Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
davidar committed Oct 26, 2024
1 parent 96dc9ca commit 9176eeb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mathics/core/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ def is_uncertain_final_definitions(self, definitions) -> bool:
def get_attributes(self, definitions):
return definitions.get_attributes(self.name)

def get_name(self) -> str:
def get_name(self, short=False) -> str:
return self.name

def get_sort_key(self, pattern_sort=False) -> tuple:
Expand Down
13 changes: 9 additions & 4 deletions mathics/eval/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

# TODO: disentangle me
def create_rules(
rules_expr: BaseElement,
rules_expr: Expression,
expr: Expression,
name: str,
evaluation: Evaluation,
extra_args: OptionalType[List] = None,
) -> Tuple[Union[List[Rule], BaseElement], bool]:
) -> Tuple[Union[List[Rule], BaseElement, None], bool] | "Dispatch":
"""
This function implements `Replace`, `ReplaceAll`, `ReplaceRepeated`
and `ReplaceList` eval methods.
Expand All @@ -35,7 +35,7 @@ def create_rules(
if isinstance(rules_expr, Dispatch):
return rules_expr.rules, False
if rules_expr.has_form("Dispatch", None):
if rules_expr.head is SymbolList:
if rules_expr.get_head() is SymbolList:
return Dispatch(rules_expr.elements, evaluation)
return Dispatch((rules_expr,), evaluation)

Expand Down Expand Up @@ -149,7 +149,12 @@ def eval_replace_with_levelspec(expr, rules, ls, heads, evaluation, options):
class Dispatch(Atom):
class_head_name = "System`Dispatch"

def __init__(self, rule_tuple: Expression, evaluation: Evaluation) -> None:
src: ListExpression
rules: list[Rule]

def __init__(
self, rule_tuple: tuple[Expression, ...], evaluation: Evaluation
) -> None:
assert isinstance(rule_tuple, tuple)
self.src = ListExpression(*rule_tuple)
try:
Expand Down

0 comments on commit 9176eeb

Please sign in to comment.