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

Use --no-implicit-optional for type checking #208

Closed

Conversation

hauntsaninja
Copy link
Contributor

This makes type checking PEP 484 compliant (as of 2018).
mypy will change its defaults soon.

See:
https://github.com/hauntsaninja/no_implicit_optional
python/mypy#9091
python/mypy#13401

@davidhalter
Copy link
Owner

Why? I like implicit optionals.

hauntsaninja added a commit to hauntsaninja/parso that referenced this pull request Sep 27, 2022
Keeps things working when you upgrade mypy versions.
The other way of solving this problem is in davidhalter#208
@hauntsaninja
Copy link
Contributor Author

Okay, I'll close this in favour of #209 then :-)

Is your question why PEP 484 was changed? In the early days of type checking in Python, type checkers played fast and loose with None, basically treating it the way Java treats null (anything can be None at any point in time and mypy won't complain about it). Once that was changed, this meant this was the only place in the type system where a variable isn't of the type its type annotation says it is, which is pretty surprising. It also contributed to the common confusion of what Optional means: many new typing users conflate it with whether or not an argument can be omitted (because it has a default value).

@hauntsaninja hauntsaninja deleted the no-implicit-optional branch September 28, 2022 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants