Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit58169e5

Browse files
jkseppanmerde-bot
authored and
merde-bot
committed
Add some types to _mathtext.py
Mypy 1.16.0 flags errors here:lib/matplotlib/_mathtext.py:2531: error: "Node" has no attribute "width" [attr-defined]lib/matplotlib/_mathtext.py:2608: error: List item 0 has incompatible type "Kern"; expected "Hlist | Vlist" [list-item]The check for the attribute _metrics is equivalent to checking for aninstance of Char, since only Char and its subclasses set self._metrics.Mypy infers an unnecessarily tight type list[Hlist | Vlist] forspaced_nucleus so we give it a more general one.
1 parent1fea704 commit58169e5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎lib/matplotlib/_mathtext.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ def subsuper(self, s: str, loc: int, toks: ParseResults) -> T.Any:
25272527
hasattr(new_children[-2],'_metrics')):
25282528
new_children=new_children[:-1]
25292529
last_char=new_children[-1]
2530-
ifhasattr(last_char,'_metrics'):
2530+
ifisinstance(last_char,Char):
25312531
last_char.width=last_char._metrics.advance
25322532
# create new Hlist without kerning
25332533
nucleus=Hlist(new_children,do_kern=False)
@@ -2603,7 +2603,7 @@ def subsuper(self, s: str, loc: int, toks: ParseResults) -> T.Any:
26032603

26042604
# Do we need to add a space after the nucleus?
26052605
# To find out, check the flag set by operatorname
2606-
spaced_nucleus= [nucleus,x]
2606+
spaced_nucleus:list[Node]= [nucleus,x]
26072607
ifself._in_subscript_or_superscript:
26082608
spaced_nucleus+= [self._make_space(self._space_widths[r'\,'])]
26092609
self._in_subscript_or_superscript=False

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp