Skip to content
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

TYP,ENH: Mark numpy.typing protocols as runtime checkable #22357

Merged
merged 1 commit into from Oct 2, 2022

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Sep 30, 2022

Closes #22352

The protocols used in npt.ArrayLike and npt.DTypeLike were previously not marked as runtime checkable while they easily could have been (the lack therefor being more of an oversight). This PR addresses aforementioned issue.

@charris
Copy link
Member

charris commented Sep 30, 2022

Backport?

@BvB93
Copy link
Member Author

BvB93 commented Sep 30, 2022

Backport?

I'd consider this more of an enhancement rather than a bug fix, but I wouldn't mind either way to be honest. I don't anticipate any merge conflicts when cherry picking in any case.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Sep 30, 2022
@charris charris merged commit 5490d87 into numpy:main Oct 2, 2022
@charris
Copy link
Member

charris commented Oct 2, 2022

Thanks Bas.

@charris
Copy link
Member

charris commented Oct 2, 2022

This seems to have caused a problem with the conda test after merging. https://dev.azure.com/numpy/numpy/_build/results?buildId=26134&view=logs&j=aeae9a1e-382d-52a1-f0dc-4dfb59c9608d&t=52b2fe40-7265-5065-1a6d-137421ab3f90 . Looks like hypothesis is at fault, version 6.55.0 was released two days ago with a new array_api check. Thoughts?

@mattip
Copy link
Member

mattip commented Oct 2, 2022

@Zac-HD ping

@Zac-HD
Copy link
Contributor

Zac-HD commented Oct 2, 2022

I think @honno is planning a patch to add this - I think it's meant to be a required attribute, but we might be running a bit ahead of the ecosystem here 😕. Unclear what the best medium-term solution would be (@honno?), but either adding that attribute or temporarily limiting the Hypothesis version should work. I'll also plan to turn that error into a warning+fallback-to-oldest-spec in Hypothesis.

refs: HypothesisWorks/hypothesis#3456 (comment) and data-apis/array-api#480

@Zac-HD
Copy link
Contributor

Zac-HD commented Oct 2, 2022

Or, taking the advice from the error message, we could add api_version="2021.12" to this call:

xps = make_strategies_namespace(xp)

@honno
Copy link
Contributor

honno commented Oct 2, 2022

Oh dear 😅 IMO we might as well add __array_api_version__ to the namespace now and kill two birds in one stone, so wrote a PR #22365

@charris charris changed the title TYP,ENH: Mark numpy.typing protocols as runtime checkable TYP,ENH: Mark numpy.typing protocols as runtime checkable Oct 5, 2022
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Oct 6, 2022
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.

ENH: A subset of "numpy.typing" type hints remain unusable at runtime
5 participants