Skip to content

MAINT: Misc np.array_api annotation fixes #19969

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 5 commits into from
Sep 30, 2021
Merged

MAINT: Misc np.array_api annotation fixes #19969

merged 5 commits into from
Sep 30, 2021

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Sep 27, 2021

Ping @asmeurer.

This PR introduces a number of minor annotation-related fixes to np.array_api.
The individual comments go into more detail regarding the nature of the various fixes.

Comment on lines +38 to +39
_T = TypeVar("_T")
NestedSequence = Sequence[Sequence[_T]]
Copy link
Member Author

Choose a reason for hiding this comment

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

NestedSequence needs a free (subscriptable) parameter based on how it's used in np.array_api.asarray:

NestedSequence[bool | int | float],

Copy link
Member Author

Choose a reason for hiding this comment

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

Off topic: mypy has some basic support for recursive types these days,
so it is now possible to define a proper arbitrary-nested sequence type with the help of protocols (xref #19894)

@BvB93 BvB93 changed the title MAINT: Misc annotation fixes MAINT: Misc np.array_api annotation fixes Sep 27, 2021
@asmeurer
Copy link
Member

These issues should also be mentioned at data-apis/array-api#143

Changed as `Array` does not live in the main `np.array_api` namespace
@BvB93
Copy link
Member Author

BvB93 commented Sep 29, 2021

I feel that the points that had to be addressed have now been addressed (including updates to the spec where needed).
Are there any further comments on this PR?

@asmeurer
Copy link
Member

This looks good to me.

@seberg
Copy link
Member

seberg commented Sep 30, 2021

Well, if Aaron thinks this is good, lets get it in. Thanks Bas!

@seberg seberg merged commit 561ddde into numpy:main Sep 30, 2021
@BvB93 BvB93 deleted the array-api branch October 4, 2021 23:14
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.

4 participants