-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: timestamps.pyi #40945
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: timestamps.pyi #40945
Conversation
jbrockmendel
commented
Apr 14, 2021
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
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.
lgtm @simonjayhawkins if comments
elif vtype is Timestamp: | ||
# error: Non-overlapping identity check (left operand type: "Type[generic]", | ||
# right operand type: "Type[Timestamp]") | ||
elif vtype is Timestamp: # type: ignore[comparison-overlap] |
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.
There's a cast on L1895 that looks iffy. remove it and this ignore is not needed.
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've merged master locally so the line numbers differ.
else: | ||
result = result.tz_localize(tz) | ||
# error: Too many arguments for "tz_localize" of "NaTType" | ||
result = result.tz_localize(tz) # type: ignore[call-arg] |
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.
if you update
def tz_convert(self) -> NaTType: ...
def tz_localize(self) -> NaTType: ...
in pandas/_libs/tslibs/nattype.pyi
to match the signatures added here in pandas/_libs/tslibs/timestamps.pyi
you could remove these ignores.
since these ignores appear to be false positives...
>>> pd.NaT.tz_convert("utc")
NaT
>>>
>>> pd.NaT.tz_localize("Europe/London")
NaT
# error: Incompatible return value type (got "Union[Timestamp, NaTType, | ||
# Series, Index]", expected "Union[DatetimeIndex, Series, float, str, | ||
# NaTType, None]") | ||
return result # type: ignore[return-value] |
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.
maybe use returns instead of assignment to result or change the type declaration of result to match the return type.
pd.Timedelta(days=42).asm8.view( | ||
"datetime64[ns]" | ||
) # type: ignore[arg-type] | ||
), |
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.
This is a numpy issue. can't see an issue on github, maybe fixed in master. will check soon.
Timestamp(2000, 1, 2, 3, 4, 5, 6, 1, pytz.UTC), | ||
# error: Argument 9 to "Timestamp" has incompatible type "_UTCclass"; | ||
# expected "Optional[int]" | ||
Timestamp(2000, 1, 2, 3, 4, 5, 6, 1, pytz.UTC), # type: ignore[arg-type] |
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.
hmm, looks like will also need overloads for the constructor.
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 @jbrockmendel generally lgtm. happy to merge as is to add more types and work on the ignores as a follow-up.
yah lets do as follow-ups if OK |
sure. have merged master |
Thanks @jbrockmendel |