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

Off by one error using enumerate #1046

Open
JulianWgs opened this issue Jan 24, 2024 · 0 comments
Open

Off by one error using enumerate #1046

JulianWgs opened this issue Jan 24, 2024 · 0 comments

Comments

@JulianWgs
Copy link

JulianWgs commented Jan 24, 2024

def bug():
    sequence = range(6)
    for k, _ in enumerate(sequence):
        pass
    return k

Regular Python returns 5 (correct), mypy compiled code returns 6 (wrong). Inside the loop the `k variable is correct.

Python 3.10.12
mypy 1.8.0

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

No branches or pull requests

1 participant