8000 BUG: Fixed an issue wherein `_GenericAlias.__getitem__` would raise for types with >1 parameters by BvB93 · Pull Request #19094 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Fixed an issue wherein _GenericAlias.__getitem__ would raise for types with >1 parameters #19094

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
May 25, 2021

Conversation

BvB93
Copy link
Member
@BvB93 BvB93 commented May 25, 2021

Backport of #19092.

Found and fixed a minor bug wherein _GenericAlias could raise under certain circumstances.

The issue was that only a single parameter was passed to underlying generic types,
even if aforementioned types would demand more than 1 parameter.

Examples

The behavior prior to this PR:

In [1]: from typing import TypeVar, Union
   ...: 
   ...: import numpy as np
   ...: import numpy.typing as npt
   ...: 
   ...: T1 = TypeVar("T1", bound=np.generic)
   ...: T2 = TypeVar("T2", bound=np.generic)
   ...: 
   ...: NDArray_A_or_B = npt.NDArray[Union[T1, T2]]

In [2]: NDArray_A_or_B[np.float32, np.float64]
  ...
TypeError: Too few parameters for typing.Union[~T1, ~T2]; actual 1, expected 2

@BvB93
Copy link
Member Author
BvB93 commented May 25, 2021

/home/circleci/repo/doc/source/release/1.21.0rc1+3-notes.rst: WARNING: document isn't included in any toctree

CI failure seems to be unrelated.

@charris charris merged commit 080faad into numpy:maintenance/1.21.x May 25, 2021
@charris
Copy link
Member
charris commented May 25, 2021

Thanks Bas. That circleci error is going to be a pain for rc releases. We should fix it.

@mattip
Copy link
Member
mattip commented May 25, 2021

That circleci error is going to be a pain for rc releases. We should fix it.

Adding :orphan: to the top of the offending document should fix it

@charris
Copy link
Member
charris commented May 25, 2021

Adding :orphan: to the top of the offending document should fix it

There is no 1.21.0rc1+3-notes.rst. Circleci is inventing the name based on the current version.

@charris
Copy link
Member
charris commented May 25, 2021

Seems it is built by towncrier.

@charris
Copy link
Member
charris commented May 25, 2021

The problem is in setup.py here

MAJOR, MINOR, MICRO = FULLVERSION.split('.')[:3]

This works for 1.22.0.dev0+11.gfe3d717080 but not for 1.21.0rc1+3.g080faad7a2.

@BvB93 BvB93 deleted the generic-alias-bug2 branch May 25, 2021 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0