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

Add some types to _mathtext.py#30119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:mainfromjkseppan:mathtext-type-fix
May 30, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
@jkseppan
jkseppan committedMay 30, 2025
commitea5d85f67d4aeda04a94e3842217f89130e62cea
6 changes: 3 additions & 3 deletionslib/matplotlib/_mathtext.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2524,10 +2524,10 @@ def subsuper(self, s: str, loc: int, toks: ParseResults) -> T.Any:
if len(new_children):
# remove last kern
if (isinstance(new_children[-1], Kern) and
hasattr(new_children[-2],'_metrics')):
isinstance(new_children[-2],Char)):
new_children = new_children[:-1]
last_char = new_children[-1]
ifhasattr(last_char,'_metrics'):
ifisinstance(last_char,Char):
last_char.width = last_char._metrics.advance
# create new Hlist without kerning
nucleus = Hlist(new_children, do_kern=False)
Expand DownExpand Up@@ -2603,7 +2603,7 @@ def subsuper(self, s: str, loc: int, toks: ParseResults) -> T.Any:

# Do we need to add a space after the nucleus?
# To find out, check the flag set by operatorname
spaced_nucleus = [nucleus, x]
spaced_nucleus: list[Node] = [nucleus, x]
if self._in_subscript_or_superscript:
spaced_nucleus += [self._make_space(self._space_widths[r'\,'])]
self._in_subscript_or_superscript = False
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp