1/X Fix check_untyped_defs = True mypy errors#5673
1/X Fix check_untyped_defs = True mypy errors#5673bluetech merged 2 commits intopytest-dev:featuresfrom
Conversation
ddd265a to
cd300cc
Compare
|
Updated to fix a couple CI failures. |
|
@bluetech |
|
Oh, it does not enabled |
cd300cc to
64e551f
Compare
I rebased, it's ready from my side. I don't mind if it's squashed - I mostly split it for reviewing. Let me know if you want me to do it.
Yes, I didn't want to send too much in one PR. I will follow up with more. |
|
@bluetech |
This is nice for self-documentation, and is the type required by mypy for adding to sys.meta_path.
64e551f to
7259c45
Compare
Codecov Report
@@ Coverage Diff @@
## features #5673 +/- ##
============================================
- Coverage 96.25% 96.21% -0.05%
============================================
Files 117 117
Lines 25948 25993 +45
Branches 2497 2497
============================================
+ Hits 24977 25008 +31
- Misses 667 677 +10
- Partials 304 308 +4
Continue to review full report at Codecov.
|
|
@blueyed I squashed all of the commits except for the first one. |
blueyed
left a comment
There was a problem hiding this comment.
I've quickly compared the old and new number of issues with --check-untyped-defs: 219 before, 134 after.
|
I merged this, thanks everyone. Next parts will come soon. |
check_untyped_defs = Trueinstructs mypy to also check bodies of functions which are not annotated (doc).I would like to enable this option because it provides some internal dogfooding of the type annotations as they are added. For example, we added type annotations for
pytest.raises, but since all of the tests are untyped, the tests weren't checked against it. Withcheck_untyped_defs = True, there is at least some basic coverage (number of parameters, parameter names, etc.).There are a few hundred such errors, mostly mypy complaining that it can't infer the type of empty containers, but some other minor stuff as well. This PR fixes the error for a first batch of modules. Each commit handles a separate module.