Skip to content

Commit ce47d1f

Browse files
committed
🤖 don't join, but union two different kind of types
1 parent 577bff4 commit ce47d1f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎tool/testgen.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,18 @@ def _union(*types: str) -> str:
262262

263263
def _join(*types: str) -> str:
264264
"""Find the common base type, i.e. union + upcast."""
265+
if len(types) == 1:
266+
return types[0]
267+
265268
numbers, other = __group_types(*types)
266269
if other and numbers:
267270
raise NotImplementedError(f"join of non-number types: {types}")
268271

272+
if len(types) == len(numbers) == 2 and not other:
273+
# union two types if they're different kinds, e.g. `np.int8 | np.uint8` instead
274+
# of `np.integer`
275+
return " | ".join(kind_types[0] for kind_types in numbers.values())
276+
269277
# special case for accidental `bool` return from `timedelta64.__eq__` on numpy <2.3
270278
if not numbers and len(other) == 2 and set(other) == {f"{NP}.bool", "bool"}:
271279
return f"{NP}.bool"

0 commit comments

Comments
 (0)