Skip to content
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

DOC: should DateOffset always be used instead of BaseOffset? #60886

Closed
MarcoGorelli opened this issue Feb 8, 2025 · 2 comments · Fixed by #61097
Closed

DOC: should DateOffset always be used instead of BaseOffset? #60886

MarcoGorelli opened this issue Feb 8, 2025 · 2 comments · Fixed by #61097
Labels
Docs Typing type annotations, mypy/pyright type checking

Comments

@MarcoGorelli
Copy link
Member

There's currently 4 pages in the docs which mention BaseOffset:

However, BaseOffset isn't user-facing

Should they just be replaced with DateOffset?

This is also relevant for pandas-stubs which uses BaseOffset in a few places

@jbrockmendel is this ok to do?

Based on

class OffsetMeta(type):
"""
Metaclass that allows us to pretend that all BaseOffset subclasses
inherit from DateOffset (which is needed for backward-compatibility).
"""
@classmethod
def __instancecheck__(cls, obj) -> bool:
return isinstance(obj, BaseOffset)
@classmethod
def __subclasscheck__(cls, obj) -> bool:
return issubclass(obj, BaseOffset)

they should be interchangeable?

@MarcoGorelli MarcoGorelli added Docs Typing type annotations, mypy/pyright type checking labels Feb 8, 2025
@jbrockmendel
Copy link
Member

Do type checkers understand the isinstance override behavior? Using BaseOffset strikes me as less likely to cause misunderstandings.

Isn't there a namespace like pd.typing for things that aren't supposed to be used directly by users but can be used for annotation purposes? Seems like BaseOffset would be a good fit there.

@MarcoGorelli
Copy link
Member Author

sure, for type checking that's fine

but for public-facing docs, BaseOffset isn't documented, shouldn't DateOffset be used there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Typing type annotations, mypy/pyright type checking
Projects
None yet
2 participants