-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,8 @@ from pandas.core.indexes.multi import MultiIndex | |
from pandas.core.indexes.period import PeriodIndex | ||
from pandas.core.indexes.timedeltas import TimedeltaIndex | ||
from pandas.core.indexing import ( | ||
_AtIndexer, | ||
_iAtIndexer, | ||
_iLocIndexer, | ||
_IndexSliceTuple, | ||
_LocIndexer, | ||
|
@@ -285,6 +287,44 @@ class _LocIndexerFrame(_LocIndexer, Generic[_T]): | |
value: Scalar | NAType | NaTType | ArrayLike | Series | list | dict | None, | ||
) -> None: ... | ||
|
||
class _iAtIndexerFrame(_iAtIndexer, Generic[_T]): | ||
def __getitem__(self, idx: tuple[int, int]) -> Scalar: ... | ||
def __setitem__( | ||
self, | ||
idx: tuple[int, int], | ||
value: Scalar | NAType | NaTType | None, | ||
) -> None: ... | ||
|
||
class _AtIndexerFrame(_AtIndexer, Generic[_T]): | ||
def __getitem__( | ||
self, | ||
idx: tuple[ | ||
int | ||
| StrLike | ||
| Timestamp | ||
| tuple[Scalar, ...] | ||
| Callable[[DataFrame], ScalarT], | ||
int | StrLike | tuple[Scalar, ...], | ||
], | ||
) -> Scalar: ... | ||
def __setitem__( | ||
self, | ||
idx: ( | ||
MaskType | StrLike | _IndexSliceTuple | list[ScalarT] | IndexingInt | slice | ||
), | ||
value: ( | ||
Scalar | ||
| NAType | ||
| NaTType | ||
| ArrayLike | ||
| Series | ||
| DataFrame | ||
| list | ||
| Mapping[Hashable, Scalar | NAType | NaTType] | ||
| None | ||
), | ||
) -> None: ... | ||
|
||
# With mypy 1.14.1 and python 3.12, the second overload needs a type-ignore statement | ||
if sys.version_info >= (3, 12): | ||
class _GetItemHack: | ||
|
@@ -1591,13 +1631,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
axis: Axis = 0, | ||
skipna: _bool = True, | ||
numeric_only: _bool = False, | ||
) -> Series: ... | ||
) -> Series[int]: ... | ||
def idxmin( | ||
self, | ||
axis: Axis = 0, | ||
skipna: _bool = True, | ||
numeric_only: _bool = False, | ||
) -> Series: ... | ||
) -> Series[int]: ... | ||
def mode( | ||
self, | ||
axis: Axis = 0, | ||
|
@@ -1683,7 +1723,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
def __iter__(self) -> Iterator[Hashable]: ... | ||
# properties | ||
@property | ||
def at(self): ... # Not sure what to do with this yet; look at source | ||
def at( | ||
self, | ||
) -> _AtIndexerFrame: ... # Not sure what to do with this yet; look at source | ||
|
||
@property | ||
def columns(self) -> Index[str]: ... | ||
@columns.setter # setter needs to be right next to getter; otherwise mypy complains | ||
|
@@ -1695,7 +1737,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | |
@property | ||
def empty(self) -> _bool: ... | ||
@property | ||
def iat(self): ... # Not sure what to do with this yet; look at source | ||
def iat( | ||
self, | ||
) -> _iAtIndexerFrame: ... # Not sure what to do with this yet; look at source | ||
|
||
@property | ||
def iloc(self) -> _iLocIndexerFrame[Self]: ... | ||
@property | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
since none of the methods in either of these refer to
_T
, you can remove theGeneric
part.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.
Correct, I had duplicated the _LocIndexerFrame and was removing unused section but forgot about it.