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

Fix type annotation for Axes.get_legend() to include None#30321

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
timhoffm merged 4 commits intomatplotlib:mainfromnrnavaneet:feature-branch
Jul 17, 2025

Conversation

nrnavaneet
Copy link
Contributor

@nrnavaneetnrnavaneet commentedJul 16, 2025
edited
Loading

Summary

Updates the type annotation of Axes.get_legend() to reflect that the method may return None, improving accuracy and static type checking support.

Updates

  • Fixed Axes.set(..., None) to skip unchanged limits
  • Added test in test_axes.py for None behavior

Uses

  • Ensures static type checkers like mypy and IDEs correctly interpret the return type.
  • Prevents false-positive warnings for None checks when using Axes.get_legend()
  • Aligns .pyi type stubs with the actual implementation and docstring.

Tests

  • Added test_get_legend_returns_none_and_legend in test_axes.py
  • Verifies get_legend() returns None initially, then returns legend after creation

closes#30318

@nrnavaneet
Copy link
ContributorAuthor

@timhoffm, I've submitted the PR as per the approval. Kindly check and lmk if any changes are required.
Happy to update it. Thank you for the opportunity :)

@rcomer
Copy link
Member

Thanks@nrnavaneet, the typing change seems good but the new test seems unrelated.

@nrnavaneet
Copy link
ContributorAuthor

nrnavaneet commentedJul 16, 2025
edited
Loading

Oh shoot ! Wrong test. I've made the changes.
Thanks for pointing that out !

@rcomer
Copy link
Member

If you are using AI to help with your contributions, please check everything it produces before submitting it. See alsohttps://matplotlib.org/devdocs/devel/contribute.html#restrictions-on-generative-ai-usage

I would not generally expect to see a test added with a typing change. In this case, I am in two minds whether to keep it. On one hand, test coverage is in general a good thing and this particular test is not expensive. On the other hand, the method in question is so simple that it is hard to see how it could go wrong, and there are existing tests that exercise it withintest_legend.py (although they are targeting other functionality).

@nrnavaneet
Copy link
ContributorAuthor

Sorry !!, Still a new contributor. Im still figuring things out. Shldve checked before committing. My bad , wont happen again. It was simple idk why i made it so complex. If u want u can discard this pr :(.
Ive Read the rules, thanks again for pointing that out; it won't happen again. I love contributing to this repo.

@nrnavaneet
Copy link
ContributorAuthor

Kindly lmk how u wanna proceed. I respect any decision you make

Copy link
Member

@dstansbydstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For a simple typing change/fix, I agree that we don't need to add a test. Please could you remove the test?

@nrnavaneet
Copy link
ContributorAuthor

Ofcourse! Will do r8 away !

@nrnavaneet
Copy link
ContributorAuthor

Removed the test as per the suggestion. Thank you :)

@rcomerrcomer added this to thev3.10.4 milestoneJul 17, 2025
@timhoffmtimhoffm merged commit2b75c9e intomatplotlib:mainJul 17, 2025
44 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJul 17, 2025
@nrnavaneetnrnavaneet deleted the feature-branch branchJuly 17, 2025 18:50
dstansby added a commit that referenced this pull requestJul 17, 2025
…321-on-v3.10.xBackport PR#30321 on branch v3.10.x (Fix type annotation for Axes.get_legend() to include None)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm approved these changes

@rcomerrcomerrcomer approved these changes

@dstansbydstansbyAwaiting requested review from dstansby

Assignees
No one assigned
Projects
None yet
Milestone
v3.10.4
Development

Successfully merging this pull request may close these issues.

[Bug]: type annotation ofAxes.get_legend() missesNone
4 participants
@nrnavaneet@rcomer@timhoffm@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp