Skip to content

Conversation

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Dec 1, 2025

closes #1485

  • Closes #xxxx (Replace xxxx with the Github issue number)
  • Tests added (Please use assert_type() to assert the type of any return value)
  • If I used AI to develop this pull request, I prompted it to follow AGENTS.md.

@MarcoGorelli MarcoGorelli marked this pull request as ready for review December 1, 2025 21:31
Comment on lines 1684 to 1686
check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type]
else:
check(assert_type(ind.view(np.ndarray), np_ndarray), np.ndarray) # type: ignore[assert-type] # pyright: ignore[reportAssertTypeFailure]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should resolve some of the ignores here, but I cannot see how. Any idea @Dr-Irv @loicdiridollou ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is some issue with how mypy is interpreting the numpy types, which are better in numpy 2.x than in numpy 1.x.

So if mypy is failing on this, so be it.

Reported python/mypy#20354

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @Dr-Irv !

@MarcoGorelli , you have added the following overload:

    @overload
    def view(self, cls: type[NDArrayT]) -> NDArrayT: ...

so if you do ind.view(np.ndarray), it seems reasonable to me to get np.ndarray as the resulting type, instead of getting np_ndarray. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typing Index

3 participants