-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Add datetime.date and datetime.datetime specializations #1003
Conversation
alippai
commented
Sep 13, 2024
- Closes BDay typing #755
- Tests added:
Can you please add runtime tests in https://github.com/pandas-dev/pandas-stubs/blob/main/tests/test_timefuncs.py You will also need to re-order the overloads to have the more specifiy overloads before more general overloads as type checker pick the first fitting overload (see the mypy errors). |
@twoertwein thanks, I've updated the failing test and added the two cases brought up in the initial issue. Looks like |
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.
Your tests are still failing. I think the issue here is that this line is incorrect in offsets.pyi
:
_DatetimeT = TypeVar("_DatetimeT", bound=date)
I think it should be
_DatetimeT = TypeVar("_DatetimeT", bound=datetime)
based on what is now in the pandas source.
Can you try that change to see if it will make things work? Because the error you are getting is that this overload: def __add__(self, other: _DatetimeT) -> _DatetimeT: ...
will never get matched, because you put in something explicit for date
, but datetime
is a subclass of date
, so I think changing the TypeVar
line will fix it.
Looks like this is not possible to describe correctly: microsoft/pylance-release#6512 |
I'm OK with putting in the appropriate |
@Dr-Irv thanks for the guide, I believe the last commit may work as intended and pass the CI |
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 @alippai