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 hints for undeprecated contour APIs#27217

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
rcomer merged 1 commit intomatplotlib:mainfromksunden:contour_type
Oct 28, 2023

Conversation

ksunden
Copy link
Member

PR summary

They had been in the limbo land of deprecated APIs that I didn't bother to ensure were thebest type
hints because they were deprecated.
So I just added them to the allowlist for stubtest, but now that they are undeprecated,
make sure that they are correct.

While I'm here, may as well get rid of the allow list entries for all of them,
even the ones that are still deprecated, as that is documented standard practice going
forward that pyi match implementation for deprecations as well

PR checklist

@ksundenksunden added this to thev3.8.1 milestoneOct 27, 2023
Comment on lines 114 to 116
def allkinds(self) -> list[np.ndarray]: ...
@property
def allsegs(self) -> list[np.ndarray]: ...
Copy link
Member

Choose a reason for hiding this comment

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

If I've read these correctly, these are lists of lists of arrays:

Suggested change
defallkinds(self)->list[np.ndarray]: ...
@property
defallsegs(self)->list[np.ndarray]: ...
defallkinds(self)->list[list[np.ndarray]]: ...
@property
defallsegs(self)->list[list[np.ndarray]]: ...

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, and technically the source of these isPath.codes andPath.vertices, which actually are only typed asArrayLike... and the former can actually just beNone (though that is not reflected by the type hint) as well (which I saw when I just ran it to be sure it was actually nested lists)

It is one of these "in practice in this usage the typewill be ndarray or None", but that is relying on knowledge outside of the type system... so I suspect if we were to inline the type hints it would cause a clash...

I also think that theNone behavior is not super intentional in this context... There is a note in thePath docstring that says "don't use codes directly, useiter_segments so that you don't get the Nones from codes"

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Only the empty path Ithink willactually havecodes=None... but that is in fact a case covered by the code...

@ksunden
Copy link
MemberAuthor

Noticed thattcolors (one of the still deprecated properties) isalso missing a layer of nesting, for some reason it is a list of 1-tuples of 4-tuples...

They whad been in the limbo land of deprecated APIs that I didn't bother to ensure were the _best_ type hints because they were deprecated. So I just added them to the allowlist for stubtest, but now that they are undeprecated, make sure that they are correct. While I'm here, may as well get rid of the allow list entries for all of them, even the ones that are still deprecated, as that is documented standard practice going forward that pyi match implementation for deprecations as well
@QuLogic
Copy link
Member

Yes, good catch.

Copy link
Member

@rcomerrcomer left a comment

Choose a reason for hiding this comment

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

I'm glad I am not the only one confused bytcolors.

@rcomerrcomer merged commit518b268 intomatplotlib:mainOct 28, 2023
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.8.xgit pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 518b268a5e94f8dcec079cb07eb735981e5ac0ef
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #27217: Fix type hints for undeprecated contour APIs'
  1. Push to a named branch:
git push YOURFORK v3.8.x:auto-backport-of-pr-27217-on-v3.8.x
  1. Create a PR against branch v3.8.x, I would have named this PR:

"Backport PR#27217 on branch v3.8.x (Fix type hints for undeprecated contour APIs)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove theStill Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free tosuggest an improvement.

rcomer added a commit to rcomer/matplotlib that referenced this pull requestOct 28, 2023
timhoffm added a commit that referenced this pull requestOct 28, 2023
Backport PR#27217 on branch v3.8.x: Fix type hints for undeprecated contour APIs
@ksundenksunden mentioned this pull requestNov 2, 2023
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic approved these changes

@rcomerrcomerrcomer approved these changes

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

Successfully merging this pull request may close these issues.

3 participants
@ksunden@QuLogic@rcomer

[8]ページ先頭

©2009-2025 Movatter.jp