8000 TYP: add missing annotations for ``numpy.object_.__new__`` by jorenham · Pull Request #26865 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TYP: add missing annotations for numpy.object_.__new__ #26865

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 1 commit into from
Aug 30, 2024

Conversation

jorenham
Copy link
Member
@jorenham jorenham commented Jul 5, 2024

Due to a mypy bug (python/mypy#15182), this cannot be type-tested.
However, I confirmed that with pyright, the (currently commented-out) typetests succeed.
According to the official typing specs, these __new__ annotations are valid, as well

Previously, np.object(...) always returned an instance of np.object_ according to its annotations.
Due to the mypy bug, mypy still thinks it does.
But other typecheckers, e.g. pyright, now correctly types that e.g. object_() -> None. object_('spam') -> 'spam', and object_([]) -> array([], dtype=object).

@jorenham jorenham changed the title [TYP] add missing annotations for numpy.object_.__new__ TYP: add missing annotations for numpy.object_.__new__ Jul 5, 2024
@jorenham jorenham force-pushed the fix-object_-constructor-signature branch from 2d6021f to 414efe1 Compare July 5, 2024 17:29
@ngoldbaum
Copy link
Member

Hi! Thanks so much for your PRs to improve NumPy's typing. Unfortunately our bandwidth to review these PRs isn't very high right now and it may take a while to review.

You may want to drop by one of our community or PR triage meetings on Wednesdays to introduce yourself and give a little context to your PRs, see the NumPy community calendar for dates and times.

Ping @BvB93, there are a few other typing PRs from the same author too.

@charris charris changed the title TYP: add missing annotations for numpy.object_.__new__ TYP: add missing annotations for numpy.object_.__new__ Jul 8, 2024
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jul 8, 2024
@jorenham
Copy link
Member Author
jorenham commented Jul 9, 2024

@seberg

@jorenham jorenham force-pushed the fix-object_-constructor-signature branch 3 times, most recently from b72d0c7 to 64f79e6 Compare July 18, 2024 19:51
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jul 20, 2024
@jorenham jorenham force-pushed the fix-object_-constructor-signature branch 2 times, most recently from 9736679 to 3378362 Compare July 23, 2024 21:24
@jorenham jorenham force-pushed the fix-object_-constructor-signature branch from 3378362 to e971242 Compare August 15, 2024 09:46
@jorenham jorenham closed this Aug 15, 2024
@jorenham jorenham deleted the fix-object_-constructor-signature branch August 15, 2024 09:57
@jorenham jorenham restored the fix-object_-constructor-signature branch August 15, 2024 10:05
@jorenham jorenham reopened this Aug 15, 2024
@jorenham jorenham requested a review from seberg August 15, 2024 10:06
@charris charris merged commit cfeed27 into numpy:main Aug 30, 2024
100 of 120 checks passed
@charris
Copy link
Member
charris commented Aug 30, 2024

Thanks @jorenham .

@jorenham jorenham deleted the fix-object_-constructor-signature branch August 30, 2024 19:48
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
0