-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: Implicit generic "Any" for builtins #30541
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
Changes from 12 commits
72bf101
1f70371
f70bbc5
e22ac17
673e14e
2ba544d
f40eb8c
6c820ec
a08e76c
2f5fd60
7fc12ec
41afe57
7d0d865
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,29 @@ | |
from pandas.core.indexes.base import Index # noqa: F401 | ||
from pandas.core.series import Series # noqa: F401 | ||
from pandas.core.generic import NDFrame # noqa: F401 | ||
from pandas import Interval # noqa: F401 | ||
|
||
# array-like | ||
|
||
AnyArrayLike = TypeVar("AnyArrayLike", "ExtensionArray", "Index", "Series", np.ndarray) | ||
ArrayLike = TypeVar("ArrayLike", "ExtensionArray", np.ndarray) | ||
|
||
# scalars | ||
|
||
PythonScalar = Union[str, int, float, bool] | ||
DatetimeLikeScalar = TypeVar("DatetimeLikeScalar", "Period", "Timestamp", "Timedelta") | ||
PandasScalar = Union[DatetimeLikeScalar, "Interval"] | ||
Scalar = Union[PythonScalar, PandasScalar] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it matter that this is a Union of a Union and a TypeVar? Maybe DatetimeLikeScalar should just be a Union? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we have the same issue as with FilePathOrBuffer, where IO is unbound in the Union and requires the addition of type parameters when using the alias. and we don't really want that for Scalar. but we had Scalar as a union (for JSONSerializable) and DatetimeLikeScalar as a TypeVar.
rather than change this, maybe should define There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea makes sense |
||
|
||
# other | ||
|
||
Dtype = Union[str, np.dtype, "ExtensionDtype"] | ||
FilePathOrBuffer = Union[str, Path, IO[AnyStr]] | ||
|
||
FrameOrSeries = TypeVar("FrameOrSeries", bound="NDFrame") | ||
Scalar = Union[str, int, float, bool] | ||
Axis = Union[str, int] | ||
Ordered = Optional[bool] | ||
JSONSerializable = Union[Scalar, List, Dict] | ||
|
||
JSONSerializable = Union[PythonScalar, List, Dict] | ||
Axes = Collection | ||
|
||
# to maintain type information across generic functions and parametrization | ||
_T = TypeVar("_T") | ||
T = TypeVar("T") |
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.
would move DatetimeLikeScalar closer to these (also would add some comments about various sections, e.g. these are Scalars )