Skip to content

Commit 443a9c1

Browse files
Technologicatclaude
andcommitted
typecheck.py: use isinstance for typing.Reversible
The hasattr(__reversed__) check was a workaround for Python 3.5 where typing.Reversible was a protocol that rejected isinstance. Works fine on 3.10+. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 92ad920 commit 443a9c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

unpythonic/typecheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def isNewType(T):
113113
return isinstance(value, U)
114114

115115
if T is typing.Reversible: # can't non-destructively check element type
116-
return hasattr(value, "__reversed__")
116+
return isinstance(value, typing.Reversible)
117117

118118
# "Protocols cannot be used with isinstance()", so:
119119
for U in (typing.SupportsInt,

0 commit comments

Comments
 (0)