diff --git a/pyproject.toml b/pyproject.toml index 1f8dcebc..64cb15b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -234,15 +234,15 @@ preview = true [tool.mypy] ignore_missing_imports = true -warn_redundant_casts = true -check_untyped_defs = true -strict_equality = true -warn_unused_configs = true allow_redefinition = true exclude = ["__snapshots__", "_build", "^conftest.py$"] -# mypy_path = "python" -# explicit_package_bases = true -# namespace_packages = true +warn_unused_configs = true +disallow_subclassing_any = true +check_untyped_defs = true +warn_redundant_casts = true +warn_unused_ignores = true +strict_equality = true +extra_checks = true [tool.maturin] python-source = "python" diff --git a/python/egglog/builtins.py b/python/egglog/builtins.py index 9d8b9cd4..6064941e 100644 --- a/python/egglog/builtins.py +++ b/python/egglog/builtins.py @@ -91,7 +91,7 @@ def __init__(self, value: str) -> None: ... def eval(self) -> str: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> str: if (value := get_literal_value(self)) is not None: @@ -122,7 +122,7 @@ def __init__(self, value: bool) -> None: ... def eval(self) -> bool: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> bool: if (value := get_literal_value(self)) is not None: @@ -165,7 +165,7 @@ def __init__(self, value: int) -> None: ... def eval(self) -> int: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> int: if (value := get_literal_value(self)) is not None: @@ -239,14 +239,14 @@ def log2(self) -> i64: ... def __invert__(self) -> i64: ... @method(egg_fn="<") - def __lt__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type] + def __lt__(self, other: i64Like) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">") def __gt__(self, other: i64Like) -> Unit: ... @method(egg_fn="<=") - def __le__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type] + def __le__(self, other: i64Like) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">=") @@ -292,7 +292,7 @@ def __init__(self, value: float) -> None: ... def eval(self) -> float: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> float: if (value := get_literal_value(self)) is not None: @@ -341,14 +341,14 @@ def __rtruediv__(self, other: f64Like) -> f64: ... def __rmod__(self, other: f64Like) -> f64: ... @method(egg_fn="<") - def __lt__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type] + def __lt__(self, other: f64Like) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">") def __gt__(self, other: f64Like) -> Unit: ... @method(egg_fn="<=") - def __le__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type] + def __le__(self, other: f64Like) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">=") @@ -387,7 +387,7 @@ class Map(BuiltinExpr, Generic[T, V]): def eval(self) -> dict[T, V]: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> dict[T, V]: d = {} @@ -457,7 +457,7 @@ class Set(BuiltinExpr, Generic[T]): def eval(self) -> set[T]: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> set[T]: if (args := get_callable_args(self, Set[T])) is not None: @@ -527,7 +527,7 @@ class MultiSet(BuiltinExpr, Generic[T]): def eval(self) -> list[T]: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> list[T]: if (args := get_callable_args(self, MultiSet[T])) is not None: @@ -582,7 +582,7 @@ class Rational(BuiltinExpr): def eval(self) -> Fraction: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> Fraction: match get_callable_args(self, Rational): @@ -651,11 +651,11 @@ def sqrt(self) -> Rational: ... @method(egg_fn="cbrt") def cbrt(self) -> Rational: ... - @method(egg_fn="numer") # type: ignore[misc] + @method(egg_fn="numer") # type: ignore[prop-decorator] @property def numer(self) -> i64: ... - @method(egg_fn="denom") # type: ignore[misc] + @method(egg_fn="denom") # type: ignore[prop-decorator] @property def denom(self) -> i64: ... @@ -666,7 +666,7 @@ class BigInt(BuiltinExpr): def eval(self) -> int: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> int: match get_callable_args(self, BigInt.from_string): @@ -744,14 +744,14 @@ def __invert__(self) -> BigInt: ... def bits(self) -> BigInt: ... @method(egg_fn="<") - def __lt__(self, other: BigIntLike) -> Unit: # type: ignore[empty-body,has-type] + def __lt__(self, other: BigIntLike) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">") def __gt__(self, other: BigIntLike) -> Unit: ... @method(egg_fn="<=") - def __le__(self, other: BigIntLike) -> Unit: # type: ignore[empty-body,has-type] + def __le__(self, other: BigIntLike) -> Unit: # type: ignore[has-type] ... @method(egg_fn=">=") @@ -793,7 +793,7 @@ class BigRat(BuiltinExpr): def eval(self) -> Fraction: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> Fraction: match get_callable_args(self, BigRat): @@ -862,11 +862,11 @@ def sqrt(self) -> BigRat: ... @method(egg_fn="cbrt") def cbrt(self) -> BigRat: ... - @method(egg_fn="numer") # type: ignore[misc] + @method(egg_fn="numer") # type: ignore[prop-decorator] @property def numer(self) -> BigInt: ... - @method(egg_fn="denom") # type: ignore[misc] + @method(egg_fn="denom") # type: ignore[prop-decorator] @property def denom(self) -> BigInt: ... @@ -893,7 +893,7 @@ class Vec(BuiltinExpr, Generic[T]): def eval(self) -> tuple[T, ...]: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> tuple[T, ...]: if get_callable_args(self, Vec.empty) is not None: @@ -972,7 +972,7 @@ class PyObject(BuiltinExpr): def eval(self) -> object: return self.value - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def value(self) -> object: expr = cast("RuntimeExpr", self).__egg_typed_expr__.expr diff --git a/python/egglog/egraph.py b/python/egglog/egraph.py index 25a4505b..52d21f6b 100644 --- a/python/egglog/egraph.py +++ b/python/egglog/egraph.py @@ -1767,7 +1767,7 @@ def _rewrite_or_rule_generator(gen: RewriteOrRuleGenerator, frame: FrameType) -> combined = {**gen.__globals__, **frame.f_locals} hints = get_type_hints(gen, combined, combined) args = [_var(p.name, hints[p.name], egg_name=None) for p in signature(gen).parameters.values()] - return list(gen(*args)) # type: ignore[misc] + return list(gen(*args)) FactLike = Fact | BaseExpr diff --git a/python/egglog/exp/program_gen.py b/python/egglog/exp/program_gen.py index 68c03f70..933ec256 100644 --- a/python/egglog/exp/program_gen.py +++ b/python/egglog/exp/program_gen.py @@ -79,7 +79,7 @@ def compile(self, next_sym: i64 = i64(0)) -> Unit: Triggers compilation of the program. """ - @method(merge=lambda old, _new: old) # type: ignore[misc] + @method(merge=lambda old, _new: old) # type: ignore[prop-decorator] @property def parent(self) -> Program: """ @@ -108,7 +108,7 @@ def __init__(self, program: Program, globals: object) -> None: """ # Only allow it to be set once, b/c hash of functions not stable - @method(merge=lambda old, _new: old) # type: ignore[misc] + @method(merge=lambda old, _new: old) # type: ignore[prop-decorator] @property def as_py_object(self) -> PyObject: """ diff --git a/python/egglog/version_compat.py b/python/egglog/version_compat.py index e29f4932..2dc74fa4 100644 --- a/python/egglog/version_compat.py +++ b/python/egglog/version_compat.py @@ -39,7 +39,7 @@ def _collect_type_vars_monkeypatch(types_, typevar_types=None): if isinstance(t, typevar_types) and t not in tvars: tvars.append(t) # **MONKEYPATCH CHANGE HERE TO ADD RuntimeClass** - if isinstance(t, (typing._GenericAlias, typing.GenericAlias, types.UnionType, RuntimeClass)): # type: ignore[name-defined] + if isinstance(t, (typing._GenericAlias, typing.GenericAlias, types.UnionType, RuntimeClass)): tvars.extend([t for t in t.__parameters__ if t not in tvars]) return tuple(tvars) diff --git a/python/tests/test_high_level.py b/python/tests/test_high_level.py index a2b6b002..c5bb13e2 100644 --- a/python/tests/test_high_level.py +++ b/python/tests/test_high_level.py @@ -895,12 +895,12 @@ def __init__(self) -> None: ... __match_args__ = ("a", "b") - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def a(self) -> int: return 1 - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def b(self) -> str: return "hi" @@ -923,7 +923,7 @@ def __init__(self) -> None: ... __match_args__ = ("a",) - @method(preserve=True) # type: ignore[misc] + @method(preserve=True) # type: ignore[prop-decorator] @property def a(self) -> int: raise AttributeError diff --git a/python/tests/test_program_gen.py b/python/tests/test_program_gen.py index c6113128..a93fc52a 100644 --- a/python/tests/test_program_gen.py +++ b/python/tests/test_program_gen.py @@ -23,7 +23,7 @@ def __mul__(self, other: Math) -> Math: ... def __neg__(self) -> Math: ... - @method(cost=1000) # type: ignore[misc] + @method(cost=1000) # type: ignore[prop-decorator] @property def program(self) -> Program: ... diff --git a/python/tests/test_runtime.py b/python/tests/test_runtime.py index 95e72084..f0d3094a 100644 --- a/python/tests/test_runtime.py +++ b/python/tests/test_runtime.py @@ -51,11 +51,11 @@ def test_classmethod_call(): ) Map = RuntimeClass(Thunk.value(decls), TypeRefWithVars("Map")) with pytest.raises(TypeConstraintError): - Map.create() # type: ignore[operator] + Map.create() i64 = RuntimeClass(Thunk.value(decls), TypeRefWithVars("i64")) unit = RuntimeClass(Thunk.value(decls), TypeRefWithVars("unit")) assert ( - Map[i64, unit].create().__egg_typed_expr__ # type: ignore[union-attr, operator] + Map[i64, unit].create().__egg_typed_expr__ # type: ignore[union-attr] == TypedExprDecl( JustTypeRef("Map", (JustTypeRef("i64"), JustTypeRef("unit"))), CallDecl(ClassMethodRef("Map", "create"), (), (JustTypeRef("i64"), JustTypeRef("unit"))),