Sample code:
#!/usr/bin/env python3
class A(object):
def __bytes__(self) -> bytes:
return b'An A'
print(bytes(A()))
Output from mypy 0.521, Python 3.5.2:
test.py:7: error: No overload variant of "bytes" matches argument types [test.A]
Looking in typeshed, it has this overload:
class bytes(ByteString):
@overload
def __init__(self, o: SupportsBytes) -> None: ...
which doesn't seem to be matching.