Skip to content

Commit fcf7e2b

Browse files
Merge pull request #331 from egraphs-good/fix-mypy
Clean up type ignores
2 parents f170223 + bba4ae6 commit fcf7e2b

File tree

8 files changed

+39
-39
lines changed

8 files changed

+39
-39
lines changed

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ preview = true
234234

235235
[tool.mypy]
236236
ignore_missing_imports = true
237-
warn_redundant_casts = true
238-
check_untyped_defs = true
239-
strict_equality = true
240-
warn_unused_configs = true
241237
allow_redefinition = true
242238
exclude = ["__snapshots__", "_build", "^conftest.py$"]
243-
# mypy_path = "python"
244-
# explicit_package_bases = true
245-
# namespace_packages = true
239+
warn_unused_configs = true
240+
disallow_subclassing_any = true
241+
check_untyped_defs = true
242+
warn_redundant_casts = true
243+
warn_unused_ignores = true
244+
strict_equality = true
245+
extra_checks = true
246246

247247
[tool.maturin]
248248
python-source = "python"

python/egglog/builtins.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(self, value: str) -> None: ...
9191
def eval(self) -> str:
9292
return self.value
9393

94-
@method(preserve=True) # type: ignore[misc]
94+
@method(preserve=True) # type: ignore[prop-decorator]
9595
@property
9696
def value(self) -> str:
9797
if (value := get_literal_value(self)) is not None:
@@ -122,7 +122,7 @@ def __init__(self, value: bool) -> None: ...
122122
def eval(self) -> bool:
123123
return self.value
124124

125-
@method(preserve=True) # type: ignore[misc]
125+
@method(preserve=True) # type: ignore[prop-decorator]
126126
@property
127127
def value(self) -> bool:
128128
if (value := get_literal_value(self)) is not None:
@@ -165,7 +165,7 @@ def __init__(self, value: int) -> None: ...
165165
def eval(self) -> int:
166166
return self.value
167167

168-
@method(preserve=True) # type: ignore[misc]
168+
@method(preserve=True) # type: ignore[prop-decorator]
169169
@property
170170
def value(self) -> int:
171171
if (value := get_literal_value(self)) is not None:
@@ -239,14 +239,14 @@ def log2(self) -> i64: ...
239239
def __invert__(self) -> i64: ...
240240

241241
@method(egg_fn="<")
242-
def __lt__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type]
242+
def __lt__(self, other: i64Like) -> Unit: # type: ignore[has-type]
243243
...
244244

245245
@method(egg_fn=">")
246246
def __gt__(self, other: i64Like) -> Unit: ...
247247

248248
@method(egg_fn="<=")
249-
def __le__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type]
249+
def __le__(self, other: i64Like) -> Unit: # type: ignore[has-type]
250250
...
251251

252252
@method(egg_fn=">=")
@@ -292,7 +292,7 @@ def __init__(self, value: float) -> None: ...
292292
def eval(self) -> float:
293293
return self.value
294294

295-
@method(preserve=True) # type: ignore[misc]
295+
@method(preserve=True) # type: ignore[prop-decorator]
296296
@property
297297
def value(self) -> float:
298298
if (value := get_literal_value(self)) is not None:
@@ -341,14 +341,14 @@ def __rtruediv__(self, other: f64Like) -> f64: ...
341341
def __rmod__(self, other: f64Like) -> f64: ...
342342

343343
@method(egg_fn="<")
344-
def __lt__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
344+
def __lt__(self, other: f64Like) -> Unit: # type: ignore[has-type]
345345
...
346346

347347
@method(egg_fn=">")
348348
def __gt__(self, other: f64Like) -> Unit: ...
349349

350350
@method(egg_fn="<=")
351-
def __le__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
351+
def __le__(self, other: f64Like) -> Unit: # type: ignore[has-type]
352352
...
353353

354354
@method(egg_fn=">=")
@@ -387,7 +387,7 @@ class Map(BuiltinExpr, Generic[T, V]):
387387
def eval(self) -> dict[T, V]:
388388
return self.value
389389

390-
@method(preserve=True) # type: ignore[misc]
390+
@method(preserve=True) # type: ignore[prop-decorator]
391391
@property
392392
def value(self) -> dict[T, V]:
393393
d = {}
@@ -457,7 +457,7 @@ class Set(BuiltinExpr, Generic[T]):
457457
def eval(self) -> set[T]:
458458
return self.value
459459

460-
@method(preserve=True) # type: ignore[misc]
460+
@method(preserve=True) # type: ignore[prop-decorator]
461461
@property
462462
def value(self) -> set[T]:
463463
if (args := get_callable_args(self, Set[T])) is not None:
@@ -527,7 +527,7 @@ class MultiSet(BuiltinExpr, Generic[T]):
527527
def eval(self) -> list[T]:
528528
return self.value
529529

530-
@method(preserve=True) # type: ignore[misc]
530+
@method(preserve=True) # type: ignore[prop-decorator]
531531
@property
532532
def value(self) -> list[T]:
533533
if (args := get_callable_args(self, MultiSet[T])) is not None:
@@ -582,7 +582,7 @@ class Rational(BuiltinExpr):
582582
def eval(self) -> Fraction:
583583
return self.value
584584

585-
@method(preserve=True) # type: ignore[misc]
585+
@method(preserve=True) # type: ignore[prop-decorator]
586586
@property
587587
def value(self) -> Fraction:
588588
match get_callable_args(self, Rational):
@@ -651,11 +651,11 @@ def sqrt(self) -> Rational: ...
651651
@method(egg_fn="cbrt")
652652
def cbrt(self) -> Rational: ...
653653

654-
@method(egg_fn="numer") # type: ignore[misc]
654+
@method(egg_fn="numer") # type: ignore[prop-decorator]
655655
@property
656656
def numer(self) -> i64: ...
657657

658-
@method(egg_fn="denom") # type: ignore[misc]
658+
@method(egg_fn="denom") # type: ignore[prop-decorator]
659659
@property
660660
def denom(self) -> i64: ...
661661

@@ -666,7 +666,7 @@ class BigInt(BuiltinExpr):
666666
def eval(self) -> int:
667667
return self.value
668668

669-
@method(preserve=True) # type: ignore[misc]
669+
@method(preserve=True) # type: ignore[prop-decorator]
670670
@property
671671
def value(self) -> int:
672672
match get_callable_args(self, BigInt.from_string):
@@ -744,14 +744,14 @@ def __invert__(self) -> BigInt: ...
744744
def bits(self) -> BigInt: ...
745745

746746
@method(egg_fn="<")
747-
def __lt__(self, other: BigIntLike) -> Unit: # type: ignore[empty-body,has-type]
747+
def __lt__(self, other: BigIntLike) -> Unit: # type: ignore[has-type]
748748
...
749749

750750
@method(egg_fn=">")
751751
def __gt__(self, other: BigIntLike) -> Unit: ...
752752

753753
@method(egg_fn="<=")
754-
def __le__(self, other: BigIntLike) -> Unit: # type: ignore[empty-body,has-type]
754+
def __le__(self, other: BigIntLike) -> Unit: # type: ignore[has-type]
755755
...
756756

757757
@method(egg_fn=">=")
@@ -793,7 +793,7 @@ class BigRat(BuiltinExpr):
793793
def eval(self) -> Fraction:
794794
return self.value
795795

796-
@method(preserve=True) # type: ignore[misc]
796+
@method(preserve=True) # type: ignore[prop-decorator]
797797
@property
798798
def value(self) -> Fraction:
799799
match get_callable_args(self, BigRat):
@@ -862,11 +862,11 @@ def sqrt(self) -> BigRat: ...
862862
@method(egg_fn="cbrt")
863863
def cbrt(self) -> BigRat: ...
864864

865-
@method(egg_fn="numer") # type: ignore[misc]
865+
@method(egg_fn="numer") # type: ignore[prop-decorator]
866866
@property
867867
def numer(self) -> BigInt: ...
868868

869-
@method(egg_fn="denom") # type: ignore[misc]
869+
@method(egg_fn="denom") # type: ignore[prop-decorator]
870870
@property
871871
def denom(self) -> BigInt: ...
872872

@@ -893,7 +893,7 @@ class Vec(BuiltinExpr, Generic[T]):
893893
def eval(self) -> tuple[T, ...]:
894894
return self.value
895895

896-
@method(preserve=True) # type: ignore[misc]
896+
@method(preserve=True) # type: ignore[prop-decorator]
897897
@property
898898
def value(self) -> tuple[T, ...]:
899899
if get_callable_args(self, Vec.empty) is not None:
@@ -972,7 +972,7 @@ class PyObject(BuiltinExpr):
972972
def eval(self) -> object:
973973
return self.value
974974

975-
@method(preserve=True) # type: ignore[misc]
975+
@method(preserve=True) # type: ignore[prop-decorator]
976976
@property
977977
def value(self) -> object:
978978
expr = cast("RuntimeExpr", self).__egg_typed_expr__.expr

python/egglog/egraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ def _rewrite_or_rule_generator(gen: RewriteOrRuleGenerator, frame: FrameType) ->
17671767
combined = {**gen.__globals__, **frame.f_locals}
17681768
hints = get_type_hints(gen, combined, combined)
17691769
args = [_var(p.name, hints[p.name], egg_name=None) for p in signature(gen).parameters.values()]
1770-
return list(gen(*args)) # type: ignore[misc]
1770+
return list(gen(*args))
17711771

17721772

17731773
FactLike = Fact | BaseExpr

python/egglog/exp/program_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def compile(self, next_sym: i64 = i64(0)) -> Unit:
7979
Triggers compilation of the program.
8080
"""
8181

82-
@method(merge=lambda old, _new: old) # type: ignore[misc]
82+
@method(merge=lambda old, _new: old) # type: ignore[prop-decorator]
8383
@property
8484
def parent(self) -> Program:
8585
"""
@@ -108,7 +108,7 @@ def __init__(self, program: Program, globals: object) -> None:
108108
"""
109109

110110
# Only allow it to be set once, b/c hash of functions not stable
111-
@method(merge=lambda old, _new: old) # type: ignore[misc]
111+
@method(merge=lambda old, _new: old) # type: ignore[prop-decorator]
112112
@property
113113
def as_py_object(self) -> PyObject:
114114
"""

python/egglog/version_compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def _collect_type_vars_monkeypatch(types_, typevar_types=None):
3939
if isinstance(t, typevar_types) and t not in tvars:
4040
tvars.append(t)
4141
# **MONKEYPATCH CHANGE HERE TO ADD RuntimeClass**
42-
if isinstance(t, (typing._GenericAlias, typing.GenericAlias, types.UnionType, RuntimeClass)): # type: ignore[name-defined]
42+
if isinstance(t, (typing._GenericAlias, typing.GenericAlias, types.UnionType, RuntimeClass)):
4343
tvars.extend([t for t in t.__parameters__ if t not in tvars])
4444
return tuple(tvars)
4545

python/tests/test_high_level.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,12 +895,12 @@ def __init__(self) -> None: ...
895895

896896
__match_args__ = ("a", "b")
897897

898-
@method(preserve=True) # type: ignore[misc]
898+
@method(preserve=True) # type: ignore[prop-decorator]
899899
@property
900900
def a(self) -> int:
901901
return 1
902902

903-
@method(preserve=True) # type: ignore[misc]
903+
@method(preserve=True) # type: ignore[prop-decorator]
904904
@property
905905
def b(self) -> str:
906906
return "hi"
@@ -923,7 +923,7 @@ def __init__(self) -> None: ...
923923

924924
__match_args__ = ("a",)
925925

926-
@method(preserve=True) # type: ignore[misc]
926+
@method(preserve=True) # type: ignore[prop-decorator]
927927
@property
928928
def a(self) -> int:
929929
raise AttributeError

python/tests/test_program_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def __mul__(self, other: Math) -> Math: ...
2323

2424
def __neg__(self) -> Math: ...
2525

26-
@method(cost=1000) # type: ignore[misc]
26+
@method(cost=1000) # type: ignore[prop-decorator]
2727
@property
2828
def program(self) -> Program: ...
2929

python/tests/test_runtime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ def test_classmethod_call():
5151
)
5252
Map = RuntimeClass(Thunk.value(decls), TypeRefWithVars("Map"))
5353
with pytest.raises(TypeConstraintError):
54-
Map.create() # type: ignore[operator]
54+
Map.create()
5555
i64 = RuntimeClass(Thunk.value(decls), TypeRefWithVars("i64"))
5656
unit = RuntimeClass(Thunk.value(decls), TypeRefWithVars("unit"))
5757
assert (
58-
Map[i64, unit].create().__egg_typed_expr__ # type: ignore[union-attr, operator]
58+
Map[i64, unit].create().__egg_typed_expr__ # type: ignore[union-attr]
5959
== TypedExprDecl(
6060
JustTypeRef("Map", (JustTypeRef("i64"), JustTypeRef("unit"))),
6161
CallDecl(ClassMethodRef("Map", "create"), (), (JustTypeRef("i64"), JustTypeRef("unit"))),

0 commit comments

Comments
 (0)