papercast
papercast copied to clipboard
Enable code analysis for plugins
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 #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__.pyifile to be able to import frompapercast.processorsimportArxivProcessorinstead of frompapercast.processors.arxiv_processorimportArxivProcessor.- Note: if we're ok with the messier import suggested in #10 we might be able to skip this step?
- 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