-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 rudimentary mypy type checking #5575
Conversation
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.
please also add additional_dependencies: [flake8-typing-imports]
to the flake8
hook configuration in .pre-commit-config.yaml
Codecov Report
@@ Coverage Diff @@
## features #5575 +/- ##
============================================
+ Coverage 96.08% 96.09% +<.01%
============================================
Files 117 117
Lines 25716 25728 +12
Branches 2494 2494
============================================
+ Hits 24709 24723 +14
+ Misses 702 701 -1
+ Partials 305 304 -1
Continue to review full report at Codecov.
|
Thanks @bluetech for working on this! I've changed the title to "WIP" to explicitly state this is not yet prime for merging. 👍 |
I updated the PR to address some of @asottile's comments. |
Updated again. I've switched to use pre-commit and addresses some of the other comments. Currently some of the tests are failing, but I can't check what causes them exactly ATM - will check later, but I pushed anyway. |
Add a very lax mypy configuration, add it to tox -e linting, and fix/ignore the few errors that come up. The idea is to get it running before diving in too much. This enables: - Progressively adding type annotations and enabling more strict options, which will improve the codebase (IMO). - Annotating the public API in-line, and eventually exposing it to library users who use type checkers (with a py.typed file). Though, none of this is done yet. Refs pytest-dev#3342.
Updated - CI looks happy now. I added I also changed the mypy pre-commit to use |
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.
@nicoddemus ok with cherry-picking this to master? I'd like to be able to iterate on this there (and not have it regress) |
@asottile it doesn't add any extra dependencies to users of the library or changes any public API, so feel free to go ahead! 👍 |
@@ -188,11 +189,11 @@ def path(self): | |||
""" path to the source code """ | |||
return self.frame.code.path | |||
|
|||
def getlocals(self): | |||
@property |
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.
that one is a breaking change of the api
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 don't think Code
objects are exposed -- or at least I can't find any cases that they are (?)
@@ -31,6 +33,9 @@ | |||
from _pytest.outcomes import fail | |||
from _pytest.outcomes import TEST_OUTCOME | |||
|
|||
if False: # TYPE_CHECKING | |||
from typing import Type |
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.
Why is this only imported conditionally, but not the others?
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.
it is not available in python 3.5.0 / 3.5.1
(This PR is currently an RFC, I will discuss it in issue #3342).
Add a very lax mypy configuration, add it to tox -e linting, and
fix/ignore the few errors that come up. The idea is to get it running
before diving in too much.
This enables:
Progressively adding type annotations and enabling more strict
options, which will improve the codebase (IMO).
Annotating the public API in-line, and eventually exposing it to
library users who use type checkers (with a py.typed file).
Though, none of this is done yet.
Refs #3342.