Skip to content

Enable code analysis for plugins #9

@papercast-dev

Description

@papercast-dev

Issue: Pylance in VSCode is unable to recognize the dynamically imported plugins in the papercast package, leading to issues like "Go to definition" not working as expected for the installed plugins.

Example:

from papercast.processors import ArxivProcessor

In the above import statement, Pylance does not recognize the ArxivProcessor imported from the papercast.processors package after papercast-arxiv plugin is installed.

Possible solution:

  • Change the plugin structure to one folder with four files: subscribers.py, processors.py, publishers.py, types.py Enforce file naming conventions for plugins #11 . Classes of each type should belong to each file. Maybe not a bad idea anyway.
  • At install time for each plugin, generate stubs for each file, and place them in the corresponding submodule folders e.g. papercast/processors/stubs/. Alternatively, figure out a way to generate stubs for only a specific class from within a module using stubgen.
  • Modify the __init__.pyi file to be able to import from papercast.processors import ArxivProcessor instead of from papercast.processors.arxiv_processor import ArxivProcessor.
  • Make an init.pyi file with contents from .stubs import *
  • Add a line to the papercast/processors/__init__.py:
    from papercast.processors import *

Notes:

  • stubs/init.pyi is shared across plugins, maybe not ideal

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions