Skip to content

Commit d840393

Browse files
committed
Fix py2
1 parent 742fd46 commit d840393

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.claude/settings.local.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66
"Bash(xonsh:*)",
77
"Bash(gh:*)",
88
"Bash(pip:*)",
9+
"Bash(conda:*)",
910
"Bash(make test-tests:*)",
1011
"WebSearch",
1112
"WebFetch(domain:coconut.readthedocs.io)",
1213
"WebFetch(domain:github.com)",
1314
"WebFetch(domain:peps.python.org)",
1415
"WebFetch(domain:pypi.org)",
15-
"WebFetch(domain:discuss.python.org)"
16+
"WebFetch(domain:discuss.python.org)",
17+
"WebFetch(domain:doc.pypy.org)"
1618
]
1719
}
1820
}

coconut/root.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ def __instancecheck__(cls, inst):
107107
return _coconut.isinstance(inst, (_coconut_py_int, _coconut_py_long))
108108
def __subclasscheck__(cls, subcls):
109109
return _coconut.issubclass(subcls, (_coconut_py_int, _coconut_py_long))
110+
def __eq__(cls, other):
111+
if other is _coconut_py_int or other is _coconut_py_long:
112+
return True
113+
return _coconut.type.__eq__(cls, other)
114+
def __hash__(cls):
115+
return _coconut.hash(_coconut_py_int)
110116
class bytes(_coconut_py_bytes):
111117
__slots__ = ()
112118
__doc__ = getattr(_coconut_py_bytes, "__doc__", "<see help(py_bytes)>")
@@ -115,6 +121,12 @@ def __instancecheck__(cls, inst):
115121
return _coconut.isinstance(inst, _coconut_py_bytes)
116122
def __subclasscheck__(cls, subcls):
117123
return _coconut.issubclass(subcls, _coconut_py_bytes)
124+
def __eq__(cls, other):
125+
if other is _coconut_py_bytes:
126+
return True
127+
return _coconut.type.__eq__(cls, other)
128+
def __hash__(cls):
129+
return _coconut.hash(_coconut_py_bytes)
118130
def __new__(self, *args):
119131
if not args:
120132
return b""

coconut/tests/src/cocotest/agnostic/primary_2.coco

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ def primary_test_2() -> bool:
491491
assert reduce(function=(+), iterable=range(5), initial=-1) == 9 # type: ignore
492492
assert takewhile(predicate=ident, iterable=[1, 2, 1, 0, 1]) |> list == [1, 2, 1] # type: ignore
493493
assert dropwhile(predicate=(not), iterable=range(5)) |> list == [1, 2, 3, 4] # type: ignore
494+
assert type(1) == int
495+
assert type(b"") == bytes
494496
@memoize(typed=True)
495497
def typed_memoized_func(x):
496498
if x is 1:

0 commit comments

Comments
 (0)