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

'cast' is missing overload for type 'builtins.object' #4810

Closed
septatrix opened this issue Dec 12, 2020 · 4 comments
Closed

'cast' is missing overload for type 'builtins.object' #4810

septatrix opened this issue Dec 12, 2020 · 4 comments
Labels
stubs: false positive Type checkers report false errors

Comments

@septatrix
Copy link
Contributor

cast also accept arguments like Optional[int] and Union[str, bytes] which are not of type Type but instead are of type builtins.object. Such an overload however is missing from the typeshed which only lists overloads for Type and str

@septatrix
Copy link
Contributor Author

Mypy currently does not generate warnings for such usage of cast as it handles it in a way which apparently also seems to suppress this error. Manually creating a new method with the same signature as is currently provided for cast however leads to errors from mypy when using such a method in the same places as cast.

@hauntsaninja
Copy link
Collaborator

See also: python/mypy#9773

@septatrix
Copy link
Contributor Author

Thanks for pointing me towards that issue. The example given there is also how I stumbled upon this bug (implementing a cast-like function). Even if that proposal leads to something the signature for cast should be adjusted for current versions.

@srittau
Copy link
Collaborator

srittau commented Dec 14, 2020

True, cast should probably get another overload to handle these cases. PR welcome as always.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stubs: false positive Type checkers report false errors
Projects
None yet
Development

No branches or pull requests

3 participants