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 explicit float type hint to attribute zoom#27958

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

Draft
Larsimusrex wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromLarsimusrex:main

Conversation

Larsimusrex
Copy link

Fixing Issue [#27957] by adding a explicit type hint, to prevent assumed int type.

Copy link

@github-actionsgithub-actionsbot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@ksunden
Copy link
Member

I'm quite hesitant to add a lone type hint in an otherwise untyped module. Especially doing so inline when the bulk of the library uses stub files.

I'm sorry that pylance is inferring the wrong type, but we did not provide any type hints for 3D (or othermpl_toolkits), so this one error is likely to be followed up with many many more. As such I'm not inclined to play whack-a-mole on individual errors in untyped modules.

I'd not be opposed to a bit larger scope of expanding type hints into 3D, and wouldn't even be too offput by doing less than complete hinting, but I think the granularity needs to be likely per file, not down to a single hint. I think my inclination is to do stubs here as well, though willing to be convinced to do inline (currently we only do inline in pyplot (which is partially generated code), tests (which are only minimal hints to appease checkers), and one or two private modules (mostly to lay foundation for perhaps inlining in the future, but probably not for at least one more release cycle, probably longer))

scottshambaugh reacted with thumbs up emoji

@@ -345,7 +345,7 @@ def _equal_aspect_axis_indices(self, aspect):
ax_indices = [1, 2]
return ax_indices

def set_box_aspect(self, aspect, *, zoom=1):
def set_box_aspect(self, aspect, *, zoom: float =1):
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
defset_box_aspect(self,aspect,*,zoom:float=1):
defset_box_aspect(self,aspect,*,zoom=1.0):

This is a smaller change that should address the inferred type without broaching adding typehints in an unhinted module.

Again, if you are expecting type hints with 3D youwill be continually disappointed at present, so caution is in order in general.

I'm still skeptical of the whack-a-mole here, but this would be my preferred short term solution to this particular typing error.

Copy link
Author

Choose a reason for hiding this comment

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

I do agree that changing the type for a single line is a bit ridiculous, especially because the same Problem occurs at least a few dozen times in this file.

After looking at the file again there are only about 100 function, many without arguments, so wouldn't take too long to add typing to the entire file. So maybe I'll do that later.

@QuLogicQuLogic changed the titleAdded expliced float type hint to attribute zoomAdd explicit float type hint to attribute zoomMar 21, 2024
@tacaswelltacaswell marked this pull request as draftMarch 22, 2024 13:16
@tacaswell
Copy link
Member

I moved this to draft because I agree we do not want to do one-off inline type hinting. We should either do a stub for the whole file or change the default to 1.0 to help down stream inferences.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ksundenksundenksunden left review comments

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@Larsimusrex@ksunden@tacaswell@scottshambaugh

[8]ページ先頭

©2009-2025 Movatter.jp