Skip to content

Commit b50753c

Browse files
committed
Remove unused parameters to parse actions
Pyparsing allows you to leave out the parameters (starting from the left) if they are unused.
1 parent 9dfa263 commit b50753c

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,18 +2070,18 @@ def push_state(self):
20702070
"""Push a new `State` onto the stack, copying the current state."""
20712071
self._state_stack.append(self.get_state().copy())
20722072

2073-
def main(self, s, loc, toks):
2073+
def main(self, toks):
20742074
return [Hlist(toks)]
20752075

2076-
def math_string(self, s, loc, toks):
2076+
def math_string(self, toks):
20772077
return self._math_expression.parseString(toks[0][1:-1], parseAll=True)
20782078

2079-
def math(self, s, loc, toks):
2079+
def math(self, toks):
20802080
hlist = Hlist(toks)
20812081
self.pop_state()
20822082
return [hlist]
20832083

2084-
def non_math(self, s, loc, toks):
2084+
def non_math(self, toks):
20852085
s = toks[0].replace(r'\$', '$')
20862086
symbols = [Char(c, self.get_state()) for c in s]
20872087
hlist = Hlist(symbols)
@@ -2092,7 +2092,7 @@ def non_math(self, s, loc, toks):
20922092

20932093
float_literal = staticmethod(pyparsing_common.convertToFloat)
20942094

2095-
def text(self, s, loc, toks):
2095+
def text(self, toks):
20962096
self.push_state()
20972097
state = self.get_state()
20982098
state.font = 'rm'
@@ -2132,12 +2132,12 @@ def _make_space(self, percentage):
21322132
r'\!': -0.16667, # -3/18 em = -3 mu
21332133
}
21342134

2135-
def space(self, s, loc, toks):
2135+
def space(self, toks):
21362136
num = self._space_widths[toks["space"]]
21372137
box = self._make_space(num)
21382138
return [box]
21392139

2140-
def customspace(self, s, loc, toks):
2140+
def customspace(self, toks):
21412141
return [self._make_space(toks["space"])]
21422142

21432143
def symbol(self, s, loc, toks):
@@ -2215,7 +2215,7 @@ def unknown_symbol(self, s, loc, toks):
22152215

22162216
_wide_accents = set(r"widehat widetilde widebar".split())
22172217

2218-
def accent(self, s, loc, toks):
2218+
def accent(self, toks):
22192219
state = self.get_state()
22202220
thickness = state.get_current_underline_thickness()
22212221
accent = toks["accent"]
@@ -2276,30 +2276,30 @@ def operatorname(self, s, loc, toks):
22762276

22772277
return Hlist(hlist_list)
22782278

2279-
def start_group(self, s, loc, toks):
2279+
def start_group(self, toks):
22802280
self.push_state()
22812281
# Deal with LaTeX-style font tokens
22822282
if toks.get("font"):
22832283
self.get_state().font = toks.get("font")
22842284
return []
22852285

2286-
def group(self, s, loc, toks):
2286+
def group(self, toks):
22872287
grp = Hlist(toks.get("group", []))
22882288
return [grp]
22892289

2290-
def required_group(self, s, loc, toks):
2290+
def required_group(self, toks):
22912291
return Hlist(toks.get("group", []))
22922292

22932293
optional_group = required_group
22942294

2295-
def end_group(self, s, loc, toks):
2295+
def end_group(self):
22962296
self.pop_state()
22972297
return []
22982298

22992299
def unclosed_group(self, s, loc, toks):
23002300
raise ParseFatalException(s, len(s), "Expected '}'")
23012301

2302-
def font(self, s, loc, toks):
2302+
def font(self, toks):
23032303
self.get_state().font = toks["font"]
23042304
return []
23052305

@@ -2320,9 +2320,6 @@ def is_slanted(self, nucleus):
23202320
return nucleus.is_slanted()
23212321
return False
23222322

2323-
def is_between_brackets(self, s, loc):
2324-
return False
2325-
23262323
def subsuper(self, s, loc, toks):
23272324
nucleus = toks.get("nucleus", Hbox(0))
23282325
subsuper = toks.get("subsuper", [])
@@ -2523,26 +2520,26 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
25232520
return self._auto_sized_delimiter(ldelim, result, rdelim)
25242521
return result
25252522

2526-
def style_literal(self, s, loc, toks):
2523+
def style_literal(self, toks):
25272524
return self._MathStyle(int(toks["style_literal"]))
25282525

2529-
def genfrac(self, s, loc, toks):
2526+
def genfrac(self, toks):
25302527
return self._genfrac(
25312528
toks.get("ldelim", ""), toks.get("rdelim", ""),
25322529
toks["rulesize"], toks.get("style", self._MathStyle.TEXTSTYLE),
25332530
toks["num"], toks["den"])
25342531

2535-
def frac(self, s, loc, toks):
2532+
def frac(self, toks):
25362533
return self._genfrac(
25372534
"", "", self.get_state().get_current_underline_thickness(),
25382535
self._MathStyle.TEXTSTYLE, toks["num"], toks["den"])
25392536

2540-
def dfrac(self, s, loc, toks):
2537+
def dfrac(self, toks):
25412538
return self._genfrac(
25422539
"", "", self.get_state().get_current_underline_thickness(),
25432540
self._MathStyle.DISPLAYSTYLE, toks["num"], toks["den"])
25442541

2545-
def binom(self, s, loc, toks):
2542+
def binom(self, toks):
25462543
return self._genfrac(
25472544
"(", ")", 0,
25482545
self._MathStyle.TEXTSTYLE, toks["num"], toks["den"])
@@ -2579,7 +2576,7 @@ def _genset(self, s, loc, toks):
25792576

25802577
overset = underset = _genset
25812578

2582-
def sqrt(self, s, loc, toks):
2579+
def sqrt(self, toks):
25832580
root = toks.get("root")
25842581
body = toks["value"]
25852582
state = self.get_state()
@@ -2619,7 +2616,7 @@ def sqrt(self, s, loc, toks):
26192616
rightside]) # Body
26202617
return [hlist]
26212618

2622-
def overline(self, s, loc, toks):
2619+
def overline(self, toks):
26232620
body = toks["body"]
26242621

26252622
state = self.get_state()
@@ -2670,14 +2667,14 @@ def _auto_sized_delimiter(self, front, middle, back):
26702667
hlist = Hlist(parts)
26712668
return hlist
26722669

2673-
def auto_delim(self, s, loc, toks):
2670+
def auto_delim(self, toks):
26742671
return self._auto_sized_delimiter(
26752672
toks["left"],
26762673
# if "mid" in toks ... can be removed when requiring pyparsing 3.
26772674
toks["mid"].asList() if "mid" in toks else [],
26782675
toks["right"])
26792676

2680-
def boldsymbol(self, s, loc, toks):
2677+
def boldsymbol(self, toks):
26812678
self.push_state()
26822679
state = self.get_state()
26832680
hlist = []
@@ -2703,7 +2700,7 @@ def boldsymbol(self, s, loc, toks):
27032700

27042701
return Hlist(hlist)
27052702

2706-
def substack(self, s, loc, toks):
2703+
def substack(self, toks):
27072704
parts = toks["parts"]
27082705
state = self.get_state()
27092706
thickness = state.get_current_underline_thickness()

0 commit comments

Comments
 (0)