-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
INT: take DateOffset out of the inheritance tree for BaseOffset subclasses #34147
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
INT: take DateOffset out of the inheritance tree for BaseOffset subclasses #34147
Conversation
* Python 3.9 build * Python 3.9 build * Python 3.9 build * Python 3.9 build * Update build39.sh minor comments * Update .travis.yml Skip clipboard tests * Python 3.9 tests * Dummy commit * Use numpy master manylinux wheel * use scipy nightly wheels * Build numpy from source
…f-liboffsets-inits
…f-liboffsets-inits
…f-liboffsets-inits
…f-liboffsets-inits
return isinstance(obj, BaseOffset) | ||
|
||
@classmethod | ||
def __subclasscheck__(cls, obj) -> bool: |
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.
@simonjayhawkins is this going to mess up annotations elsewhere we annotate something as a DateOffset?
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.
mypy is a static checker, so IIUC mypy doesn't execute the code in __instancecheck__ and __subclasscheck__. Therefore, mypy has no way of knowing that BaseOffset subclass pretend to be DateOffset subclasses.
This is probably a use case for Protocol. i.e. structural typing instead of nominal typing.
Use a
__instancecheck__
override to keep isinstance checks working.This will allow us to start moving other BaseOffset subclasses up into liboffsets without having to get DateOffset (which will be one of the trickiest) first.