-
Couldn't load subscription status.
- Fork 3.2k
Add infrastructure support for static type-checking using mypy #4545
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
0f9d259
Add basic mypy support
pradyunsg bc637a8
:newspaper:
pradyunsg ed9208e
Improve mypy configuration
pradyunsg 9fce241
Patch pkg_resources for mypy
pradyunsg 8f92b55
Fix mypy warnings
pradyunsg da46ab2
Add type annotations to pip.configuration
pradyunsg 711596b
Use pip.utils.typing to guard typing imports
pradyunsg 7c5f901
Modify vendoring to include additional .pyi stubs
pradyunsg adf4538
Add generated stubs
pradyunsg c2371a1
Exclude the pyi files and extra directory created
pradyunsg b3e16f9
Fix mypy errors since addition of stubs
pradyunsg 55fd83f
Add a separate tox job for mypy
pradyunsg 6a0da3d
Fix a bug found by mypy
pradyunsg 9b03434
use six instead of try except
pradyunsg 3046f7a
Don't ask for permission
pradyunsg 182c548
Fix remaining errors
pradyunsg b9b5e4a
:art:
pradyunsg 1b5a23f
:wrench:
pradyunsg c365304
Merge branch 'master' into mypy/infrastructure
pradyunsg cb113d5
I actually missed a conflict. Wow.
pradyunsg 11451c5
Merge branch 'master' into mypy/infrastructure
pradyunsg d37868f
Move the typing file
pradyunsg d408818
Add imports I'd missed
pradyunsg d9a4431
Move mypy stubs as well
pradyunsg efd7264
Update MANIFEST
pradyunsg ec26f0a
Import from inner packages
pradyunsg da57810
type: Any partials in cmdoptions
pradyunsg 93d9f20
Remove a useless section
pradyunsg e2b2f70
isort all imports
pradyunsg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ pip.egg-info/ | |
| MANIFEST | ||
| .tox | ||
| .cache | ||
| .mypy_cache | ||
| *.egg | ||
| *.eggs | ||
| *.py[cod] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Integrate with mypy for utilizing static typing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry I've been quite busy these last months so I'm a little late in my review ^^
Couldn't we tag the unused imports specifically and keep this check in flake8 ?
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.
flake8 doesn't actually understand the mypy declarations and shouts about them. mypy (obviously) does and doesn't shout about valid usage.
IIRC, I remember reading somewhere in the mypy documentation that it does detect if a certain import is unused, which is what made me feel comfortable about silencing these warnings. Now that both linters are run one after another, I don't think it's an issue if mypy catches something instead of flake8.
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.
Oh, and I had looked at https://github.com/ambv/flake8-mypy -- The first line of the description of that project makes me think this approach is better suited.
Further, the "Two levels of type checking" section of that project's README motivated me to actually take this route.