Skip to content

Add type parameters to generics in isna and notna #945

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
Jun 28, 2024

Conversation

JanEricNitschke
Copy link
Contributor

@JanEricNitschke JanEricNitschke commented Jun 28, 2024

This is to fix issues with pyright strict mode which complains about partially unknown types.

I verified that this test fails in strict mode without these changes and passes with them.

There are still some points i am unsure about:

  • Whether to use Any or an (unbounded?) TypeVar (or maybe i should use Incomplete?)
  • I had to split the ArrayLike annotation into its components to add the type parameters to the ndarray. While i did also change it in the pandas-stubs/_typing.pyi, it was still importing them from the actual pandas.

@JanEricNitschke
Copy link
Contributor Author

Closes #944

@JanEricNitschke
Copy link
Contributor Author

I checked that the Any is probably the way to go unless we already know some bounds that need to be respected here.

Only open question would then be the handling of the ArrayLike. The best approach would be if we could modify (which i did) and pull in the version from the stubs. But i dont know how, do i explicitely import from pandas-stubs? But it seems to work with importing from pandas in the previous pr.

@JanEricNitschke JanEricNitschke marked this pull request as ready for review June 28, 2024 12:23
@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Jun 28, 2024

Only open question would then be the handling of the ArrayLike. The best approach would be if we could modify (which i did) and pull in the version from the stubs. But i dont know how, do i explicitely import from pandas-stubs? But it seems to work with importing from pandas in the previous pr.

In the stubs, you can do from pandas._typing import ArrayLike . The stubs do imports from themselves instead of from the pandas source.

@JanEricNitschke
Copy link
Contributor Author

Just double checked and you are right. I was getting some weird messages from vscode there. I guess it was an issue with that.

I ran pyright over just that one test and it did pick up the ArrayLike from the stubs _typing.

Copy link
Collaborator

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

@Dr-Irv Dr-Irv merged commit ea8bdee into pandas-dev:main Jun 28, 2024
13 checks passed
@JanEricNitschke JanEricNitschke deleted the fix-isna branch June 28, 2024 18:34
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.

2 participants