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

Conditional redefinition of builtin doesn't work #1105

Closed
JukkaL opened this issue Jan 8, 2016 · 0 comments
Closed

Conditional redefinition of builtin doesn't work #1105

JukkaL opened this issue Jan 8, 2016 · 0 comments
Labels
false-positive mypy gave an error on correct code feature priority-2-low

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jan 8, 2016

Mypy complains about the type of next in the following example where we define a builtin if it doesn't exist:

try:
    next   # Error: Cannot determine type of next
except NameError:
    next = lambda x: x.next()

Mypy could fall back to the builtins module namespace during semantic analysis if it can't determine the type of a module-level name. This way the name would refer to the built-in definition until the first redefinition in the file.

(This is derived from #649, originally reported by @rbtcollins).

@JukkaL JukkaL added the feature label Jan 8, 2016
@ddfisher ddfisher added this to the Future milestone Mar 2, 2016
@gvanrossum gvanrossum removed this from the Future milestone Mar 29, 2017
@JukkaL JukkaL added the false-positive mypy gave an error on correct code label May 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
false-positive mypy gave an error on correct code feature priority-2-low
Projects
None yet
Development

No branches or pull requests

4 participants