-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
User-plugin system #3512
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
User-plugin system #3512
Conversation
@@ -113,6 +117,9 @@ def __init__(self) -> None: | |||
self.debug_cache = False | |||
self.quick_and_dirty = False | |||
|
|||
# plugins | |||
self.plugins = [] # type: List[PluginRegistry] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is producing an error when running the tests that I don't understand:
mypy/options.py:121: error: Invalid type "mypy.plugin.PluginRegistry"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that this is because of a reference cycle. There is a known bug that mypy does not treat named tuples in cycles correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the heads up. I suspected a cycle too, but knew that they seemed to be working in general. I'll see if I can resolve the cycle elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for information here is the issue about cycles #3054
…ectly for NamedTuples
Odd that only 3.5.1 seems to have a problem importing |
Two advantages: - simplifies mypy.build - related to instantiating user plugins will occur sooner (in main instead of build)
The typing module is provisional and some features were added halfway through the 3.5 series. I believe we test 3.5.1 because that's what Dropbox uses internally. |
Yes that's exactly right. |
This provides a bit more flexibility and also let's us get around the fact that typing.Type does not exist in python 3.5.1.
Ok, worked around it. |
@chadrik Closing this now. If you have further improvements to the plugin system, please send them as new PRs. |
Here's a design sketch for #1240.
Some thoughts, copied from there:
Plugin discovery options
/path/to/myplugin.py
. could also extend this with aMYPY_PLUGIN_PATH
pip
to install pluginspackage.module
Sub-Options
Plugin
, or make this configurable as well? e.g.package.module.MyPlugin
or/path/to/myplugin.py:MyPlugin
(Note: I've already written some functionality for the latter in my hooks branch)mypy.plugin.Plugin
?Plugin chainability options
None
result. we could then cache the mapping from feature (e.g.'typing.Mapping.get'
) to user-plugin instance to speed up future lookups.Plugin
instance around.Right now I'm using discovery option B and chainability option A, but this is just a starting point for debate.