Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e97a56e

Browse files
Alvaro-KotheDr-Irv
andauthored
STY: ignore mypy errors (#62482)
Co-authored-by: Irv Lustig <irv@princeton.com>
1 parent 3085f9f commit e97a56e

File tree

17 files changed

+45
-43
lines changed

17 files changed

+45
-43
lines changed

‎pandas/_typing.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@
8383

8484
# numpy compatible types
8585
NumpyValueArrayLike: TypeAlias = ScalarLike_co | npt.ArrayLike
86-
# Name "npt._ArrayLikeInt_co" is not defined [name-defined]
87-
NumpySorter: TypeAlias = npt._ArrayLikeInt_co | None # type: ignore[name-defined]
86+
NumpySorter: TypeAlias = npt._ArrayLikeInt_co | None
8887

8988

9089
P = ParamSpec("P")

‎pandas/core/algorithms.py‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,15 @@ def _reconstruct_data(
215215
# that values.dtype == dtype
216216
cls = dtype.construct_array_type()
217217

218-
# error: Incompatible types in assignment (expression has type
219-
# "ExtensionArray", variable has type "ndarray[Any, Any]")
220-
values = cls._from_sequence(values, dtype=dtype) # type: ignore[assignment]
221-
222-
else:
223-
values = values.astype(dtype, copy=False)
224-
225-
return values
218+
# error: Incompatible return value type
219+
# (got "ExtensionArray",
220+
# expected "ndarray[tuple[Any, ...], dtype[Any]]")
221+
return cls._from_sequence(values, dtype=dtype) # type: ignore[return-value]
222+
223+
# error: Incompatible return value type
224+
# (got "ndarray[tuple[Any, ...], dtype[Any]]",
225+
# expected "ExtensionArray")
226+
return values.astype(dtype, copy=False) # type: ignore[return-value]
226227

227228

228229
def _ensure_arraylike(values, func_name: str) -> ArrayLike:

‎pandas/core/array_algos/quantile.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def quantile_with_mask(
102102
interpolation=interpolation,
103103
)
104104

105-
result = np.asarray(result)# type: ignore[assignment]
105+
result = np.asarray(result)
106106
result = result.T
107107

108108
return result

‎pandas/core/arrays/_mixins.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ def view(self, dtype: Dtype | None = None) -> ArrayLike:
151151

152152
td64_values = arr.view(dtype)
153153
return TimedeltaArray._simple_new(td64_values, dtype=dtype)
154-
return arr.view(dtype=dtype)
154+
# error: Argument "dtype" to "view" of "ndarray" has incompatible type
155+
# "ExtensionDtype | dtype[Any]"; expected "dtype[Any] | _HasDType[dtype[Any]]"
156+
return arr.view(dtype=dtype) # type: ignore[arg-type]
155157

156158
def take(
157159
self,

‎pandas/core/arrays/arrow/_arrow_utils.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def pyarrow_array_to_numpy_and_mask(
4444
mask = pyarrow.BooleanArray.from_buffers(
4545
pyarrow.bool_(), len(arr), [None, bitmask], offset=arr.offset
4646
)
47-
mask = np.asarray(mask)# type: ignore[assignment]
47+
mask = np.asarray(mask)
4848
else:
4949
mask = np.ones(len(arr), dtype=bool)
5050
return data, mask

‎pandas/core/arrays/arrow/array.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def _box_pa_array(
657657
):
658658
arr_value = np.asarray(value, dtype=object)
659659
# similar to isna(value) but exclude NaN, NaT, nat-like, nan-like
660-
mask = is_pdna_or_none(arr_value)# type: ignore[assignment]
660+
mask = is_pdna_or_none(arr_value)
661661

662662
try:
663663
pa_array = pa.array(value, type=pa_type, mask=mask)
@@ -2738,7 +2738,7 @@ def _str_get_dummies(self, sep: str = "|", dtype: NpDtype | None = None):
27382738
dummies_dtype = np.bool_
27392739
dummies = np.zeros(n_rows * n_cols, dtype=dummies_dtype)
27402740
dummies[indices] = True
2741-
dummies = dummies.reshape((n_rows, n_cols))# type: ignore[assignment]
2741+
dummies = dummies.reshape((n_rows, n_cols))
27422742
result = self._from_pyarrow_array(pa.array(list(dummies)))
27432743
return result, uniques_sorted.to_pylist()
27442744

‎pandas/core/arrays/categorical.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ def value_counts(self, dropna: bool = True) -> Series:
18691869
count = np.bincount(obs, minlength=ncat or 0)
18701870
else:
18711871
count = np.bincount(np.where(mask, code, ncat))
1872-
ix = np.append(ix, -1)# type: ignore[assignment]
1872+
ix = np.append(ix, -1)
18731873

18741874
ix = coerce_indexer_dtype(ix, self.dtype.categories)
18751875
ix_categorical = self._from_backing_data(ix)

‎pandas/core/arrays/datetimes.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,11 @@ def _add_offset(self, offset: BaseOffset) -> Self:
804804
try:
805805
res_values = offset._apply_array(values._ndarray)
806806
if res_values.dtype.kind == "i":
807-
res_values = res_values.view(values.dtype)
807+
# error: Argument 1 to "view" of "ndarray" has
808+
# incompatible type
809+
# "dtype[datetime64[date | int | None]] | DatetimeTZDtype";
810+
# expected "dtype[Any] | _HasDType[dtype[Any]]" [arg-type]
811+
res_values = res_values.view(values.dtype) # type: ignore[arg-type]
808812
except NotImplementedError:
809813
if get_option("performance_warnings"):
810814
warnings.warn(

‎pandas/core/arrays/string_.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
764764
result = super()._cast_pointwise_result(values)
765765
if isinstance(result.dtype, StringDtype):
766766
# Ensure we retain our same na_value/storage
767-
result = result.astype(self.dtype)# type: ignore[call-overload]
767+
result = result.astype(self.dtype)
768768
return result
769769

770770
@classmethod

‎pandas/core/groupby/groupby.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ def _apply_filter(self, indices, dropna):
18861886
mask.fill(False)
18871887
mask[indices.astype(int)] = True
18881888
# mask fails to broadcast when passed to where; broadcast manually.
1889-
mask = np.tile(mask, list(self._selected_obj.shape[1:]) + [1]).T# type: ignore[assignment]
1889+
mask = np.tile(mask, list(self._selected_obj.shape[1:]) + [1]).T
18901890
filtered = self._selected_obj.where(mask) # Fill with NaNs.
18911891
return filtered
18921892

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /