Skip to content

Draft: [DEP] Deprecate setting the shape attribute of a numpy array #29492

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

eendebakpt
Copy link
Contributor

Addresses part of #28800.

Comment on lines +2172 to 2173
@deprecated("Setting the shape on a NumPy array has been deprecated in NumPy 2.4")
@shape.setter
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure why, but my instinct tells me that these two should be swapped

Suggested change
@deprecated("Setting the shape on a NumPy array has been deprecated in NumPy 2.4")
@shape.setter
@shape.setter
@deprecated("Setting the shape on a NumPy array has been deprecated in NumPy 2.4")

That's probably because I know from experience that this way it'll work for both mypy and pyright, whereas I'm not sure about the other way around. But then again, maybe it doesn't matter 🤷🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed the style a couple of lines below for strides.setter. Could you check how this works with mypy and pyright?

Copy link
Member

Choose a reason for hiding this comment

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

mypy indeed doesn't seem to like it this way:

image

Swapping them seems to help:

image

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