Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
44 changes: 22 additions & 22 deletions python/egglog/builtins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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=">=")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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=">=")
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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: ...

Expand All @@ -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):
Expand Down Expand Up @@ -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=">=")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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: ...

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/egglog/egraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions python/egglog/exp/program_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion python/egglog/version_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions python/tests/test_high_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_program_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))),
Expand Down
Loading