Skip to content

Commit 2b325e6

Browse files
committed
Fix pre-existing mypy failures in random.py and einsum.py
Update type: ignore comments to use correct error codes for mypy 1.20: - random.py: suppress unreachable warning in match/case - einsum.py: replace stale misc/has-type codes with str-unpack/arg-type
1 parent d42712b commit 2b325e6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

pytensor/link/numba/dispatch/random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def fallback_rv(_core_shape, *args):
424424

425425
match core_rv_fn_and_cache_key:
426426
case (core_rv_fn, (int() | None) as core_cache_key):
427-
pass
427+
pass # type: ignore[unreachable]
428428
case (_core_rv_fn, invalid_core_cache_key):
429429
raise ValueError(
430430
f"Invalid core_cache_key returned from numba_core_rv_funcify: {invalid_core_cache_key}. Must be int or None."

pytensor/tensor/einsum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,11 @@ def einsum(subscripts: str, *operands: "TensorLike", optimize=None) -> TensorVar
608608
case 3:
609609
# New API doesn't have index removed
610610
contraction_list = []
611-
for pos, step_ein_str, _ in contraction_list_raw: # type: ignore[misc]
611+
for pos, step_ein_str, _ in contraction_list_raw: # type: ignore[str-unpack]
612612
# e.g., 'ijp,oij->op' -> removed_str = {'i', 'j'}
613-
inp_str, out_str = step_ein_str.replace(",", "").split("->") # type: ignore[has-type]
613+
inp_str, out_str = step_ein_str.replace(",", "").split("->")
614614
removed_idx = set(inp_str) - set(out_str)
615-
contraction_list.append((pos, removed_idx, step_ein_str)) # type: ignore[has-type]
615+
contraction_list.append((pos, removed_idx, step_ein_str)) # type: ignore[arg-type]
616616
case _:
617617
raise ValueError("Unexpected contraction list template")
618618
del contraction_list_raw

0 commit comments

Comments
 (0)