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

Remove some unnecessary checks for None #1464

Merged
merged 2 commits into from
May 2, 2016

Conversation

rwbarton
Copy link
Contributor

@rwbarton rwbarton commented May 2, 2016

I find extraneous checks of this kind confusing; suggesting that None is expected as a possible value when in fact it has no meaning and is (or is expected to be) impossible.

self.actual is declared as having type Type, and (as of commit
b602ecc) cannot be None.
self.variables is declared as having type List[TypeVarDef], and can
never be None.
@gvanrossum
Copy link
Member

Did you check the history of those lines? They look like the kind of things that might have been put in to avoid a crash.

@rwbarton
Copy link
Contributor Author

rwbarton commented May 2, 2016

I know that the TypeVarType one really could have been None until b602ecc, and the check for None is much older than that (42b9328 which also added a test that reproduced the crash).

The is_generic one is unchanged from 2012 when this file was written in the mypy language; there doesn't seem to have ever been a version of this line without the None check, so I think either it was redundant from the start, or there were surrounding changes that made it redundant (I have some uncertainty due to not knowing the runtime semantics of the old mypy language!)

@gvanrossum
Copy link
Member

The first comes from 42b9328 (fixes #674) and I worry that you might be reintroducing the bug.

The second comes from d3872f9 and it looks like you're doing the right thing there.

@gvanrossum
Copy link
Member

OK, our messages crossed. I see your point. Merging.

@gvanrossum gvanrossum merged commit 3acdf54 into python:master May 2, 2016
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.

2 participants