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

Consider making None a normal Instance type with --strict-optional #1847

Closed
ddfisher opened this issue Jul 12, 2016 · 2 comments
Closed

Consider making None a normal Instance type with --strict-optional #1847

ddfisher opened this issue Jul 12, 2016 · 2 comments

Comments

@ddfisher
Copy link
Collaborator

NoneTyp is special cased in a lot of places, but—with strict optional—for the most part it behaves like a normal Instance type (and the special casing has to recreate that behavior). If we started tracking the truthiness of objects (see #1698), I think we could get rid of the vast majority of NoneTyp's special casing. (The only thing that I can think of that would remain its role in partial types.) This would make the code easier to reason about, and would have prevented some of the strict optional bugs we've seen so far.

@dmoisset
Copy link
Contributor

dmoisset commented Aug 5, 2016

My work on #1689 (see #1989) removed some references/special casing for NoneType inside find_isinstance_check. There's still another one there related to x is None and x is not None, probably those could be replaced by a more general analysis of expression1 is expression2 (if that is true, both expressions have the same type and some narrowings may be done, which can cover x is None as a special case).

@gvanrossum gvanrossum removed this from the 0.5 milestone Mar 29, 2017
@ilevkivskyi
Copy link
Member

It looks like it is really not worth it at this stage. It will take a lot of work but benefits are questionable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants