-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add a get_additional_deps hook to Plugin to support django-stubs #6598
Conversation
django-stubs needs to be able to add in additional dependencies to modules and is currently using monkeypatching to do it. That is 1) not great and 2) breaks under mypyc. Add a hook to support generating additional dependencies from a plugin.
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.
I left just a few minor comments.
This is good to merge, but let's wait a bit to see if this helps with the django plugin.
I've checked in https://github.com/mkurnikov/django-stubs/pull/60, all tests pass with new hook and disabled monkeypatches |
django-stubs needs to be able to add in additional dependencies to modules and is currently using monkeypatching to do it. That is 1) not great and 2) breaks under mypyc. Add a hook to support generating additional dependencies from a plugin.
|
||
Priorities are defined in mypy.build (but maybe shouldn't be). | ||
10 is a good choice for priority. | ||
""" |
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 (+ an example) should be also added to mypy/docs/source/extending_mypy.rst
.
@msullivan Will you have time to make a PR? I suppose this will be announced in the release blog post, it would be great to have some docs to link to.
django-stubs needs to be able to add in additional dependencies to
modules and is currently using monkeypatching to do it.
That is 1) not great and 2) breaks under mypyc.
Add a hook to support generating additional dependencies from a plugin.
One thing I'm unsure about with this PR is the handling of priorities. I'm not sure that being able to specify priorities is necessary, but I am reluctant to leave them out of the API and then need to either have two hooks or a breaking change when it turns out that something does need them. The priority constants are all defined in mypy.build, which plugins probably shouldn't be importing, but moving them to a new file seems like overkill for a super marginal plugin use case.
This should allow a fix for https://github.com/mkurnikov/django-stubs/issues/48. @mkurnikov could you try updating django-stubs to work with this PR so that we can validate it and cherry-pick it for the release?