Skip to content

CI: update pyright #57481

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 1 commit into from
Feb 19, 2024
Merged
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ repos:
types: [python]
stages: [manual]
additional_dependencies: &pyright_dependencies
- [email protected].347
- [email protected].350
- id: pyright
# note: assumes python env is setup and activated
name: pyright reportGeneralTypeIssues
Expand Down
4 changes: 2 additions & 2 deletions pandas/_testing/_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
DATETIME_NO_TZ = st.datetimes()

DATETIME_JAN_1_1900_OPTIONAL_TZ = st.datetimes(
min_value=pd.Timestamp(1900, 1, 1).to_pydatetime(), # pyright: ignore[reportGeneralTypeIssues]
max_value=pd.Timestamp(1900, 1, 1).to_pydatetime(), # pyright: ignore[reportGeneralTypeIssues]
min_value=pd.Timestamp(1900, 1, 1).to_pydatetime(), # pyright: ignore[reportArgumentType]
max_value=pd.Timestamp(1900, 1, 1).to_pydatetime(), # pyright: ignore[reportArgumentType]
timezones=st.one_of(st.none(), dateutil_timezones(), pytz_timezones()),
)

Expand Down
2 changes: 1 addition & 1 deletion pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ def fixed_now_ts() -> Timestamp:
"""
Fixture emits fixed Timestamp.now()
"""
return Timestamp( # pyright: ignore[reportGeneralTypeIssues]
return Timestamp( # pyright: ignore[reportReturnType]
year=2021, month=1, day=1, hour=12, minute=4, second=13, microsecond=22
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/_numba/kernels/mean_.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def sliding_mean(
neg_ct,
compensation_add,
num_consecutive_same_value,
prev_value, # pyright: ignore[reportGeneralTypeIssues]
prev_value, # pyright: ignore[reportArgumentType]
)
else:
for j in range(start[i - 1], s):
Expand All @@ -132,7 +132,7 @@ def sliding_mean(
neg_ct,
compensation_add,
num_consecutive_same_value,
prev_value, # pyright: ignore[reportGeneralTypeIssues]
prev_value, # pyright: ignore[reportArgumentType]
)

if nobs >= min_periods and nobs > 0:
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ def __array__(self, dtype: NpDtype | None = None) -> np.ndarray:
return self._ndarray

@overload
def __getitem__(self, item: ScalarIndexer) -> DTScalarOrNaT:
def __getitem__(self, key: ScalarIndexer) -> DTScalarOrNaT:
...

@overload
def __getitem__(
self,
item: SequenceIndexer | PositionalIndexerTuple,
key: SequenceIndexer | PositionalIndexerTuple,
) -> Self:
...

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ def _memory_usage(self, deep: bool = False) -> int:
24
"""
if hasattr(self.array, "memory_usage"):
return self.array.memory_usage( # pyright: ignore[reportGeneralTypeIssues]
return self.array.memory_usage( # pyright: ignore[reportAttributeAccessIssue]
deep=deep,
)

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/computation/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def eval(
if inplace and isinstance(target, NDFrame):
target.loc[:, assigner] = ret
else:
target[assigner] = ret # pyright: ignore[reportGeneralTypeIssues]
target[assigner] = ret # pyright: ignore[reportIndexIssue]
except (TypeError, IndexError) as err:
raise ValueError("Cannot assign expression output to target") from err

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/dtypes/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def is_nested_list_like(obj: object) -> bool:
is_list_like(obj)
and hasattr(obj, "__len__")
# need PEP 724 to handle these typing errors
and len(obj) > 0 # pyright: ignore[reportGeneralTypeIssues]
and len(obj) > 0 # pyright: ignore[reportArgumentType]
and all(is_list_like(item) for item in obj) # type: ignore[attr-defined]
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ def get_data_from_filepath(
2. file-like object (e.g. open file object, StringIO)
"""
filepath_or_buffer = stringify_path(filepath_or_buffer) # type: ignore[arg-type]
with get_handle( # pyright: ignore[reportGeneralTypeIssues]
filepath_or_buffer, # pyright: ignore[reportGeneralTypeIssues]
with get_handle( # pyright: ignore[reportCallIssue]
filepath_or_buffer, # pyright: ignore[reportArgumentType]
"r",
encoding=encoding,
compression=compression,
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def decorator(decorated: F) -> F:
continue
if hasattr(docstring, "_docstring_components"):
docstring_components.extend(
docstring._docstring_components # pyright: ignore[reportGeneralTypeIssues]
docstring._docstring_components # pyright: ignore[reportAttributeAccessIssue]
)
elif isinstance(docstring, str) or docstring.__doc__:
docstring_components.append(docstring)
Expand Down
2 changes: 1 addition & 1 deletion pandas/util/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def validate_insert_loc(loc: int, length: int) -> int:
loc += length
if not 0 <= loc <= length:
raise IndexError(f"loc must be an integer between -{length} and {length}")
return loc # pyright: ignore[reportGeneralTypeIssues]
return loc # pyright: ignore[reportReturnType]


def check_dtype_backend(dtype_backend) -> None:
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -734,14 +734,22 @@ reportUntypedNamedTuple = true
reportUnusedImport = true
disableBytesTypePromotions = true
# disable subset of "basic"
reportArgumentType = false
reportAssignmentType = false
reportAttributeAccessIssue = false
reportCallIssue = false
reportGeneralTypeIssues = false
reportIndexIssue = false
reportMissingModuleSource = false
reportOperatorIssue = false
reportOptionalCall = false
reportOptionalIterable = false
reportOptionalMemberAccess = false
reportOptionalOperand = false
reportOptionalSubscript = false
reportPrivateImportUsage = false
reportRedeclaration = false
reportReturnType = false
reportUnboundVariable = false

[tool.coverage.run]
Expand Down
9 changes: 8 additions & 1 deletion pyright_reportGeneralTypeIssues.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"typeCheckingMode": "off",
"reportArgumentType": true,
"reportAssignmentType": true,
"reportAttributeAccessIssue": true,
"reportCallIssue": true,
"reportGeneralTypeIssues": true,
"reportIndexIssue": true,
"reportOperatorIssue": true,
"reportRedeclaration": true,
"reportReturnType": true,
"useLibraryCodeForTypes": false,
"analyzeUnannotatedFunctions": false,
"disableBytesTypePromotions": true,
Expand Down Expand Up @@ -63,7 +71,6 @@
"pandas/core/indexes/period.py",
"pandas/core/indexing.py",
"pandas/core/internals/api.py",
"pandas/core/internals/array_manager.py",
"pandas/core/internals/blocks.py",
"pandas/core/internals/construction.py",
"pandas/core/internals/managers.py",
Expand Down