Skip to content

reveal_type hides errors when --allow-redefinition is used #9719

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

Closed
KotlinIsland opened this issue Nov 13, 2020 · 8 comments
Closed

reveal_type hides errors when --allow-redefinition is used #9719

KotlinIsland opened this issue Nov 13, 2020 · 8 comments
Labels
bug mypy got something wrong

Comments

@KotlinIsland
Copy link
Contributor

a = 2
reveal_type(a)  # Revealed type is 'builtins.int'
a = "asdf"
note: Revealed type is 'builtins.int'
@KotlinIsland KotlinIsland added the bug mypy got something wrong label Nov 13, 2020
@hauntsaninja
Copy link
Collaborator

I can't repro

@KotlinIsland
Copy link
Contributor Author

@hauntsaninja I can reproduce:
image

@hauntsaninja
Copy link
Collaborator

Maybe try sharing a repro from https://mypy-play.net?
Obviously as the filer of this issue you can repro; repeating that information doesn't help. On the other hand, filling out the information the issue template asks for, e.g. like your mypy version, does.

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Nov 16, 2020

E.g. https://mypy-play.net/?mypy=latest&python=3.9&flags=strict&gist=07840bf89fe7ef07e4e3521d1a3708a9 shows that I can't reproduce the lack of error based on what you've posted so far

@KotlinIsland
Copy link
Contributor Author

Oh sorry, my bad. I forgot I had a mypy.ini, it's --allow-redefinition

@KotlinIsland KotlinIsland changed the title reveal_type hides errors reveal_type hides errors when --allow-redefinition is used Nov 16, 2020
@KotlinIsland
Copy link
Contributor Author

KotlinIsland commented Nov 16, 2020

mypy playground doesn't have an option for allow-redefinition?

@hauntsaninja
Copy link
Collaborator

If you have --allow-redefinition then your code isn't incorrect. The behaviour changes due to reveal_type (but substitute literally any use of a) because of #6963

@hauntsaninja
Copy link
Collaborator

Yusuke would probably happily accept a PR adding the option to mypy playground at https://github.com/ymyzk/mypy-playground/pulls :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants