Skip to content

Commit db84e84

Browse files
Change bound tp params to always be non
1 parent 2d8c30b commit db84e84

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

python/egglog/declarations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ class CallDecl:
639639
args: tuple[TypedExprDecl, ...] = ()
640640
# type parameters that were bound to the callable, if it is a classmethod
641641
# Used for pretty printing classmethod calls with type parameters
642-
bound_tp_params: tuple[JustTypeRef, ...] | None = None
642+
bound_tp_params: tuple[JustTypeRef, ...] = ()
643643

644644
# pool objects for faster __eq__
645645
_args_to_value: ClassVar[WeakValueDictionary[tuple[object, ...], CallDecl]] = WeakValueDictionary({})
@@ -654,7 +654,7 @@ def __new__(cls, *args: object, **kwargs: object) -> Self:
654654
# normalize the args/kwargs to a tuple so that they can be compared
655655
callable = args[0] if args else kwargs["callable"]
656656
args_ = args[1] if len(args) > 1 else kwargs.get("args", ())
657-
bound_tp_params = args[2] if len(args) > 2 else kwargs.get("bound_tp_params")
657+
bound_tp_params = args[2] if len(args) > 2 else kwargs.get("bound_tp_params", ())
658658

659659
normalized_args = (callable, args_, bound_tp_params)
660660
try:

python/egglog/egraph_state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ def from_call(
793793
args,
794794
# Don't include bound type params if this is just a method, we only needed them for type resolution
795795
# but dont need to store them
796-
bound_tp_params if isinstance(callable_ref, ClassMethodRef | InitRef) else None,
796+
bound_tp_params if isinstance(callable_ref, ClassMethodRef | InitRef) else (),
797797
)
798798
raise ValueError(
799799
f"Could not find callable ref for call {term}. None of these refs matched the types: {self.state.egg_fn_to_callable_refs[term.name]}"

python/egglog/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def __call__(self, *args: object, _egg_partial_function: bool = False, **kwargs:
457457
arg_exprs = tuple(arg.__egg_typed_expr__ for arg in upcasted_args)
458458
return_tp = tcs.substitute_typevars(signature.semantic_return_type, cls_name)
459459
bound_params = (
460-
cast("JustTypeRef", bound_tp).args if isinstance(self.__egg_ref__, ClassMethodRef | InitRef) else None
460+
cast("JustTypeRef", bound_tp).args if isinstance(self.__egg_ref__, ClassMethodRef | InitRef) else ()
461461
)
462462
# If we were using unstable-app to call a funciton, add that function back as the first arg.
463463
if function_value:

python/egglog/type_constraint_solver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def infer_arg_types(
5454
fn_var_args: TypeOrVarRef | None,
5555
return_: JustTypeRef,
5656
cls_name: str | None,
57-
) -> tuple[Iterable[JustTypeRef], tuple[JustTypeRef, ...] | None]:
57+
) -> tuple[Iterable[JustTypeRef], tuple[JustTypeRef, ...]]:
5858
"""
5959
Given a return type, infer the argument types. If there is a variable arg, it returns an infinite iterable.
6060
@@ -75,7 +75,7 @@ def infer_arg_types(
7575
)
7676
)
7777
if cls_name
78-
else None
78+
else ()
7979
)
8080
return arg_types, bound_typevars
8181

0 commit comments

Comments
 (0)