Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable code analysis for plugins #9

Open
papercast-dev opened this issue Apr 20, 2023 · 0 comments
Open

Enable code analysis for plugins #9

papercast-dev opened this issue Apr 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@papercast-dev
Copy link
Owner

papercast-dev commented Apr 20, 2023

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
@papercast-dev papercast-dev added the enhancement New feature or request label Apr 20, 2023
@papercast-dev papercast-dev changed the title Code analysis for plugins Enable code analysis for plugins Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant