Skip to content

Commit

Permalink
Misc lint-like stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Oct 3, 2024
1 parent 44b52cb commit 33aadac
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions mathics/builtin/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
The attributes 'Flat', 'Orderless', and 'OneIdentity' affect pattern matching.
"""

from typing import Callable, List, Optional as OptionalType, Tuple, Union
from typing import List, Optional as OptionalType, Tuple, Union

from mathics.core.atoms import Integer, Number, Rational, Real, String
from mathics.core.atoms import Integer, Integer2, Number, Rational, Real, String
from mathics.core.attributes import (
A_HOLD_ALL,
A_HOLD_FIRST,
Expand All @@ -63,7 +63,13 @@
from mathics.core.pattern import BasePattern, StopGenerator
from mathics.core.rules import Rule
from mathics.core.symbols import Atom, Symbol, SymbolList, SymbolTrue
from mathics.core.systemsymbols import SymbolBlank, SymbolDefault, SymbolDispatch
from mathics.core.systemsymbols import (
SymbolBlank,
SymbolDefault,
SymbolDispatch,
SymbolRule,
SymbolRuleDelayed,
)
from mathics.eval.parts import python_levelspec

# This tells documentation how to sort this module
Expand Down Expand Up @@ -94,15 +100,14 @@ class Rule_(BinaryOperator):
operator = "->"
attributes = A_SEQUENCE_HOLD | A_PROTECTED
grouping = "Right"
messages = {"argrx": "Rule called with `1` arguments; 2 arguments are expected."}
needs_verbatim = True
summary_text = "a replacement rule"

def eval_rule(self, elems, evaluation):
"""Rule[elems___]"""
num_parms = len(elems.get_sequence())
if num_parms != 2:
evaluation.message("Rule", "argrx", Integer(num_parms))
evaluation.message("Rule", "argrx", "Rule", Integer(num_parms), Integer2)
return None


Expand All @@ -122,9 +127,6 @@ class RuleDelayed(BinaryOperator):
"""

attributes = A_SEQUENCE_HOLD | A_HOLD_REST | A_PROTECTED
messages = {
"argrx": "RuleDelayed called with `1` arguments; 2 arguments are expected."
}
needs_verbatim = True
operator = ":>"
summary_text = "a rule that keeps the replacement unevaluated"
Expand All @@ -133,7 +135,8 @@ def eval_rule_delayed(self, elems, evaluation):
"""RuleDelayed[elems___]"""
num_parms = len(elems.get_sequence())
if num_parms != 2:
evaluation.message("RuleDelayed", "argrx", Integer(num_parms))
print("WOOT")
evaluation.message("RuleDelayed", "argrx", Integer(num_parms), Integer2)
return None


Expand Down Expand Up @@ -198,7 +201,7 @@ def create_rules(

result = []
for rule in rules:
if rule.get_head_name() not in ("System`Rule", "System`RuleDelayed"):
if rule.head not in (SymbolRule, SymbolRuleDelayed):
evaluation.message(name, "reps", rule)
return None, True
if len(rule.elements) != 2:
Expand Down

0 comments on commit 33aadac

Please sign in to comment.