Skip to content

Add check assert_type to tests for frame.py and add __new__ method for DatetimeIndex #1313

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions pandas-stubs/core/indexes/datetimes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ from pandas import (
from pandas.core.indexes.accessors import DatetimeIndexProperties
from pandas.core.indexes.datetimelike import DatetimeTimedeltaMixin
from pandas.core.series import (
Series,
TimedeltaSeries,
TimestampSeries,
)
Expand Down Expand Up @@ -56,6 +57,19 @@ class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties):
copy: bool = ...,
name: Hashable = ...,
) -> None: ...
@classmethod
def __new__(
cls,
data: AxesData | Series,
freq: Frequency = ...,
tz: TimeZones = ...,
ambiguous: str = ...,
dayfirst: bool = ...,
yearfirst: bool = ...,
dtype: Dtype = ...,
copy: bool = ...,
name: Hashable = ...,
) -> Self: ...
Comment on lines +60 to +72
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just do this by making this the __init__() method, (returning None).

So in line 50, just modify data to be data: AxesData | Series

def __reduce__(self): ...
# various ignores needed for mypy, as we do want to restrict what can be used in
# arithmetic for these types
Expand Down
Loading
Loading