-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: Update pyright #56892
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
TYP: Update pyright #56892
Changes from 1 commit
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 |
---|---|---|
|
@@ -132,7 +132,7 @@ repos: | |
types: [python] | ||
stages: [manual] | ||
additional_dependencies: &pyright_dependencies | ||
- [email protected].339 | ||
- [email protected].346 | ||
- id: pyright | ||
# note: assumes python env is setup and activated | ||
name: pyright reportGeneralTypeIssues | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
from typing import ( | ||
TYPE_CHECKING, | ||
ClassVar, | ||
cast, | ||
Literal, | ||
) | ||
|
||
|
@@ -637,7 +638,7 @@ def _str_map( | |
# error: Argument 1 to "dtype" has incompatible type | ||
# "Union[ExtensionDtype, str, dtype[Any], Type[object]]"; expected | ||
# "Type[object]" | ||
dtype=np.dtype(dtype), # type: ignore[arg-type] | ||
dtype=np.dtype(cast(type, dtype)), | ||
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.
|
||
) | ||
|
||
if not na_value_is_na: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9802,7 +9802,9 @@ def explode( | |
|
||
return result.__finalize__(self, method="explode") | ||
|
||
def unstack(self, level: IndexLabel = -1, fill_value=None, sort: bool = True): | ||
def unstack( | ||
self, level: IndexLabel = -1, fill_value=None, sort: bool = True | ||
) -> DataFrame | Series: | ||
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. returns a Series when a DataFrame has a non-MultiIndex index (this is also documented; a series with a non-MultiIndex raises instead). Pyright's magic was able to infer that DataFrame | Series can be returned, unfortunately, this requires quite a few ignore codes. |
||
""" | ||
Pivot a level of the (necessarily hierarchical) index labels. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,7 +491,7 @@ def copy(self, name: Hashable | None = None, deep: bool = False) -> Self: | |
new_index = self._rename(name=name) | ||
return new_index | ||
|
||
def _minmax(self, meth: str): | ||
def _minmax(self, meth: str) -> float: | ||
no_steps = len(self) - 1 | ||
if no_steps == -1: | ||
return np.nan | ||
|
@@ -500,13 +500,13 @@ def _minmax(self, meth: str): | |
|
||
return self.start + self.step * no_steps | ||
|
||
def min(self, axis=None, skipna: bool = True, *args, **kwargs) -> int: | ||
def min(self, axis=None, skipna: bool = True, *args, **kwargs) -> float: | ||
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. This is a bit sad: _minmax can return np.nan which is a float 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. Could we still annotate 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. Changed it! |
||
"""The minimum value of the RangeIndex""" | ||
nv.validate_minmax_axis(axis) | ||
nv.validate_min(args, kwargs) | ||
return self._minmax("min") | ||
|
||
def max(self, axis=None, skipna: bool = True, *args, **kwargs) -> int: | ||
def max(self, axis=None, skipna: bool = True, *args, **kwargs) -> float: | ||
"""The maximum value of the RangeIndex""" | ||
nv.validate_minmax_axis(axis) | ||
nv.validate_max(args, kwargs) | ||
|
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.
maybe_convert_objects
returns anExtensionArray
or annp.ndarray
. Most functions callmaybe_convert_objects
only whenconvert=True
and otherwise return annp.ndarray
(see the overloads).