Skip to content

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

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all 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
2 changes: 1 addition & 1 deletion lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
def set_box_aspect(self, aspect, *, zoom: float = 1):
def set_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 you will 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.

"""
Set the Axes box aspect.

Expand Down