FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

TYP: default to `dtype[Any]` by jorenham · Pull Request #28669 · numpy/numpy · GitHub

/ numpy Public

TYP: default to dtype[Any] - #28669

Merged
charris merged 2 commits into
numpy:mainfrom
jorenham:typing/dtype-type-parameter-default
Apr 9, 2025
Merged

charris merged 2 commits into
numpy:mainfrom
jorenham:typing/dtype-type-parameter-default

Conversation

jorenham commented Apr 7, 2025

Copy link
Copy Markdown
Member

No description provided.

jorenham added 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes 41 - Static typing labels Apr 7, 2025
jorenham added a commit to jorenham/numpy that referenced this pull request Apr 7, 2025
jorenham added a commit to jorenham/numpy that referenced this pull request Apr 7, 2025
jorenham force-pushed the typing/dtype-type-parameter-default branch from 1be93d2 to c48b082 Compare April 7, 2025 20:34
jorenham added this to the 2.3.0 release milestone Apr 7, 2025
jorenham force-pushed the typing/dtype-type-parameter-default branch from c48b082 to 4b3a6b4 Compare April 7, 2025 21:31
jorenham removed the 56 - Needs Release Note. Needs an entry in doc/release/upcoming_changes label Apr 8, 2025
charris merged commit 74303b6 into numpy:main Apr 9, 2025

charris commented Apr 9, 2025

Copy link
Copy Markdown
Member

Thanks Joren.

jorenham deleted the typing/dtype-type-parameter-default branch April 9, 2025 22:36
MaanasArora pushed a commit to MaanasArora/numpy that referenced this pull request Apr 11, 2025

fzimmermann89 commented Jun 10, 2025
edited
Loading

Copy link
Copy Markdown

Is this the change that causes mypy unreachable warnings in code like this

match array.dtype:
   case np.int:
      ...
   case np.float:
     ...

?

Copy link
Copy Markdown
Member Author

Is this the change that causes mypy unreachable warnings in code like this

match array.dtype:
   case np.int:
      ...
   case np.float:
     ...

?

np.float and np.int do not exist, so that might be why

Copy link
Copy Markdown
Member Author

fzimmermann89 commented Jun 11, 2025
edited
Loading

Copy link
Copy Markdown

Sorry, the actual code is:

  match data.dtype:
         case np.uint16:
                    data = data.astype(np.int32)
         case np.uint32 | np.uint64:
                    data = data.astype(np.int64)

This works in mypy with numpy <2.2, but breaks in numpy 2.3.

But the issue is caused by array.dtype no longer being Any -- sorry.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL