Skip to content

42 in "some string" fails at runtime with TypeError but is allowed in typeshed #2937

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
ilevkivskyi opened this issue Apr 27, 2019 · 1 comment · Fixed by #2967
Closed

42 in "some string" fails at runtime with TypeError but is allowed in typeshed #2937

ilevkivskyi opened this issue Apr 27, 2019 · 1 comment · Fixed by #2967
Labels
stubs: false negative Type checkers do not report an error, but should

Comments

@ilevkivskyi
Copy link
Member

ilevkivskyi commented Apr 27, 2019

str.__contains__() is annotated as accepting object, but in fact it only accepts strings. Fixing the annotation will require a # type: ignore since this will be an incompatible override.

There is a similar problem with bytes.__contains__(), it only accepts int and bytes.

@ilevkivskyi ilevkivskyi added topic-bytes-unicode stubs: false negative Type checkers do not report an error, but should labels Apr 27, 2019
@ilevkivskyi
Copy link
Member Author

This was discovered in context of python/mypy#6674

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false negative Type checkers do not report an error, but should
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant