From b053965939a03150a9a4f3e05ace4bfe92e3a60b Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Sat, 13 Feb 2021 14:56:13 +0000 Subject: [PATCH] TYP: tidy comments for # type: ignore --- pandas/_testing/__init__.py | 2 +- pandas/_testing/_io.py | 8 ++- pandas/core/arrays/datetimelike.py | 13 ++--- pandas/core/arrays/interval.py | 2 +- pandas/core/arrays/string_.py | 5 +- pandas/core/base.py | 63 +++++++++--------------- pandas/core/common.py | 4 -- pandas/core/computation/expr.py | 6 +-- pandas/core/computation/ops.py | 5 +- pandas/core/computation/scope.py | 34 +++++-------- pandas/core/frame.py | 8 +-- pandas/core/generic.py | 61 ++++++++--------------- pandas/core/groupby/base.py | 20 +++----- pandas/core/groupby/grouper.py | 8 ++- pandas/core/indexes/base.py | 10 ++-- pandas/core/indexes/category.py | 3 +- pandas/core/indexes/datetimelike.py | 2 +- pandas/core/indexes/extension.py | 4 +- pandas/core/indexes/multi.py | 3 +- pandas/core/indexes/period.py | 6 +-- pandas/core/internals/blocks.py | 1 + pandas/core/resample.py | 31 +++++------- pandas/core/reshape/merge.py | 5 +- pandas/io/excel/_base.py | 4 +- pandas/io/formats/console.py | 6 +-- pandas/io/formats/excel.py | 10 ++-- pandas/io/formats/format.py | 8 ++- pandas/io/formats/style.py | 4 +- pandas/io/parsers/c_parser_wrapper.py | 30 +++++------ pandas/io/parsers/python_parser.py | 10 ++-- pandas/io/pytables.py | 4 +- pandas/plotting/_matplotlib/core.py | 21 +++----- pandas/plotting/_misc.py | 3 +- pandas/tests/internals/test_internals.py | 4 +- pandas/util/_decorators.py | 12 ++--- 35 files changed, 159 insertions(+), 261 deletions(-) diff --git a/pandas/_testing/__init__.py b/pandas/_testing/__init__.py index 0b2be53131af6..97a152d9ade1e 100644 --- a/pandas/_testing/__init__.py +++ b/pandas/_testing/__init__.py @@ -559,7 +559,7 @@ def makeCustomIndex( "p": makePeriodIndex, }.get(idx_type) if idx_func: - # pandas\_testing.py:2120: error: Cannot call function of unknown type + # error: Cannot call function of unknown type idx = idx_func(nentries) # type: ignore[operator] # but we need to fill in the name if names: diff --git a/pandas/_testing/_io.py b/pandas/_testing/_io.py index 5f27b016b68a2..8d387ff5674f7 100644 --- a/pandas/_testing/_io.py +++ b/pandas/_testing/_io.py @@ -82,9 +82,8 @@ def dec(f): is_decorating = not kwargs and len(args) == 1 and callable(args[0]) if is_decorating: f = args[0] - # pandas\_testing.py:2331: error: Incompatible types in assignment - # (expression has type "List[]", variable has type - # "Tuple[Any, ...]") + # error: Incompatible types in assignment (expression has type + # "List[]", variable has type "Tuple[Any, ...]") args = [] # type: ignore[assignment] return dec(f) else: @@ -205,8 +204,7 @@ def wrapper(*args, **kwargs): except Exception as err: errno = getattr(err, "errno", None) if not errno and hasattr(errno, "reason"): - # pandas\_testing.py:2521: error: "Exception" has no attribute - # "reason" + # error: "Exception" has no attribute "reason" errno = getattr(err.reason, "errno", None) # type: ignore[attr-defined] if errno in skip_errnos: diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 162a69370bc61..bb152ba709cbc 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -445,8 +445,7 @@ def _validate_comparison_value(self, other): raise InvalidComparison(other) if isinstance(other, self._recognized_scalars) or other is NaT: - # pandas\core\arrays\datetimelike.py:432: error: Too many arguments - # for "object" [call-arg] + # error: Too many arguments for "object" other = self._scalar_type(other) # type: ignore[call-arg] try: self._check_compatible_with(other) @@ -497,8 +496,7 @@ def _validate_shift_value(self, fill_value): if is_valid_na_for_dtype(fill_value, self.dtype): fill_value = NaT elif isinstance(fill_value, self._recognized_scalars): - # pandas\core\arrays\datetimelike.py:746: error: Too many arguments - # for "object" [call-arg] + # error: Too many arguments for "object" fill_value = self._scalar_type(fill_value) # type: ignore[call-arg] else: # only warn if we're not going to raise @@ -506,8 +504,7 @@ def _validate_shift_value(self, fill_value): # kludge for #31971 since Period(integer) tries to cast to str new_fill = Period._from_ordinal(fill_value, freq=self.freq) else: - # pandas\core\arrays\datetimelike.py:753: error: Too many - # arguments for "object" [call-arg] + # error: Too many arguments for "object" new_fill = self._scalar_type(fill_value) # type: ignore[call-arg] # stacklevel here is chosen to be correct when called from @@ -563,7 +560,7 @@ def _validate_scalar( value = NaT elif isinstance(value, self._recognized_scalars): - # error: Too many arguments for "object" [call-arg] + # error: Too many arguments for "object" value = self._scalar_type(value) # type: ignore[call-arg] else: @@ -1679,7 +1676,7 @@ def factorize(self, na_sentinel=-1, sort: bool = False): # TODO: overload __getitem__, a slice indexer returns same type as self # error: Incompatible types in assignment (expression has type # "Union[DatetimeLikeArrayMixin, Union[Any, Any]]", variable - # has type "TimelikeOps") [assignment] + # has type "TimelikeOps") uniques = uniques[::-1] # type: ignore[assignment] return codes, uniques # FIXME: shouldn't get here; we are ignoring sort diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 0f3e028c34c05..50b5528692b8e 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -1508,7 +1508,7 @@ def isin(self, values) -> np.ndarray: # GH#38353 instead of casting to object, operating on a # complex128 ndarray is much more performant. - # error: "ArrayLike" has no attribute "view" [attr-defined] + # error: "ArrayLike" has no attribute "view" left = self._combined.view("complex128") # type:ignore[attr-defined] right = values._combined.view("complex128") return np.in1d(left, right) diff --git a/pandas/core/arrays/string_.py b/pandas/core/arrays/string_.py index 65618ce32b6d7..b318757e8978a 100644 --- a/pandas/core/arrays/string_.py +++ b/pandas/core/arrays/string_.py @@ -190,9 +190,8 @@ def __init__(self, values, copy=False): values = extract_array(values) super().__init__(values, copy=copy) - # pandas\core\arrays\string_.py:188: error: Incompatible types in - # assignment (expression has type "StringDtype", variable has type - # "PandasDtype") [assignment] + # error: Incompatible types in assignment (expression has type "StringDtype", + # variable has type "PandasDtype") self._dtype = StringDtype() # type: ignore[assignment] if not isinstance(values, type(self)): self._validate() diff --git a/pandas/core/base.py b/pandas/core/base.py index da8ed8a59f981..3f3b4cd1afec1 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -95,8 +95,7 @@ def __sizeof__(self): either a value or Series of values """ if hasattr(self, "memory_usage"): - # pandas\core\base.py:84: error: "PandasObject" has no attribute - # "memory_usage" [attr-defined] + # error: "PandasObject" has no attribute "memory_usage" mem = self.memory_usage(deep=True) # type: ignore[attr-defined] return int(mem if is_scalar(mem) else mem.sum()) @@ -206,17 +205,14 @@ def _selection_list(self): @cache_readonly def _selected_obj(self): - # pandas\core\base.py:195: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" if self._selection is None or isinstance( self.obj, ABCSeries # type: ignore[attr-defined] ): - # pandas\core\base.py:194: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" return self.obj # type: ignore[attr-defined] else: - # pandas\core\base.py:204: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" return self.obj[self._selection] # type: ignore[attr-defined] @cache_readonly @@ -225,29 +221,22 @@ def ndim(self) -> int: @cache_readonly def _obj_with_exclusions(self): - # pandas\core\base.py:209: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" if self._selection is not None and isinstance( self.obj, ABCDataFrame # type: ignore[attr-defined] ): - # pandas\core\base.py:217: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" return self.obj.reindex( # type: ignore[attr-defined] columns=self._selection_list ) - # pandas\core\base.py:207: error: "SelectionMixin" has no attribute - # "exclusions" [attr-defined] + # error: "SelectionMixin" has no attribute "exclusions" if len(self.exclusions) > 0: # type: ignore[attr-defined] - # pandas\core\base.py:208: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] - - # pandas\core\base.py:208: error: "SelectionMixin" has no attribute - # "exclusions" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" + # error: "SelectionMixin" has no attribute "exclusions" return self.obj.drop(self.exclusions, axis=1) # type: ignore[attr-defined] else: - # pandas\core\base.py:210: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" return self.obj # type: ignore[attr-defined] def __getitem__(self, key): @@ -255,13 +244,11 @@ def __getitem__(self, key): raise IndexError(f"Column(s) {self._selection} already selected") if isinstance(key, (list, tuple, ABCSeries, ABCIndex, np.ndarray)): - # pandas\core\base.py:217: error: "SelectionMixin" has no attribute - # "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" if len( self.obj.columns.intersection(key) # type: ignore[attr-defined] ) != len(key): - # pandas\core\base.py:218: error: "SelectionMixin" has no - # attribute "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" bad_keys = list( set(key).difference(self.obj.columns) # type: ignore[attr-defined] ) @@ -269,13 +256,13 @@ def __getitem__(self, key): return self._gotitem(list(key), ndim=2) elif not getattr(self, "as_index", False): - # error: "SelectionMixin" has no attribute "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" if key not in self.obj.columns: # type: ignore[attr-defined] raise KeyError(f"Column not found: {key}") return self._gotitem(key, ndim=2) else: - # error: "SelectionMixin" has no attribute "obj" [attr-defined] + # error: "SelectionMixin" has no attribute "obj" if key not in self.obj: # type: ignore[attr-defined] raise KeyError(f"Column not found: {key}") return self._gotitem(key, ndim=1) @@ -601,8 +588,7 @@ def to_numpy( dtype='datetime64[ns]') """ if is_extension_array_dtype(self.dtype): - # pandas\core\base.py:837: error: Too many arguments for "to_numpy" - # of "ExtensionArray" [call-arg] + # error: Too many arguments for "to_numpy" of "ExtensionArray" return self.array.to_numpy( # type: ignore[call-arg] dtype, copy=copy, na_value=na_value, **kwargs ) @@ -914,13 +900,11 @@ def _map_values(self, mapper, na_action=None): # use the built in categorical series mapper which saves # time by mapping the categories instead of all values - # pandas\core\base.py:893: error: Incompatible types in - # assignment (expression has type "Categorical", variable has - # type "IndexOpsMixin") [assignment] + # error: Incompatible types in assignment (expression has type + # "Categorical", variable has type "IndexOpsMixin") self = cast("Categorical", self) # type: ignore[assignment] - # pandas\core\base.py:894: error: Item "ExtensionArray" of - # "Union[ExtensionArray, Any]" has no attribute "map" - # [union-attr] + # error: Item "ExtensionArray" of "Union[ExtensionArray, Any]" has no + # attribute "map" return self._values.map(mapper) # type: ignore[union-attr] values = self._values @@ -938,8 +922,7 @@ def _map_values(self, mapper, na_action=None): raise NotImplementedError map_f = lambda values, f: values.map(f) else: - # pandas\core\base.py:1142: error: "IndexOpsMixin" has no attribute - # "astype" [attr-defined] + # error: "IndexOpsMixin" has no attribute "astype" values = self.astype(object)._values # type: ignore[attr-defined] if na_action == "ignore": map_f = lambda values, f: lib.map_infer_mask( @@ -1177,8 +1160,7 @@ def memory_usage(self, deep=False): are not components of the array if deep=False or if used on PyPy """ if hasattr(self.array, "memory_usage"): - # pandas\core\base.py:1379: error: "ExtensionArray" has no - # attribute "memory_usage" [attr-defined] + # error: "ExtensionArray" has no attribute "memory_usage" return self.array.memory_usage(deep=deep) # type: ignore[attr-defined] v = self.array.nbytes @@ -1313,8 +1295,7 @@ def searchsorted(self, value, side="left", sorter=None) -> np.ndarray: def drop_duplicates(self, keep="first"): duplicated = self.duplicated(keep=keep) - # pandas\core\base.py:1507: error: Value of type "IndexOpsMixin" is not - # indexable [index] + # error: Value of type "IndexOpsMixin" is not indexable return self[~duplicated] # type: ignore[index] def duplicated(self, keep="first"): diff --git a/pandas/core/common.py b/pandas/core/common.py index aa24e12bf2cf1..89ba33da92661 100644 --- a/pandas/core/common.py +++ b/pandas/core/common.py @@ -268,10 +268,6 @@ def maybe_iterable_to_list(obj: Union[Iterable[T], T]) -> Union[Collection[T], T """ if isinstance(obj, abc.Iterable) and not isinstance(obj, abc.Sized): return list(obj) - # error: Incompatible return value type (got - # "Union[pandas.core.common., - # pandas.core.common.1, T]", expected - # "Union[Collection[T], T]") [return-value] obj = cast(Collection, obj) return obj diff --git a/pandas/core/computation/expr.py b/pandas/core/computation/expr.py index babf8116a5588..ee91ab4a282cf 100644 --- a/pandas/core/computation/expr.py +++ b/pandas/core/computation/expr.py @@ -659,8 +659,7 @@ def visit_Call(self, node, side=None, **kwargs): raise if res is None: - # pandas\core\computation\expr.py:663: error: "expr" has no - # attribute "id" [attr-defined] + # error: "expr" has no attribute "id" raise ValueError( f"Invalid function call {node.func.id}" # type: ignore[attr-defined] ) @@ -684,8 +683,7 @@ def visit_Call(self, node, side=None, **kwargs): for key in node.keywords: if not isinstance(key, ast.keyword): - # pandas\core\computation\expr.py:684: error: "expr" has no - # attribute "id" [attr-defined] + # error: "expr" has no attribute "id" raise ValueError( "keyword error in function call " # type: ignore[attr-defined] f"'{node.func.id}'" diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index 7b42b21cadc1f..e8eae710623c5 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -71,8 +71,7 @@ def __init__(self, name: str, is_local: Optional[bool] = None): class Term: def __new__(cls, name, env, side=None, encoding=None): klass = Constant if not isinstance(name, str) else cls - # pandas\core\computation\ops.py:72: error: Argument 2 for "super" not - # an instance of argument 1 [misc] + # error: Argument 2 for "super" not an instance of argument 1 supr_new = super(Term, klass).__new__ # type: ignore[misc] return supr_new(klass) @@ -593,7 +592,7 @@ def __init__(self, func, args): self.func = func def __call__(self, env): - # pandas\core\computation\ops.py:592: error: "Op" not callable [operator] + # error: "Op" not callable operands = [op(env) for op in self.operands] # type: ignore[operator] with np.errstate(all="ignore"): return self.func.func(*operands) diff --git a/pandas/core/computation/scope.py b/pandas/core/computation/scope.py index c2ba7f9892ef0..71d725051977f 100644 --- a/pandas/core/computation/scope.py +++ b/pandas/core/computation/scope.py @@ -131,17 +131,14 @@ def __init__( # scope when we align terms (alignment accesses the underlying # numpy array of pandas objects) - # pandas\core\computation\scope.py:132: error: Incompatible types - # in assignment (expression has type "ChainMap[str, Any]", variable - # has type "DeepChainMap[str, Any]") [assignment] + # error: Incompatible types in assignment (expression has type + # "ChainMap[str, Any]", variable has type "DeepChainMap[str, Any]") self.scope = self.scope.new_child( # type: ignore[assignment] (global_dict or frame.f_globals).copy() ) if not isinstance(local_dict, Scope): - # pandas\core\computation\scope.py:134: error: Incompatible - # types in assignment (expression has type "ChainMap[str, - # Any]", variable has type "DeepChainMap[str, Any]") - # [assignment] + # error: Incompatible types in assignment (expression has type + # "ChainMap[str, Any]", variable has type "DeepChainMap[str, Any]") self.scope = self.scope.new_child( # type: ignore[assignment] (local_dict or frame.f_locals).copy() ) @@ -150,8 +147,7 @@ def __init__( # assumes that resolvers are going from outermost scope to inner if isinstance(local_dict, Scope): - # pandas\core\computation\scope.py:140: error: Cannot determine - # type of 'resolvers' [has-type] + # error: Cannot determine type of 'resolvers' resolvers += tuple(local_dict.resolvers.maps) # type: ignore[has-type] self.resolvers = DeepChainMap(*resolvers) self.temps = {} @@ -239,8 +235,7 @@ def swapkey(self, old_key: str, new_key: str, new_value=None): for mapping in maps: if old_key in mapping: - # pandas\core\computation\scope.py:228: error: Unsupported - # target for indexed assignment ("Mapping[Any, Any]") [index] + # error: Unsupported target for indexed assignment ("Mapping[Any, Any]") mapping[new_key] = new_value # type: ignore[index] return @@ -260,10 +255,8 @@ def _get_vars(self, stack, scopes: List[str]): for scope, (frame, _, _, _, _, _) in variables: try: d = getattr(frame, "f_" + scope) - # pandas\core\computation\scope.py:247: error: Incompatible - # types in assignment (expression has type "ChainMap[str, - # Any]", variable has type "DeepChainMap[str, Any]") - # [assignment] + # error: Incompatible types in assignment (expression has type + # "ChainMap[str, Any]", variable has type "DeepChainMap[str, Any]") self.scope = self.scope.new_child(d) # type: ignore[assignment] finally: # won't remove it, but DECREF it @@ -331,13 +324,10 @@ def full_scope(self): vars : DeepChainMap All variables in this scope. """ - # pandas\core\computation\scope.py:314: error: Unsupported operand - # types for + ("List[Dict[Any, Any]]" and "List[Mapping[Any, Any]]") - # [operator] - - # pandas\core\computation\scope.py:314: error: Unsupported operand - # types for + ("List[Dict[Any, Any]]" and "List[Mapping[str, Any]]") - # [operator] + # error: Unsupported operand types for + ("List[Dict[Any, Any]]" and + # "List[Mapping[Any, Any]]") + # error: Unsupported operand types for + ("List[Dict[Any, Any]]" and + # "List[Mapping[str, Any]]") maps = ( [self.temps] + self.resolvers.maps # type: ignore[operator] diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 63d238da12101..f6db5d40c8409 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1163,8 +1163,8 @@ def __len__(self) -> int: """ return len(self.index) - # pandas/core/frame.py:1146: error: Overloaded function signatures 1 and 2 - # overlap with incompatible return types [misc] + # error: Overloaded function signatures 1 and 2 overlap with incompatible return + # types @overload def dot(self, other: Series) -> Series: # type: ignore[misc] ... @@ -4822,8 +4822,8 @@ def set_index( elif isinstance(col, (Index, Series)): # if Index then not MultiIndex (treated above) - # error: Argument 1 to "append" of "list" has incompatible - # type "Union[Index, Series]"; expected "Index" [arg-type] + # error: Argument 1 to "append" of "list" has incompatible type + # "Union[Index, Series]"; expected "Index" arrays.append(col) # type:ignore[arg-type] names.append(col.name) elif isinstance(col, (list, np.ndarray)): diff --git a/pandas/core/generic.py b/pandas/core/generic.py index ec37da66760c3..6413489a74ae6 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10530,8 +10530,7 @@ def _add_numeric_operations(cls): def any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs): return NDFrame.any(self, axis, bool_only, skipna, level, **kwargs) - # pandas\core\generic.py:10725: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.any = any # type: ignore[assignment] @doc( @@ -10547,13 +10546,11 @@ def any(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs): def all(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs): return NDFrame.all(self, axis, bool_only, skipna, level, **kwargs) - # pandas\core\generic.py:10719: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method - # pandas\core\generic.py:10719: error: Incompatible types in assignment - # (expression has type "Callable[[Iterable[object]], bool]", variable - # has type "Callable[[NDFrame, Any, Any, Any, Any, KwArg(Any)], Any]") - # [assignment] + # error: Incompatible types in assignment (expression has type + # "Callable[[Iterable[object]], bool]", variable has type "Callable[[NDFrame, + # Any, Any, Any, Any, KwArg(Any)], Any]") cls.all = all # type: ignore[assignment] # error: Argument 1 to "doc" has incompatible type "Optional[str]"; expected @@ -10571,8 +10568,7 @@ def all(self, axis=0, bool_only=None, skipna=True, level=None, **kwargs): def mad(self, axis=None, skipna=None, level=None): return NDFrame.mad(self, axis, skipna, level) - # pandas\core\generic.py:10736: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.mad = mad # type: ignore[assignment] @doc( @@ -10595,8 +10591,7 @@ def sem( ): return NDFrame.sem(self, axis, skipna, level, ddof, numeric_only, **kwargs) - # pandas\core\generic.py:10758: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.sem = sem # type: ignore[assignment] @doc( @@ -10618,8 +10613,7 @@ def var( ): return NDFrame.var(self, axis, skipna, level, ddof, numeric_only, **kwargs) - # pandas\core\generic.py:10779: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.var = var # type: ignore[assignment] @doc( @@ -10642,8 +10636,7 @@ def std( ): return NDFrame.std(self, axis, skipna, level, ddof, numeric_only, **kwargs) - # pandas\core\generic.py:10801: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.std = std # type: ignore[assignment] @doc( @@ -10658,8 +10651,7 @@ def std( def cummin(self, axis=None, skipna=True, *args, **kwargs): return NDFrame.cummin(self, axis, skipna, *args, **kwargs) - # pandas\core\generic.py:10815: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.cummin = cummin # type: ignore[assignment] @doc( @@ -10674,8 +10666,7 @@ def cummin(self, axis=None, skipna=True, *args, **kwargs): def cummax(self, axis=None, skipna=True, *args, **kwargs): return NDFrame.cummax(self, axis, skipna, *args, **kwargs) - # pandas\core\generic.py:10829: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.cummax = cummax # type: ignore[assignment] @doc( @@ -10690,8 +10681,7 @@ def cummax(self, axis=None, skipna=True, *args, **kwargs): def cumsum(self, axis=None, skipna=True, *args, **kwargs): return NDFrame.cumsum(self, axis, skipna, *args, **kwargs) - # pandas\core\generic.py:10843: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.cumsum = cumsum # type: ignore[assignment] @doc( @@ -10706,8 +10696,7 @@ def cumsum(self, axis=None, skipna=True, *args, **kwargs): def cumprod(self, axis=None, skipna=True, *args, **kwargs): return NDFrame.cumprod(self, axis, skipna, *args, **kwargs) - # pandas\core\generic.py:10857: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.cumprod = cumprod # type: ignore[assignment] @doc( @@ -10734,8 +10723,7 @@ def sum( self, axis, skipna, level, numeric_only, min_count, **kwargs ) - # pandas\core\generic.py:10883: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.sum = sum # type: ignore[assignment] @doc( @@ -10761,8 +10749,7 @@ def prod( self, axis, skipna, level, numeric_only, min_count, **kwargs ) - # pandas\core\generic.py:10908: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.prod = prod # type: ignore[assignment] cls.product = prod @@ -10779,8 +10766,7 @@ def prod( def mean(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): return NDFrame.mean(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:10924: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.mean = mean # type: ignore[assignment] @doc( @@ -10796,8 +10782,7 @@ def mean(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): def skew(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): return NDFrame.skew(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:10939: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.skew = skew # type: ignore[assignment] @doc( @@ -10816,8 +10801,7 @@ def skew(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): def kurt(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): return NDFrame.kurt(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:10957: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.kurt = kurt # type: ignore[assignment] cls.kurtosis = kurt @@ -10836,8 +10820,7 @@ def median( ): return NDFrame.median(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:10975: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.median = median # type: ignore[assignment] @doc( @@ -10855,8 +10838,7 @@ def median( def max(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): return NDFrame.max(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:10992: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.max = max # type: ignore[assignment] @doc( @@ -10874,8 +10856,7 @@ def max(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): def min(self, axis=None, skipna=None, level=None, numeric_only=None, **kwargs): return NDFrame.min(self, axis, skipna, level, numeric_only, **kwargs) - # pandas\core\generic.py:11009: error: Cannot assign to a method - # [assignment] + # error: Cannot assign to a method cls.min = min # type: ignore[assignment] @final diff --git a/pandas/core/groupby/base.py b/pandas/core/groupby/base.py index 594c5899209df..9f1446b359f66 100644 --- a/pandas/core/groupby/base.py +++ b/pandas/core/groupby/base.py @@ -57,8 +57,7 @@ def _gotitem(self, key, ndim, subset=None): """ # create a new object to prevent aliasing if subset is None: - # pandas\core\groupby\base.py:52: error: "GotItemMixin" has no - # attribute "obj" [attr-defined] + # error: "GotItemMixin" has no attribute "obj" subset = self.obj # type: ignore[attr-defined] # we need to make a shallow copy of ourselves @@ -70,22 +69,15 @@ def _gotitem(self, key, ndim, subset=None): # Try to select from a DataFrame, falling back to a Series try: - # pandas\core\groupby\base.py:60: error: "GotItemMixin" has no - # attribute "_groupby" [attr-defined] + # error: "GotItemMixin" has no attribute "_groupby" groupby = self._groupby[key] # type: ignore[attr-defined] except IndexError: - # pandas\core\groupby\base.py:62: error: "GotItemMixin" has no - # attribute "_groupby" [attr-defined] + # error: "GotItemMixin" has no attribute "_groupby" groupby = self._groupby # type: ignore[attr-defined] - # pandas\core\groupby\base.py:64: error: Too many arguments for - # "GotItemMixin" [call-arg] - - # pandas\core\groupby\base.py:64: error: Unexpected keyword argument - # "groupby" for "GotItemMixin" [call-arg] - - # pandas\core\groupby\base.py:64: error: Unexpected keyword argument - # "parent" for "GotItemMixin" [call-arg] + # error: Too many arguments for "GotItemMixin" + # error: Unexpected keyword argument "groupby" for "GotItemMixin" + # error: Unexpected keyword argument "parent" for "GotItemMixin" self = type(self)( subset, groupby=groupby, parent=self, **kwargs # type: ignore[call-arg] ) diff --git a/pandas/core/groupby/grouper.py b/pandas/core/groupby/grouper.py index c7dc6d021a4c3..6a789bc26cabc 100644 --- a/pandas/core/groupby/grouper.py +++ b/pandas/core/groupby/grouper.py @@ -281,9 +281,8 @@ def _get_grouper(self, obj, validate: bool = True): a tuple of binner, grouper, obj (possibly sorted) """ self._set_grouper(obj) - # pandas\core\groupby\grouper.py:310: error: Value of type variable - # "FrameOrSeries" of "get_grouper" cannot be "Optional[Any]" - # [type-var] + # error: Value of type variable "FrameOrSeries" of "get_grouper" cannot be + # "Optional[Any]" self.grouper, _, self.obj = get_grouper( # type: ignore[type-var] self.obj, [self.key], @@ -370,8 +369,7 @@ def _set_grouper(self, obj: FrameOrSeries, sort: bool = False): @final @property def groups(self): - # pandas\core\groupby\grouper.py:382: error: Item "None" of - # "Optional[Any]" has no attribute "groups" [union-attr] + # error: Item "None" of "Optional[Any]" has no attribute "groups" return self.grouper.groups # type: ignore[union-attr] @final diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 789ca04b894cd..f12a4fd382e7a 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -6071,14 +6071,14 @@ def ensure_index( if hasattr(index_like, "name"): # https://github.com/python/mypy/issues/1424 # error: Item "ExtensionArray" of "Union[ExtensionArray, - # Sequence[Any]]" has no attribute "name" [union-attr] + # Sequence[Any]]" has no attribute "name" # error: Item "Sequence[Any]" of "Union[ExtensionArray, Sequence[Any]]" - # has no attribute "name" [union-attr] - # error: "Sequence[Any]" has no attribute "name" [attr-defined] + # has no attribute "name" + # error: "Sequence[Any]" has no attribute "name" # error: Item "Sequence[Any]" of "Union[Series, Sequence[Any]]" has no - # attribute "name" [union-attr] + # attribute "name" # error: Item "Sequence[Any]" of "Union[Any, Sequence[Any]]" has no - # attribute "name" [union-attr] + # attribute "name" name = index_like.name # type: ignore[union-attr, attr-defined] return Index(index_like, name=name, copy=copy) diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 265170dd28a3b..7e6d7d911b065 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -318,8 +318,7 @@ def _format_attrs(self): "categories", ibase.default_pprint(self.categories, max_seq_items=max_categories), ), - # pandas\core\indexes\category.py:315: error: "CategoricalIndex" - # has no attribute "ordered" [attr-defined] + # error: "CategoricalIndex" has no attribute "ordered" ("ordered", self.ordered), # type: ignore[attr-defined] ] if self.name is not None: diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 00f47c0aaf538..2e6519a3b73ad 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -714,7 +714,7 @@ def _intersection(self, other: Index, sort=False) -> Index: left_chunk = left._values[lslice] # error: Argument 1 to "_simple_new" of "DatetimeIndexOpsMixin" has # incompatible type "Union[ExtensionArray, Any]"; expected - # "Union[DatetimeArray, TimedeltaArray, PeriodArray]" [arg-type] + # "Union[DatetimeArray, TimedeltaArray, PeriodArray]" result = type(self)._simple_new(left_chunk) # type: ignore[arg-type] return self._wrap_setop_result(other, result) diff --git a/pandas/core/indexes/extension.py b/pandas/core/indexes/extension.py index ea3678a7e15d9..a0e783a74df3c 100644 --- a/pandas/core/indexes/extension.py +++ b/pandas/core/indexes/extension.py @@ -226,8 +226,8 @@ def __getitem__(self, key): if result.ndim == 1: return type(self)(result, name=self.name) # Unpack to ndarray for MPL compat - # pandas\core\indexes\extension.py:220: error: "ExtensionArray" has - # no attribute "_data" [attr-defined] + + # error: "ExtensionArray" has no attribute "_data" result = result._data # type: ignore[attr-defined] # Includes cases where we get a 2D ndarray back for MPL compat diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 26d59db1b08fd..1fdffcf8e5980 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1448,8 +1448,7 @@ def _set_names(self, names, level=None, validate=True): raise TypeError( f"{type(self).__name__}.name must be a hashable type" ) - # pandas\core\indexes\multi.py:1448: error: Cannot determine type - # of '__setitem__' [has-type] + # error: Cannot determine type of '__setitem__' self._names[lev] = name # type: ignore[has-type] # If .levels has been accessed, the names in our cache will be stale. diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a9561cc477d4a..9664f41362c8a 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -166,21 +166,21 @@ def to_timestamp(self, freq=None, how="start") -> DatetimeIndex: return DatetimeIndex._simple_new(arr, name=self.name) # https://github.com/python/mypy/issues/1362 - # error: Decorated property not supported [misc] + # error: Decorated property not supported @property # type:ignore[misc] @doc(PeriodArray.hour.fget) def hour(self) -> Int64Index: return Int64Index(self._data.hour, name=self.name) # https://github.com/python/mypy/issues/1362 - # error: Decorated property not supported [misc] + # error: Decorated property not supported @property # type:ignore[misc] @doc(PeriodArray.minute.fget) def minute(self) -> Int64Index: return Int64Index(self._data.minute, name=self.name) # https://github.com/python/mypy/issues/1362 - # error: Decorated property not supported [misc] + # error: Decorated property not supported @property # type:ignore[misc] @doc(PeriodArray.second.fget) def second(self) -> Int64Index: diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 8ba6018e743bb..3c27e34dcbcf6 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2475,6 +2475,7 @@ def _block_shape(values: ArrayLike, ndim: int = 1) -> ArrayLike: # TODO(EA2D): https://github.com/pandas-dev/pandas/issues/23023 # block.shape is incorrect for "2D" ExtensionArrays # We can't, and don't need to, reshape. + # error: "ExtensionArray" has no attribute "reshape" values = values.reshape(tuple((1,) + shape)) # type: ignore[attr-defined] return values diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 68f791ac0a837..767dd312bb7df 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -96,9 +96,8 @@ def __init__(self, obj, groupby=None, axis=0, kind=None, **kwargs): self.as_index = True self.exclusions = set() self.binner = None - # pandas\core\resample.py:96: error: Incompatible types in assignment - # (expression has type "None", variable has type "BaseGrouper") - # [assignment] + # error: Incompatible types in assignment (expression has type "None", variable + # has type "BaseGrouper") self.grouper = None # type: ignore[assignment] if self.groupby is not None: @@ -419,8 +418,7 @@ def _apply_loffset(self, result): result : Series or DataFrame the result of resample """ - # pandas\core\resample.py:409: error: Cannot determine type of - # 'loffset' [has-type] + # error: Cannot determine type of 'loffset' needs_offset = ( isinstance( self.loffset, # type: ignore[has-type] @@ -431,8 +429,7 @@ def _apply_loffset(self, result): ) if needs_offset: - # pandas\core\resample.py:415: error: Cannot determine type of - # 'loffset' [has-type] + # error: Cannot determine type of 'loffset' result.index = result.index + self.loffset # type: ignore[has-type] self.loffset = None @@ -869,8 +866,7 @@ def std(self, ddof=1, *args, **kwargs): Standard deviation of values within each group. """ nv.validate_resampler_func("std", args, kwargs) - # pandas\core\resample.py:850: error: Unexpected keyword argument - # "ddof" for "_downsample" [call-arg] + # error: Unexpected keyword argument "ddof" for "_downsample" return self._downsample("std", ddof=ddof) # type: ignore[call-arg] def var(self, ddof=1, *args, **kwargs): @@ -888,8 +884,7 @@ def var(self, ddof=1, *args, **kwargs): Variance of values within each group. """ nv.validate_resampler_func("var", args, kwargs) - # pandas\core\resample.py:867: error: Unexpected keyword argument - # "ddof" for "_downsample" [call-arg] + # error: Unexpected keyword argument "ddof" for "_downsample" return self._downsample("var", ddof=ddof) # type: ignore[call-arg] @doc(GroupBy.size) @@ -948,11 +943,8 @@ def quantile(self, q=0.5, **kwargs): Return a DataFrame, where the coulmns are groupby columns, and the values are its quantiles. """ - # pandas\core\resample.py:920: error: Unexpected keyword argument "q" - # for "_downsample" [call-arg] - - # pandas\core\resample.py:920: error: Too many arguments for - # "_downsample" [call-arg] + # error: Unexpected keyword argument "q" for "_downsample" + # error: Too many arguments for "_downsample" return self._downsample("quantile", q=q, **kwargs) # type: ignore[call-arg] @@ -1005,8 +997,7 @@ def __init__(self, obj, *args, **kwargs): for attr in self._attributes: setattr(self, attr, kwargs.get(attr, getattr(parent, attr))) - # pandas\core\resample.py:972: error: Too many arguments for "__init__" - # of "object" [call-arg] + # error: Too many arguments for "__init__" of "object" super().__init__(None) # type: ignore[call-arg] self._groupby = groupby self._groupby.mutated = True @@ -1070,8 +1061,8 @@ def _downsample(self, how, **kwargs): return obj # do we have a regular frequency - # pandas\core\resample.py:1037: error: "BaseGrouper" has no - # attribute "binlabels" [attr-defined] + + # error: "BaseGrouper" has no attribute "binlabels" if ( (ax.freq is not None or ax.inferred_freq is not None) and len(self.grouper.binlabels) > len(ax) # type: ignore[attr-defined] diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 8704d757c3289..963d071dc2768 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -996,9 +996,8 @@ def _get_merge_keys(self): """ left_keys = [] right_keys = [] - # pandas\core\reshape\merge.py:966: error: Need type annotation for - # 'join_names' (hint: "join_names: List[] = ...") - # [var-annotated] + # error: Need type annotation for 'join_names' (hint: "join_names: List[] + # = ...") join_names = [] # type: ignore[var-annotated] right_drop = [] left_drop = [] diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index f12a530ea6c34..8902d45144c56 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -893,8 +893,8 @@ def check_extension(cls, ext: str): """ if ext.startswith("."): ext = ext[1:] - # error: "Callable[[ExcelWriter], Any]" has no attribute "__iter__" - # (not iterable) [attr-defined] + # error: "Callable[[ExcelWriter], Any]" has no attribute "__iter__" (not + # iterable) if not any( ext in extension for extension in cls.supported_extensions # type: ignore[attr-defined] diff --git a/pandas/io/formats/console.py b/pandas/io/formats/console.py index ea291bcbfa44c..bdd2b3d6e4c6a 100644 --- a/pandas/io/formats/console.py +++ b/pandas/io/formats/console.py @@ -69,8 +69,7 @@ def check_main(): return not hasattr(main, "__file__") or get_option("mode.sim_interactive") try: - # pandas\io\formats\console.py:72: error: Name '__IPYTHON__' is not - # defined [name-defined] + # error: Name '__IPYTHON__' is not defined return __IPYTHON__ or check_main() # type: ignore[name-defined] except NameError: return check_main() @@ -85,8 +84,7 @@ def in_ipython_frontend(): bool """ try: - # pandas\io\formats\console.py:86: error: Name 'get_ipython' is not - # defined [name-defined] + # error: Name 'get_ipython' is not defined ip = get_ipython() # type: ignore[name-defined] return "zmq" in str(type(ip)).lower() except NameError: diff --git a/pandas/io/formats/excel.py b/pandas/io/formats/excel.py index b027d8139f24b..13126c2fa7b06 100644 --- a/pandas/io/formats/excel.py +++ b/pandas/io/formats/excel.py @@ -613,9 +613,8 @@ def _format_header(self) -> Iterable[ExcelCell]: "" ] * len(self.columns) if reduce(lambda x, y: x and y, map(lambda x: x != "", row)): - # pandas\io\formats\excel.py:618: error: Incompatible types in - # assignment (expression has type "Generator[ExcelCell, None, - # None]", variable has type "Tuple[]") [assignment] + # error: Incompatible types in assignment (expression has type + # "Generator[ExcelCell, None, None]", variable has type "Tuple[]") gen2 = ( # type: ignore[assignment] ExcelCell(self.rowcounter, colindex, val, self.header_style) for colindex, val in enumerate(row) @@ -819,9 +818,8 @@ def write( if isinstance(writer, ExcelWriter): need_save = False else: - # pandas\io\formats\excel.py:808: error: Cannot instantiate - # abstract class 'ExcelWriter' with abstract attributes 'engine', - # 'save', 'supported_extensions' and 'write_cells' [abstract] + # error: Cannot instantiate abstract class 'ExcelWriter' with abstract + # attributes 'engine', 'save', 'supported_extensions' and 'write_cells' writer = ExcelWriter( # type: ignore[abstract] writer, engine=engine, storage_options=storage_options ) diff --git a/pandas/io/formats/format.py b/pandas/io/formats/format.py index 05d94366e6623..48b2fae8c6de5 100644 --- a/pandas/io/formats/format.py +++ b/pandas/io/formats/format.py @@ -1347,11 +1347,9 @@ def _value_formatter( def base_formatter(v): assert float_format is not None # for mypy - # pandas\io\formats\format.py:1411: error: "str" not callable - # [operator] - - # pandas\io\formats\format.py:1411: error: Unexpected keyword - # argument "value" for "__call__" of "EngFormatter" [call-arg] + # error: "str" not callable + # error: Unexpected keyword argument "value" for "__call__" of + # "EngFormatter" return ( float_format(value=v) # type: ignore[operator,call-arg] if notna(v) diff --git a/pandas/io/formats/style.py b/pandas/io/formats/style.py index 735fb345363c7..22e21761fa303 100644 --- a/pandas/io/formats/style.py +++ b/pandas/io/formats/style.py @@ -1740,8 +1740,8 @@ def from_custom_template(cls, searchpath, name): loader = jinja2.ChoiceLoader([jinja2.FileSystemLoader(searchpath), cls.loader]) # mypy doesn't like dynamically-defined classes - # error: Variable "cls" is not valid as a type [valid-type] - # error: Invalid base class "cls" [misc] + # error: Variable "cls" is not valid as a type + # error: Invalid base class "cls" class MyStyler(cls): # type:ignore[valid-type,misc] env = jinja2.Environment(loader=loader) template = env.get_template(name) diff --git a/pandas/io/parsers/c_parser_wrapper.py b/pandas/io/parsers/c_parser_wrapper.py index d1d77c5e044be..27f06dc84a275 100644 --- a/pandas/io/parsers/c_parser_wrapper.py +++ b/pandas/io/parsers/c_parser_wrapper.py @@ -25,29 +25,23 @@ def __init__(self, src: FilePathOrBuffer, **kwds): for key in ("storage_options", "encoding", "memory_map", "compression"): kwds.pop(key, None) if self.handles.is_mmap and hasattr(self.handles.handle, "mmap"): - # pandas\io\parsers.py:1861: error: Item "IO[Any]" of - # "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, - # TextIOWrapper, mmap]" has no attribute "mmap" [union-attr] + # error: Item "IO[Any]" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" - # pandas\io\parsers.py:1861: error: Item "RawIOBase" of - # "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, - # TextIOWrapper, mmap]" has no attribute "mmap" [union-attr] + # error: Item "RawIOBase" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" - # pandas\io\parsers.py:1861: error: Item "BufferedIOBase" of - # "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, - # TextIOWrapper, mmap]" has no attribute "mmap" [union-attr] + # error: Item "BufferedIOBase" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" - # pandas\io\parsers.py:1861: error: Item "TextIOBase" of - # "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, - # TextIOWrapper, mmap]" has no attribute "mmap" [union-attr] + # error: Item "TextIOBase" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" - # pandas\io\parsers.py:1861: error: Item "TextIOWrapper" of - # "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, - # TextIOWrapper, mmap]" has no attribute "mmap" [union-attr] + # error: Item "TextIOWrapper" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" - # pandas\io\parsers.py:1861: error: Item "mmap" of "Union[IO[Any], - # RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap]" has - # no attribute "mmap" [union-attr] + # error: Item "mmap" of "Union[IO[Any], RawIOBase, BufferedIOBase, + # TextIOBase, TextIOWrapper, mmap]" has no attribute "mmap" self.handles.handle = self.handles.handle.mmap # type: ignore[union-attr] try: diff --git a/pandas/io/parsers/python_parser.py b/pandas/io/parsers/python_parser.py index 223acdea80ca6..cfd648636753d 100644 --- a/pandas/io/parsers/python_parser.py +++ b/pandas/io/parsers/python_parser.py @@ -217,10 +217,9 @@ def _read(): reader = _read() - # pandas\io\parsers.py:2427: error: Incompatible types in assignment - # (expression has type "_reader", variable has type "Union[IO[Any], - # RawIOBase, BufferedIOBase, TextIOBase, TextIOWrapper, mmap, None]") - # [assignment] + # error: Incompatible types in assignment (expression has type "_reader", + # variable has type "Union[IO[Any], RawIOBase, BufferedIOBase, TextIOBase, + # TextIOWrapper, mmap, None]") self.data = reader # type: ignore[assignment] def read(self, rows=None): @@ -278,8 +277,7 @@ def _exclude_implicit_index(self, alldata): # legacy def get_chunk(self, size=None): if size is None: - # pandas\io\parsers.py:2528: error: "PythonParser" has no attribute - # "chunksize" [attr-defined] + # error: "PythonParser" has no attribute "chunksize" size = self.chunksize # type: ignore[attr-defined] return self.read(rows=size) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 8917be1f558b2..077686d9bd642 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -3410,8 +3410,8 @@ def queryables(self) -> Dict[str, Any]: (v.cname, v) for v in self.values_axes if v.name in set(self.data_columns) ] - # error: Unsupported operand types for + ("List[Tuple[str, IndexCol]]" - # and "List[Tuple[str, None]]") + # error: Unsupported operand types for + ("List[Tuple[str, IndexCol]]" and + # "List[Tuple[str, None]]") return dict(d1 + d2 + d3) # type: ignore[operator] def index_cols(self): diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 7d743075674f1..2b6dd5347c3e7 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -594,17 +594,14 @@ def _make_legend(self): if self.legend: if self.legend == "reverse": - # pandas\plotting\_matplotlib\core.py:578: error: - # Incompatible types in assignment (expression has type + # error: Incompatible types in assignment (expression has type # "Iterator[Any]", variable has type "List[Any]") - # [assignment] self.legend_handles = reversed( # type: ignore[assignment] self.legend_handles ) - # pandas\plotting\_matplotlib\core.py:579: error: - # Incompatible types in assignment (expression has type + # error: Incompatible types in assignment (expression has type # "Iterator[Optional[Hashable]]", variable has type - # "List[Optional[Hashable]]") [assignment] + # "List[Optional[Hashable]]") self.legend_labels = reversed( # type: ignore[assignment] self.legend_labels ) @@ -1149,10 +1146,9 @@ def _make_plot(self): it = self._iter_data(data=data, keep_index=True) else: x = self._get_xticks(convert_period=True) - # pandas\plotting\_matplotlib\core.py:1100: error: Incompatible - # types in assignment (expression has type "Callable[[Any, Any, - # Any, Any, Any, Any, KwArg(Any)], Any]", variable has type - # "Callable[[Any, Any, Any, Any, KwArg(Any)], Any]") [assignment] + # error: Incompatible types in assignment (expression has type + # "Callable[[Any, Any, Any, Any, Any, Any, KwArg(Any)], Any]", variable has + # type "Callable[[Any, Any, Any, Any, KwArg(Any)], Any]") plotf = self._plot # type: ignore[assignment] it = self._iter_data() @@ -1601,9 +1597,8 @@ def blank_labeler(label, value): if labels is not None: blabels = [blank_labeler(left, value) for left, value in zip(labels, y)] else: - # pandas\plotting\_matplotlib\core.py:1546: error: Incompatible - # types in assignment (expression has type "None", variable has - # type "List[Any]") [assignment] + # error: Incompatible types in assignment (expression has type "None", + # variable has type "List[Any]") blabels = None # type: ignore[assignment] results = ax.pie(y, labels=blabels, **kwds) diff --git a/pandas/plotting/_misc.py b/pandas/plotting/_misc.py index 58f44104b99d6..e0a860b9d8709 100644 --- a/pandas/plotting/_misc.py +++ b/pandas/plotting/_misc.py @@ -530,8 +530,7 @@ def reset(self): ------- None """ - # pandas\plotting\_misc.py:533: error: Cannot access "__init__" - # directly [misc] + # error: Cannot access "__init__" directly self.__init__() # type: ignore[misc] def _get_canonical_key(self, key): diff --git a/pandas/tests/internals/test_internals.py b/pandas/tests/internals/test_internals.py index 0a50ef2831534..3203b7fa1893d 100644 --- a/pandas/tests/internals/test_internals.py +++ b/pandas/tests/internals/test_internals.py @@ -1233,8 +1233,8 @@ def check_frame_setitem(self, elem, index: Index, inplace: bool): if inplace: # assertion here implies setting was done inplace - # error: Item "ArrayManager" of "Union[ArrayManager, BlockManager]" - # has no attribute "blocks" [union-attr] + # error: Item "ArrayManager" of "Union[ArrayManager, BlockManager]" has no + # attribute "blocks" assert df._mgr.blocks[0].values is arr # type:ignore[union-attr] else: assert df.dtypes[0] == object diff --git a/pandas/util/_decorators.py b/pandas/util/_decorators.py index a13fb1ce57f6c..268c636ab9353 100644 --- a/pandas/util/_decorators.py +++ b/pandas/util/_decorators.py @@ -78,8 +78,8 @@ def wrapper(*args, **kwargs) -> Callable[..., Any]: {dedent(doc)}""" ) - # error: Incompatible return value type (got "Callable[[VarArg(Any), - # KwArg(Any)], Callable[...,Any]]", expected "Callable[[F], F]") + # error: Incompatible return value type (got "Callable[[VarArg(Any), KwArg(Any)], + # Callable[...,Any]]", expected "Callable[[F], F]") return wrapper # type: ignore[return-value] @@ -362,10 +362,10 @@ def decorator(decorated: F) -> F: for docstring in docstrings: if hasattr(docstring, "_docstring_components"): - # error: Item "str" of "Union[str, Callable[..., Any]]" has no - # attribute "_docstring_components" [union-attr] - # error: Item "function" of "Union[str, Callable[..., Any]]" - # has no attribute "_docstring_components" [union-attr] + # error: Item "str" of "Union[str, Callable[..., Any]]" has no attribute + # "_docstring_components" + # error: Item "function" of "Union[str, Callable[..., Any]]" has no + # attribute "_docstring_components" docstring_components.extend( docstring._docstring_components # type: ignore[union-attr] )