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

Add a get_additional_deps hook to Plugin to support django-stubs #6598

Merged
merged 3 commits into from Mar 29, 2019

Conversation

@msullivan
Copy link
Collaborator

commented Mar 27, 2019

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?

Add a get_additional_deps hook to Plugin to support django-stubs
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.

@msullivan msullivan requested review from JukkaL and gvanrossum Mar 27, 2019

@JukkaL
Copy link
Collaborator

left a comment

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.

test-data/unit/check-custom-plugin.test Outdated Show resolved Hide resolved
mypy/plugin.py Show resolved Hide resolved
mypy/plugin.py Outdated Show resolved Hide resolved
@mkurnikov

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2019

I've checked in https://github.com/mkurnikov/django-stubs/pull/60, all tests pass with new hook and disabled monkeypatches
(CI fails, it is configured for stock mypy).

@msullivan msullivan merged commit 465521b into master Mar 29, 2019

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@msullivan msullivan deleted the deps-hook branch Mar 29, 2019

JukkaL added a commit that referenced this pull request Mar 29, 2019

Add a get_additional_deps hook to Plugin to support django-stubs (#6598)
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.
"""

This comment has been minimized.

Copy link
@ilevkivskyi

ilevkivskyi Apr 2, 2019

Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.