-
-
Notifications
You must be signed in to change notification settings - Fork 147
Type NAType
#1348
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
MarcoGorelli
wants to merge
18
commits into
pandas-dev:main
Choose a base branch
from
MarcoGorelli:natype-arithemtic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Type NAType
#1348
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d157fa1
wip
MarcoGorelli b305640
maybe fix the overloads
MarcoGorelli 1e15cb9
wip tests
MarcoGorelli 517c7d4
fixup test
MarcoGorelli c54fe63
appease mypy
MarcoGorelli 527f00f
wip
MarcoGorelli e5c8df7
fixup
MarcoGorelli 2ae0638
fixup
MarcoGorelli bc73767
remove ndarray overloads as they dont really make sense for a nullabl…
MarcoGorelli 2527f5d
fixup
MarcoGorelli 6760c3d
fixup
MarcoGorelli eef5694
Merge remote-tracking branch 'upstream/main' into natype-arithemtic
MarcoGorelli a686ae9
fixup
MarcoGorelli 08e604c
mypy fixup
MarcoGorelli a094e3e
remove `__bool__`, and comparisons (eq/ne/gt/lt/...) with `Series`/`I…
MarcoGorelli cb1da48
remove redundant annotation
MarcoGorelli 340582c
comment cases which require other fixes
MarcoGorelli 8c1eced
note pyright bug
MarcoGorelli 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 |
---|---|---|
@@ -1,46 +1,243 @@ | ||
from typing import ( | ||
Any, | ||
Callable, | ||
Literal, | ||
overload, | ||
) | ||
|
||
from pandas import ( | ||
Index, | ||
Series, | ||
) | ||
from pandas.core.arrays.boolean import BooleanArray | ||
from typing_extensions import Self | ||
|
||
class NAType: | ||
def __new__(cls, *args, **kwargs) -> Self: ... | ||
def __new__(cls, *args: Any, **kwargs: Any) -> Self: ... | ||
def __format__(self, format_spec: str) -> str: ... | ||
def __bool__(self) -> None: ... | ||
def __hash__(self) -> int: ... | ||
def __reduce__(self) -> str: ... | ||
def __add__(self, other) -> NAType: ... | ||
def __radd__(self, other) -> NAType: ... | ||
def __sub__(self, other) -> NAType: ... | ||
def __rsub__(self, other) -> NAType: ... | ||
def __mul__(self, other) -> NAType: ... | ||
def __rmul__(self, other) -> NAType: ... | ||
def __matmul__(self, other) -> NAType: ... | ||
def __rmatmul__(self, other) -> NAType: ... | ||
def __truediv__(self, other) -> NAType: ... | ||
def __rtruediv__(self, other) -> NAType: ... | ||
def __floordiv__(self, other) -> NAType: ... | ||
def __rfloordiv__(self, other) -> NAType: ... | ||
def __mod__(self, other) -> NAType: ... | ||
def __rmod__(self, other) -> NAType: ... | ||
def __divmod__(self, other) -> NAType: ... | ||
def __rdivmod__(self, other) -> NAType: ... | ||
def __eq__(self, other) -> bool: ... | ||
def __ne__(self, other) -> bool: ... | ||
def __le__(self, other) -> bool: ... | ||
def __lt__(self, other) -> bool: ... | ||
def __gt__(self, other) -> bool: ... | ||
def __ge__(self, other) -> bool: ... | ||
def __neg__(self, other) -> NAType: ... | ||
def __pos__(self, other) -> NAType: ... | ||
def __abs__(self, other) -> NAType: ... | ||
def __invert__(self, other) -> NAType: ... | ||
def __pow__(self, other) -> NAType: ... | ||
def __rpow__(self, other) -> NAType: ... | ||
def __and__(self, other) -> NAType | None: ... | ||
__rand__ = __and__ | ||
def __or__(self, other) -> bool | NAType: ... | ||
__ror__ = __or__ | ||
def __xor__(self, other) -> NAType: ... | ||
__rxor__ = __xor__ | ||
@overload | ||
def __add__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __add__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __add__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __radd__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __radd__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __radd__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __sub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __sub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __sub__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rsub__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rsub__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rsub__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __mul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __mul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __mul__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rmul__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rmul__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rmul__(self, other: object, /) -> NAType: ... | ||
def __matmul__(self, other: object, /) -> NAType: ... | ||
def __rmatmul__(self, other: object, /) -> NAType: ... | ||
Dr-Irv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def __truediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __truediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __truediv__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rtruediv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rtruediv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rtruediv__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __floordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __floordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __floordiv__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rfloordiv__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rfloordiv__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rfloordiv__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __mod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __mod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __mod__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rmod__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rmod__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __divmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> tuple[Series, Series]: ... | ||
@overload | ||
def __divmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __divmod__(self, other: object, /) -> tuple[NAType, NAType]: ... | ||
@overload | ||
def __rdivmod__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> tuple[Series, Series]: ... | ||
@overload | ||
def __rdivmod__(self, other: Index, /) -> tuple[Index, Index]: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rdivmod__(self, other: object, /) -> tuple[NAType, NAType]: ... | ||
@overload # type: ignore[override] | ||
def __eq__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __eq__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __eq__( # pyright: ignore[reportIncompatibleMethodOverride] | ||
self, other: object, / | ||
) -> NAType: ... | ||
@overload # type: ignore[override] | ||
def __ne__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __ne__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __ne__( # pyright: ignore[reportIncompatibleMethodOverride] | ||
self, other: object, / | ||
) -> NAType: ... | ||
@overload | ||
def __le__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __le__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __le__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __lt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __lt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __lt__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __gt__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __gt__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __gt__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __ge__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series[bool]: ... | ||
@overload | ||
def __ge__(self, other: Index, /) -> BooleanArray: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __ge__(self, other: object, /) -> NAType: ... | ||
def __neg__(self) -> NAType: ... | ||
def __pos__(self) -> NAType: ... | ||
def __abs__(self) -> NAType: ... | ||
def __invert__(self) -> NAType: ... | ||
@overload | ||
def __pow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __pow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __pow__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rpow__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rpow__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rpow__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __and__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
@overload | ||
def __and__(self, other: bool | NAType, /) -> NAType: ... | ||
@overload | ||
def __rand__(self, other: Literal[False], /) -> Literal[False]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
@overload | ||
def __rand__(self, other: bool, /) -> NAType: ... | ||
@overload | ||
def __or__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
@overload | ||
def __or__(self, other: bool | NAType, /) -> NAType: ... | ||
@overload | ||
def __ror__(self, other: Literal[True], /) -> Literal[True]: ... # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
@overload | ||
def __ror__(self, other: bool | NAType, /) -> NAType: ... | ||
@overload | ||
def __xor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __xor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __xor__(self, other: object, /) -> NAType: ... | ||
@overload | ||
def __rxor__( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload] | ||
self, other: Series, / | ||
) -> Series: ... | ||
@overload | ||
def __rxor__(self, other: Index, /) -> Index: ... # type: ignore[overload-overlap] | ||
@overload | ||
def __rxor__(self, other: object, /) -> NAType: ... | ||
__array_priority__: int | ||
def __array_ufunc__(self, ufunc, method, *inputs, **kwargs): ... | ||
def __array_ufunc__( | ||
self, ufunc: Callable[..., Any], method: str, *inputs: Any, **kwargs: Any | ||
) -> Any: ... | ||
|
||
NA: NAType = ... |
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.
Uh oh!
There was an error while loading. Please reload this page.