8000 BUG,TYP: Allow subscripting ``iinfo`` and ``finfo`` generic types at runtime, or omit the type params by jorenham · Pull Request #27346 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG,TYP: Allow subscripting iinfo and finfo generic types at runtime, or omit the type params #27346

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

Merged
merged 2 commits into from
Sep 5, 2024

Conversation

jorenham
Copy link
Member
@jorenham jorenham commented Sep 4, 2024

This fixes #27341 in two ways:

  • Added __class_getitem__ classmethods to numpy.(f|i)info, so that, at runtime, np.info[Any] won't raise a TypeError anymore.
  • Added PEP 696 defaults to the typing.TypeVar type-parameters of numpy.(f|i)info. Type checkers will now effectively interpret a "bare" iinfo as iinfo[integer[NBitBase]], and finfo as finfo[floating[NBitBase]]. See TYP: Assume that typing_extensions is always available in the stubs #27132 for an explanation on how this is possible on Python <3.12.

@charris charris merged commit e88e37f into numpy:main Sep 5, 2024
67 checks passed
@charris
Copy link
Member
charris commented Sep 5, 2024

Thanks @jorenham .

@jorenham jorenham deleted the bug/fix-27341 branch September 5, 2024 08:27
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.

BUG: iinfo type annotation breaks with TypeError: type 'iinfo' is not subscriptable
2 participants
0