Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged

Conversation

jkseppan
Copy link
Member

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 an
instance of Char, since only Char and its subclasses set self._metrics.

Mypy infers an unnecessarily tight type list[Hlist | Vlist] for
spaced_nucleus so we give it a more general one.

@jkseppan
Copy link
Member Author

Example of failing CI job due to this:

https://github.com/matplotlib/matplotlib/actions/runs/15325539537/job/43119002687

@jkseppan jkseppan mentioned this pull request May 29, 2025
7 tasks
@QuLogic QuLogic added this to the v3.10.4 milestone May 29, 2025
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 an
instance of Char, since only Char and its subclasses set self._metrics.

Mypy infers an unnecessarily tight type list[Hlist | Vlist] for
spaced_nucleus so we give it a more general one.
@jkseppan jkseppan force-pushed the mathtext-type-fix branch from 87ae200 to ea5d85f Compare May 30, 2025 04:37
@QuLogic QuLogic merged commit 2918b73 into matplotlib:main May 30, 2025
40 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 30, 2025
QuLogic added a commit that referenced this pull request May 30, 2025
…119-on-v3.10.x

Backport PR #30119 on branch v3.10.x (Add some types to _mathtext.py)
@QuLogic
Copy link
Member

QuLogic commented Jun 4, 2025

@meeseeksdev backport to v3.10.3-doc

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jun 4, 2025
QuLogic added a commit that referenced this pull request Jun 4, 2025
…119-on-v3.10.3-doc

Backport PR #30119 on branch v3.10.3-doc (Add some types to _mathtext.py)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants