-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
bytes(obj) rejected even when obj implements __bytes__ #3989
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
Comments
The problem is that |
Unfortunately the workaround breaks using #!/usr/bin/env python3
import typing
class A(typing.SupportsBytes):
def __bytes__(self) -> bytes:
return b'An A'
print(bytes(A()))
assert isinstance(None, A) at runtime gives
I managed to work around it by replacing |
Concerning the |
It works with the current version of mypy (0.570), so closing. |
Sample code:
Output from mypy 0.521, Python 3.5.2:
Looking in typeshed, it has this overload:
which doesn't seem to be matching.
The text was updated successfully, but these errors were encountered: