-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TYP: pd.isna #46222
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: pd.isna #46222
Conversation
Would you mind not force pushing the branch in the future? It makes it hard to see what changes you made in just the last commit. |
Okay. was rebasing on main (git pull --rebase main) but kept the new commit separate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small comment
I just do
That seems to make it easier to track things for others. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small grammatical change
@twoertwein I approved, but I think @simonjayhawkins or @jbrockmendel should take a look as well. |
This reverts commit b9288cb.
@twoertwein if you can merge master |
green, except for mypy error also present on main |
thanks @twoertwein |
NDFrameT, | ||
Scalar, | ||
npt, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @twoertwein for the PR.
I didn't want to comment on this PR before to avoid "too many cooks" and in general if mypy is happy, so am I. (In some respects, because we have mypy we don't need to review certain aspects of typing as if it is not 100% correct, it will create issues down the line. I see it like a jigsaw puzzle that won't be complete until the last piece is in place, i.e. the codebase is 100% typed.)
However, I think I've seen that your preference is to import from pandas._typing inside the TYPE_CHECKING also elsewhere? If this is correct can you explain the reasoning so that it helps when reviewing other contributors PRs.
AFAIK, we ensure all imports in pandas._typing are guarded so that they can be imported at the top level and for instance npt was added so that we could import without needing to add a TYPE_CHECKING block everywhere it was needed, otherwise we would just import from numpy directly and not include in pandas._typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I imported it within the TYPE_CHECKING block because it is only needed for type checking . I will import it outside the TYPE_CHECKING block in next PRs.
Probably one reason why I prefer to put imports in this block is that there are some import cycles that prevent even mypy to function correctly: I think having from pandas import Index
caused issues whereas from pandas.core.indexes.base import Index
worked without issues (both inside the TYPE_CHECKING block).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, for import cycles it is definitely needed. My preference is also adding imports inside the type checking if added specifically in a typing PR for type annotations but this is difficult to enforce since say a refactor could remove the need for a top level import and it would not be removed because it is still used in type annotations then in theory the import should be moved to the type checking for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having
from pandas import Index
caused issues whereasfrom pandas.core.indexes.base import Index
worked without issues (both inside the TYPE_CHECKING block).
my preference here is to use from pandas import Index
when inside the type checking block. less typing! (the fingers on the keyboard type of typing not the type annotations type of typing!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried replacing it with from pandas import Index
and it worked, must have been something different that caused weird mypy issues.
Inferred by mypy and pyright: