From 3bd44257ce6cfde88542993178620db7798ed3f9 Mon Sep 17 00:00:00 2001 From: DL Lim Date: Sat, 9 Nov 2024 11:04:20 +0000 Subject: [PATCH 01/18] Update mypy version from 1.11.2 to 1.13.0 --- environment.yml | 2 +- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 5ef5fbe910427..9bf6cf2a92347 100644 --- a/environment.yml +++ b/environment.yml @@ -77,7 +77,7 @@ dependencies: # code checks - flake8=7.1.0 # run in subprocess over docstring examples - - mypy=1.11.2 # pre-commit uses locally installed mypy + - mypy=1.13.0 # pre-commit uses locally installed mypy - tokenize-rt # scripts/check_for_inconsistent_pandas_namespace.py - pre-commit>=4.0.1 diff --git a/requirements-dev.txt b/requirements-dev.txt index 00e320e6370ce..69568cf661241 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -54,7 +54,7 @@ moto flask asv>=0.6.1 flake8==7.1.0 -mypy==1.11.2 +mypy==1.13.0 tokenize-rt pre-commit>=4.0.1 gitpython From 301242402c932584beb510a9f5e61cfd2484bf1a Mon Sep 17 00:00:00 2001 From: Nikolay Vasilev Date: Sat, 9 Nov 2024 12:36:10 +0000 Subject: [PATCH 02/18] Removed type ignores --- pandas/core/computation/ops.py | 3 +-- pandas/core/missing.py | 8 +------- pandas/io/common.py | 4 +--- pandas/plotting/_matplotlib/boxplot.py | 5 +---- pandas/plotting/_matplotlib/hist.py | 5 +---- 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index a1a5f77f8539e..9b26de42e119b 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -76,8 +76,7 @@ class Term: def __new__(cls, name, env, side=None, encoding=None): klass = Constant if not isinstance(name, str) else cls - # error: Argument 2 for "super" not an instance of argument 1 - supr_new = super(Term, klass).__new__ # type: ignore[misc] + supr_new = super(Term, klass).__new__ return supr_new(klass) is_local: bool diff --git a/pandas/core/missing.py b/pandas/core/missing.py index 039d868bccd16..4170f35922198 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -413,13 +413,7 @@ def func(yvalues: np.ndarray) -> None: **kwargs, ) - # error: Argument 1 to "apply_along_axis" has incompatible type - # "Callable[[ndarray[Any, Any]], None]"; expected "Callable[..., - # Union[_SupportsArray[dtype[]], Sequence[_SupportsArray - # [dtype[]]], Sequence[Sequence[_SupportsArray[dtype[]]]], - # Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]], - # Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[]]]]]]]]" - np.apply_along_axis(func, axis, data) # type: ignore[arg-type] + np.apply_along_axis(func, axis, data) def _index_to_interp_indices(index: Index, method: str) -> np.ndarray: diff --git a/pandas/io/common.py b/pandas/io/common.py index a76f0cf6dd34d..78fcdf8ff14b4 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -910,10 +910,8 @@ def get_handle( or not hasattr(handle, "seekable") ): handle = _IOWrapper(handle) - # error: Argument 1 to "TextIOWrapper" has incompatible type - # "_IOWrapper"; expected "IO[bytes]" handle = TextIOWrapper( - handle, # type: ignore[arg-type] + handle, encoding=ioargs.encoding, errors=errors, newline="", diff --git a/pandas/plotting/_matplotlib/boxplot.py b/pandas/plotting/_matplotlib/boxplot.py index 6bb10068bee38..68682344f98ca 100644 --- a/pandas/plotting/_matplotlib/boxplot.py +++ b/pandas/plotting/_matplotlib/boxplot.py @@ -198,10 +198,7 @@ def _make_plot(self, fig: Figure) -> None: else self.data ) - # error: Argument "data" to "_iter_data" of "MPLPlot" has - # incompatible type "object"; expected "DataFrame | - # dict[Hashable, Series | DataFrame]" - for i, (label, y) in enumerate(self._iter_data(data=data)): # type: ignore[arg-type] + for i, (label, y) in enumerate(self._iter_data(data=data)): ax = self._get_ax(i) kwds = self.kwds.copy() diff --git a/pandas/plotting/_matplotlib/hist.py b/pandas/plotting/_matplotlib/hist.py index 97e510982ab93..1a423ad49c294 100644 --- a/pandas/plotting/_matplotlib/hist.py +++ b/pandas/plotting/_matplotlib/hist.py @@ -137,10 +137,7 @@ def _make_plot(self, fig: Figure) -> None: if self.by is not None else self.data ) - - # error: Argument "data" to "_iter_data" of "MPLPlot" has incompatible - # type "object"; expected "DataFrame | dict[Hashable, Series | DataFrame]" - for i, (label, y) in enumerate(self._iter_data(data=data)): # type: ignore[arg-type] + for i, (label, y) in enumerate(self._iter_data(data=data)): ax = self._get_ax(i) kwds = self.kwds.copy() From bafc3fa0561f523a224c5b3b4aaa6de679b1da32 Mon Sep 17 00:00:00 2001 From: Ofsouzap Date: Sat, 9 Nov 2024 12:37:30 +0000 Subject: [PATCH 03/18] Correct typing error --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 35014674565ff..d77f973f124b1 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8024,7 +8024,7 @@ def asof(self, where, subset=None): np.nan, index=self.columns, name=where[0] ) - locs = self.index.asof_locs(where, ~(nulls._values)) + locs = self.index.asof_locs(where, ~cast("DataFrame", nulls._values)) # mask the missing mask = locs == -1 From e72632a153bc8ba3b756f3fb945c0c3a417e7a9b Mon Sep 17 00:00:00 2001 From: Nikolay Vasilev Date: Sat, 9 Nov 2024 13:25:01 +0000 Subject: [PATCH 04/18] Removed a missed type ignore --- pandas/core/indexes/interval.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index b0b9c5419e2ad..13811c28e6c1e 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -558,8 +558,7 @@ def _maybe_convert_i8(self, key): left = self._maybe_convert_i8(key.left) right = self._maybe_convert_i8(key.right) constructor = Interval if scalar else IntervalIndex.from_arrays - # error: "object" not callable - return constructor(left, right, closed=self.closed) # type: ignore[operator] + return constructor(left, right, closed=self.closed) if scalar: # Timestamp/Timedelta From f6b30d3ac3c6e6e6afb588448d95915264816c24 Mon Sep 17 00:00:00 2001 From: Ofsouzap Date: Sat, 9 Nov 2024 13:54:53 +0000 Subject: [PATCH 05/18] nanops typing fix --- pandas/core/nanops.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index e775156a6ae2f..1c35eacf55c03 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -726,7 +726,7 @@ def nanmean( @bottleneck_switch() -def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=None): +def nanmedian(values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None) -> float | np.ndarray: """ Parameters ---------- @@ -738,7 +738,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask= Returns ------- - result : float + result : float | ndarray Unless input is a float array, in which case use the same precision as the input array. @@ -758,7 +758,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask= # cases we never need to set NaN to the masked values using_nan_sentinel = values.dtype.kind == "f" and mask is None - def get_median(x, _mask=None): + def get_median(x: np.ndarray, _mask=None): if _mask is None: _mask = notna(x) else: @@ -794,6 +794,8 @@ def get_median(x, _mask=None): notempty = values.size + res: float | np.ndarray + # an array from a frame if values.ndim > 1 and axis is not None: # there's a non-empty array to apply over otherwise numpy raises From 03b51af2e7580fafe6ccc2d22fe1cfa0693a1a12 Mon Sep 17 00:00:00 2001 From: Ofsouzap Date: Sat, 9 Nov 2024 14:20:04 +0000 Subject: [PATCH 06/18] Fix indexing typing error --- pandas/core/indexing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 08bd3cde60806..cbbfa208b33f9 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -914,7 +914,7 @@ def __setitem__(self, key, value) -> None: indexer = self._get_setitem_indexer(key) self._has_valid_setitem_indexer(key) - iloc = self if self.name == "iloc" else self.obj.iloc + iloc: _iLocIndexer = cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc iloc._setitem_with_indexer(indexer, value, self.name) def _validate_key(self, key, axis: AxisInt) -> None: From 3c75b7f6912e62d468fa9f3f0f0a40123db19711 Mon Sep 17 00:00:00 2001 From: pyfra Date: Sat, 9 Nov 2024 14:37:26 +0000 Subject: [PATCH 07/18] added type ignore to _core.py --- pandas/plotting/_core.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index b60392368d944..7a2796281cf5b 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1038,7 +1038,9 @@ def __call__(self, *args, **kwargs): label_name = label_kw or y data.name = label_name else: - match = is_list_like(label_kw) and len(label_kw) == len(y) + # error: Argument 1 to "len" has incompatible type "Any | bool"; + # expected "Sized" [arg-type] + match = is_list_like(label_kw) and len(label_kw) == len(y) # type: ignore[arg-type] if label_kw and not match: raise ValueError( "label should be list-like and same length as y" From a36a34e5198ec090d7c680bdb71ca1edb636814f Mon Sep 17 00:00:00 2001 From: YasithDSL Date: Sat, 9 Nov 2024 14:59:25 +0000 Subject: [PATCH 08/18] add type ignore to column types --- pandas/tests/io/test_sql.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index c28a33069d23f..dcadd02a0caa2 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -237,14 +237,17 @@ def types_table_metadata(dialect: str): "types", metadata, Column("TextCol", TEXT), - Column("DateCol", date_type), + # error: Cannot infer type argument 1 of "Column" + Column("DateCol", date_type), # type: ignore[misc] Column("IntDateCol", Integer), Column("IntDateOnlyCol", Integer), Column("FloatCol", Float), Column("IntCol", Integer), - Column("BoolCol", bool_type), - Column("IntColWithNull", Integer), - Column("BoolColWithNull", bool_type), + # error: Cannot infer type argument 1 of "Column" + Column("BoolCol", bool_type), # type: ignore[misc] + Column("IntColWithNull", Integer), + # error: Cannot infer type argument 1 of "Column" + Column("BoolColWithNull", bool_type), # type: ignore[misc] ) return types From 2190f91ea03ab91027a1f8c9e65417483fbf53b6 Mon Sep 17 00:00:00 2001 From: pyfra Date: Sat, 9 Nov 2024 15:21:00 +0000 Subject: [PATCH 09/18] added type ignore in _get_common_dtype in dtypes.py --- pandas/core/dtypes/dtypes.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 004a1aab5436e..ac46580a8cf30 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -2130,9 +2130,11 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None: PerformanceWarning, stacklevel=find_stack_level(), ) - np_dtypes = (x.subtype if isinstance(x, SparseDtype) else x for x in dtypes) - return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) + # error: Argument 1 to "np_find_common_type" has incompatible type + # "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]"; + # expected "dtype[Any]" [arg-type] + return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type] @register_extension_dtype From 5e2f18b9d24a7394431ac89d293fad7b6b3a8a08 Mon Sep 17 00:00:00 2001 From: Larry Date: Sat, 9 Nov 2024 16:20:47 +0000 Subject: [PATCH 10/18] type ignore common.py --- pandas/io/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index 78fcdf8ff14b4..c91e698accd7c 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -910,12 +910,13 @@ def get_handle( or not hasattr(handle, "seekable") ): handle = _IOWrapper(handle) + # error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer" [type-var] handle = TextIOWrapper( handle, encoding=ioargs.encoding, errors=errors, newline="", - ) + ) # type: ignore[arg-type] handles.append(handle) # only marked as wrapped when the caller provided a handle is_wrapped = not ( From 1a4cd4084019a0ac2efb8c1a9ddbf278b80d0d65 Mon Sep 17 00:00:00 2001 From: YasithDSL Date: Sat, 9 Nov 2024 16:36:39 +0000 Subject: [PATCH 11/18] Add type ignore for call-overload --- pandas/core/missing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index 4170f35922198..da444aa5e997f 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -412,8 +412,10 @@ def func(yvalues: np.ndarray) -> None: mask=mask, **kwargs, ) - - np.apply_along_axis(func, axis, data) + # error: No overload variant of "apply_along_axis" matches + # argument types "Callable[[ndarray[Any, Any]], None]", + # "int", "ndarray[Any, Any]" + np.apply_along_axis(func, axis, data) # type: ignore[call-overload] def _index_to_interp_indices(index: Index, method: str) -> np.ndarray: From 12aa2c8d85c74e6efd043fd10c3f254a06820e3e Mon Sep 17 00:00:00 2001 From: DL Lim Date: Sat, 9 Nov 2024 16:37:07 +0000 Subject: [PATCH 12/18] pre-commit --- pandas/core/dtypes/dtypes.py | 6 +++--- pandas/core/indexing.py | 4 +++- pandas/core/nanops.py | 4 +++- pandas/io/common.py | 2 +- pandas/plotting/_core.py | 4 ++-- pandas/tests/io/test_sql.py | 8 ++++---- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index ac46580a8cf30..96b0aa16940a6 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -2131,10 +2131,10 @@ def _get_common_dtype(self, dtypes: list[DtypeObj]) -> DtypeObj | None: stacklevel=find_stack_level(), ) np_dtypes = (x.subtype if isinstance(x, SparseDtype) else x for x in dtypes) - # error: Argument 1 to "np_find_common_type" has incompatible type - # "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]"; + # error: Argument 1 to "np_find_common_type" has incompatible type + # "*Generator[Any | dtype[Any] | ExtensionDtype, None, None]"; # expected "dtype[Any]" [arg-type] - return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type] + return SparseDtype(np_find_common_type(*np_dtypes), fill_value=fill_value) # type: ignore [arg-type] @register_extension_dtype diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index cbbfa208b33f9..975e7ad135ba7 100644 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -914,7 +914,9 @@ def __setitem__(self, key, value) -> None: indexer = self._get_setitem_indexer(key) self._has_valid_setitem_indexer(key) - iloc: _iLocIndexer = cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc + iloc: _iLocIndexer = ( + cast("_iLocIndexer", self) if self.name == "iloc" else self.obj.iloc + ) iloc._setitem_with_indexer(indexer, value, self.name) def _validate_key(self, key, axis: AxisInt) -> None: diff --git a/pandas/core/nanops.py b/pandas/core/nanops.py index 1c35eacf55c03..d6154e2352c63 100644 --- a/pandas/core/nanops.py +++ b/pandas/core/nanops.py @@ -726,7 +726,9 @@ def nanmean( @bottleneck_switch() -def nanmedian(values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None) -> float | np.ndarray: +def nanmedian( + values: np.ndarray, *, axis: AxisInt | None = None, skipna: bool = True, mask=None +) -> float | np.ndarray: """ Parameters ---------- diff --git a/pandas/io/common.py b/pandas/io/common.py index c91e698accd7c..1f89afae19f89 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -916,7 +916,7 @@ def get_handle( encoding=ioargs.encoding, errors=errors, newline="", - ) # type: ignore[arg-type] + ) # type: ignore[arg-type] handles.append(handle) # only marked as wrapped when the caller provided a handle is_wrapped = not ( diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 7a2796281cf5b..3fbd4c6f6e26a 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1038,9 +1038,9 @@ def __call__(self, *args, **kwargs): label_name = label_kw or y data.name = label_name else: - # error: Argument 1 to "len" has incompatible type "Any | bool"; + # error: Argument 1 to "len" has incompatible type "Any | bool"; # expected "Sized" [arg-type] - match = is_list_like(label_kw) and len(label_kw) == len(y) # type: ignore[arg-type] + match = is_list_like(label_kw) and len(label_kw) == len(y) # type: ignore[arg-type] if label_kw and not match: raise ValueError( "label should be list-like and same length as y" diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index dcadd02a0caa2..beca8dea9407d 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -238,16 +238,16 @@ def types_table_metadata(dialect: str): metadata, Column("TextCol", TEXT), # error: Cannot infer type argument 1 of "Column" - Column("DateCol", date_type), # type: ignore[misc] + Column("DateCol", date_type), # type: ignore[misc] Column("IntDateCol", Integer), Column("IntDateOnlyCol", Integer), Column("FloatCol", Float), Column("IntCol", Integer), # error: Cannot infer type argument 1 of "Column" - Column("BoolCol", bool_type), # type: ignore[misc] - Column("IntColWithNull", Integer), + Column("BoolCol", bool_type), # type: ignore[misc] + Column("IntColWithNull", Integer), # error: Cannot infer type argument 1 of "Column" - Column("BoolColWithNull", bool_type), # type: ignore[misc] + Column("BoolColWithNull", bool_type), # type: ignore[misc] ) return types From c1d7a57454101101383ce7031ebca6b2a2a5ba02 Mon Sep 17 00:00:00 2001 From: Larry Date: Sat, 9 Nov 2024 16:41:07 +0000 Subject: [PATCH 13/18] fix line too long --- pandas/io/common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index c91e698accd7c..ceac59c850e94 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -910,7 +910,8 @@ def get_handle( or not hasattr(handle, "seekable") ): handle = _IOWrapper(handle) - # error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer" [type-var] + # error: Value of type variable "_BufferT_co" of + # "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer" [type-var] handle = TextIOWrapper( handle, encoding=ioargs.encoding, From 1ef6691c5bb111a06b05a1b37693afab2aefb188 Mon Sep 17 00:00:00 2001 From: DL Lim Date: Sat, 9 Nov 2024 17:00:33 +0000 Subject: [PATCH 14/18] pre-commit --- pandas/io/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index bc6380fc59275..b4d35c159b1a1 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -910,7 +910,7 @@ def get_handle( or not hasattr(handle, "seekable") ): handle = _IOWrapper(handle) - # error: Value of type variable "_BufferT_co" of + # error: Value of type variable "_BufferT_co" of # "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer" [type-var] handle = TextIOWrapper( handle, From f77a81b3d8ed1c9706cc9b85491552f27f87f5c9 Mon Sep 17 00:00:00 2001 From: YasithDSL Date: Sat, 9 Nov 2024 17:03:10 +0000 Subject: [PATCH 15/18] Remove unused ignore --- pandas/core/missing.py | 9 +++++---- pandas/io/common.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pandas/core/missing.py b/pandas/core/missing.py index da444aa5e997f..ff2daae002731 100644 --- a/pandas/core/missing.py +++ b/pandas/core/missing.py @@ -412,10 +412,11 @@ def func(yvalues: np.ndarray) -> None: mask=mask, **kwargs, ) - # error: No overload variant of "apply_along_axis" matches - # argument types "Callable[[ndarray[Any, Any]], None]", - # "int", "ndarray[Any, Any]" - np.apply_along_axis(func, axis, data) # type: ignore[call-overload] + + # error: No overload variant of "apply_along_axis" matches + # argument types "Callable[[ndarray[Any, Any]], None]", + # "int", "ndarray[Any, Any]" + np.apply_along_axis(func, axis, data) # type: ignore[call-overload] def _index_to_interp_indices(index: Index, method: str) -> np.ndarray: diff --git a/pandas/io/common.py b/pandas/io/common.py index de70ed91c7dd4..8da3ca0218983 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -917,7 +917,7 @@ def get_handle( encoding=ioargs.encoding, errors=errors, newline="", - ) # type: ignore[arg-type] + ) handles.append(handle) # only marked as wrapped when the caller provided a handle is_wrapped = not ( From 2a8019b0c93a276794ae0f01d8f1562441a5dda8 Mon Sep 17 00:00:00 2001 From: Nikolay Vasilev Date: Sat, 9 Nov 2024 17:24:49 +0000 Subject: [PATCH 16/18] Fixed type:ignore from type-arg to type-var --- pandas/io/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/io/common.py b/pandas/io/common.py index b4d35c159b1a1..de70ed91c7dd4 100644 --- a/pandas/io/common.py +++ b/pandas/io/common.py @@ -910,10 +910,10 @@ def get_handle( or not hasattr(handle, "seekable") ): handle = _IOWrapper(handle) - # error: Value of type variable "_BufferT_co" of - # "TextIOWrapper" cannot be "_IOWrapper | BaseBuffer" [type-var] + # error: Value of type variable "_BufferT_co" of "TextIOWrapper" cannot + # be "_IOWrapper | BaseBuffer" [type-var] handle = TextIOWrapper( - handle, + handle, # type: ignore[type-var] encoding=ioargs.encoding, errors=errors, newline="", From a6a6dbf142d85b1619cfd4f5980c57c83c42b8b1 Mon Sep 17 00:00:00 2001 From: Ofsouzap Date: Sat, 9 Nov 2024 19:18:37 +0000 Subject: [PATCH 17/18] Correct typing fix --- pandas/core/generic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d77f973f124b1..d8c48b62dd0fb 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8024,7 +8024,8 @@ def asof(self, where, subset=None): np.nan, index=self.columns, name=where[0] ) - locs = self.index.asof_locs(where, ~cast("DataFrame", nulls._values)) + # error: Unsupported operand type for ~ ("ExtensionArray | ndarray[Any, Any] | Any") + locs = self.index.asof_locs(where, ~nulls._values) # type: ignore[operator] # mask the missing mask = locs == -1 From 4f838b60ad9f117ca6a25fa73d41c6417d93f6b5 Mon Sep 17 00:00:00 2001 From: Ofsouzap Date: Sat, 9 Nov 2024 19:33:50 +0000 Subject: [PATCH 18/18] Formatting fixes --- pandas/core/generic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index d8c48b62dd0fb..7c2cc5d33a5db 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -8024,7 +8024,8 @@ def asof(self, where, subset=None): np.nan, index=self.columns, name=where[0] ) - # error: Unsupported operand type for ~ ("ExtensionArray | ndarray[Any, Any] | Any") + # error: Unsupported operand type for + # ~ ("ExtensionArray | ndarray[Any, Any] | Any") locs = self.index.asof_locs(where, ~nulls._values) # type: ignore[operator] # mask the missing