Adding the `--strict` option to mypy
See original GitHub issueOverview
This is the second part of the discussion from #10065 (review).
Description
I have been working on converting the type hint commentaries into proper annotations (#10004, #10018, #10065, #10074). But I had a simple mistake on #10065 by annotating this:
download_dir: str = None
when it must be annotated like this:
download_dir: Optional[str] = None
We expected that Mypy was going to fail, but it just passed by. Then, we saw that Mypy accepts implicit optional annotations, until we use --no-implicit-optional
.
What we want
We want Mypy to use --no-implicit-optional
on its checks, to make a better diagnosis. View the PR review where the original discussion is for more information.
Code of Conduct
- I agree to follow the PSF Code of Conduct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (24 by maintainers)
Top Results From Across the Web
The mypy command line - mypy 0.991 documentation
This flag disables strict checking of Optional types and None values. With this option, mypy doesn't generally check the use of None values...
Read more >`--strict` is too strict to be useful · Issue #7767 · python/mypy
I like the idea of making --strict only strict enough that we can reasonably use it in mypy. We could also support an...
Read more >mypy command line option stricter than --strict - Stack Overflow
I have the following code in test.py x = 1. Does there exist an option in mypy to force definition of type hints...
Read more >Professional-grade mypy configuration - Wolt Blog
By default, mypy doesn't require any type hints, i.e. it has disallow_untyped_defs = False by default. If you want to enforce the usage...
Read more >Mypy Documentation - Read the Docs
Adding type hints for mypy does not interfere with the way your ... Mypy has a strict mode that enables a number of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Assigned
Yea, we have to enable a bunch of mypy’s strictness flags (this is probably the highest impact among those).
The ideal goal would be to get to a point where we can run
mypy --strict .
and have everything pass.