Skip to content

Commit 34bf08c

Browse files
revert silence F821 and remove mypy error codes
1 parent 6f738a7 commit 34bf08c

35 files changed

+58
-59
lines changed

pandas/compat/pickle_compat.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class _LoadSparseSeries:
7272
# https://github.com/python/mypy/issues/1020
7373
# error: Incompatible return type for "__new__" (returns "Series", but must return
7474
# a subtype of "_LoadSparseSeries")
75-
def __new__(cls) -> "Series": # type: ignore[misc]
75+
def __new__(cls) -> "Series": # type: ignore
7676
from pandas import Series
7777

7878
warnings.warn(
@@ -90,7 +90,7 @@ class _LoadSparseFrame:
9090
# https://github.com/python/mypy/issues/1020
9191
# error: Incompatible return type for "__new__" (returns "DataFrame", but must
9292
# return a subtype of "_LoadSparseFrame")
93-
def __new__(cls) -> "DataFrame": # type: ignore[misc]
93+
def __new__(cls) -> "DataFrame": # type: ignore
9494
from pandas import DataFrame
9595

9696
warnings.warn(
@@ -202,7 +202,7 @@ def __new__(cls) -> "DataFrame": # type: ignore[misc]
202202
# functions for compat and uses a non-public class of the pickle module.
203203

204204
# error: Name 'pkl._Unpickler' is not defined
205-
class Unpickler(pkl._Unpickler): # type: ignore[name-defined]
205+
class Unpickler(pkl._Unpickler): # type: ignore
206206
def find_class(self, module, name):
207207
# override superclass
208208
key = (module, name)

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ def argsort(
16161616
# argument "ascending" [misc]
16171617
# error: "argsort" of "ExtensionArray" gets multiple values for keyword
16181618
# argument "kind" [misc]
1619-
return super().argsort( # type: ignore[misc]
1619+
return super().argsort( # type: ignore
16201620
ascending=ascending, kind=kind, *args, **kwargs
16211621
)
16221622

pandas/core/arrays/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ def mid(self):
996996
"""
997997
# https://github.com/python/mypy/issues/1362
998998
# Mypy does not support decorated properties
999-
@property # type: ignore[misc]
999+
@property # type: ignore
10001000
@Appender(
10011001
_interval_shared_docs["is_non_overlapping_monotonic"] % _shared_docs_kwargs
10021002
)

pandas/core/arrays/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def dtype(self):
329329
return self._dtype
330330

331331
# error: Read-only property cannot override read-write property [misc]
332-
@property # type: ignore[misc]
332+
@property # type: ignore
333333
def freq(self):
334334
"""
335335
Return the frequency object for this PeriodArray.

pandas/core/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ def array(self) -> ExtensionArray:
878878
# As a mixin, we depend on the mixing class having _values.
879879
# Special mixin syntax may be developed in the future:
880880
# https://github.com/python/typing/issues/246
881-
result = self._values # type: ignore[attr-defined]
881+
result = self._values # type: ignore
882882

883883
if is_datetime64_ns_dtype(result.dtype):
884884
from pandas.arrays import DatetimeArray
@@ -1007,7 +1007,7 @@ def _ndarray_values(self) -> np.ndarray:
10071007
# As a mixin, we depend on the mixing class having values.
10081008
# Special mixin syntax may be developed in the future:
10091009
# https://github.com/python/typing/issues/246
1010-
return self.values # type: ignore[attr-defined]
1010+
return self.values # type: ignore
10111011

10121012
@property
10131013
def empty(self):

pandas/core/computation/pytables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _resolve_name(self):
5151
return self.name
5252

5353
# error: Read-only property cannot override read-write property [misc]
54-
@property # type: ignore[misc]
54+
@property # type: ignore
5555
def value(self):
5656
return self._value
5757

pandas/core/config_init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def is_terminal() -> bool:
308308
"""
309309
try:
310310
# error: Name 'get_ipython' is not defined
311-
ip = get_ipython() # type: ignore[name-defined]
311+
ip = get_ipython() # type: ignore
312312
except NameError: # assume standard Python interpreter in a terminal
313313
return True
314314
else:

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ def try_datetime(v):
11111111
values, tz = conversion.datetime_to_datetime64(v)
11121112
# error: "DatetimeIndex" has no attribute "tz_localize"
11131113
return (
1114-
DatetimeIndex(values) # type: ignore[attr-defined]
1114+
DatetimeIndex(values) # type: ignore
11151115
.tz_localize("UTC")
11161116
.tz_convert(tz=tz)
11171117
)

pandas/core/dtypes/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ def ensure_int_or_float(arr: ArrayLike, copy: bool = False) -> np.array:
170170
# TODO: GH27506 potential bug with ExtensionArrays
171171
try:
172172
# error: Unexpected keyword argument "casting" for "astype"
173-
return arr.astype("int64", copy=copy, casting="safe") # type: ignore[call-arg]
173+
return arr.astype("int64", copy=copy, casting="safe") # type: ignore
174174
except TypeError:
175175
pass
176176
try:
177177
# error: Unexpected keyword argument "casting" for "astype"
178-
return arr.astype("uint64", copy=copy, casting="safe") # type: ignore[call-arg]
178+
return arr.astype("uint64", copy=copy, casting="safe") # type: ignore
179179
except TypeError:
180180
return arr.astype("float64", copy=copy)
181181

pandas/core/dtypes/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# objects
66
def create_pandas_abc_type(name, attr, comp):
77
# error: 'classmethod' used with a non-method
8-
@classmethod # type: ignore[misc]
8+
@classmethod # type: ignore
99
def _check(cls, inst):
1010
return getattr(inst, attr, "_typ") in comp
1111

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3448,7 +3448,7 @@ def extract_unique_dtypes_from_dtypes_set(
34483448
unique_dtype
34493449
for unique_dtype in unique_dtypes
34503450
if issubclass(
3451-
unique_dtype.type, tuple(dtypes_set) # type: ignore[arg-type]
3451+
unique_dtype.type, tuple(dtypes_set) # type: ignore
34523452
)
34533453
]
34543454
return extracted_dtypes

pandas/core/groupby/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ def _cython_agg_blocks(self, how, alt=None, numeric_only=True, min_count=-1):
983983
result = maybe_downcast_numeric(result, block.dtype)
984984

985985
# error: "object" has no attribute "ndim" [attr-defined]
986-
if result.ndim == 1 and isinstance( # type: ignore[attr-defined]
986+
if result.ndim == 1 and isinstance( # type: ignore
987987
result, np.ndarray
988988
):
989989
# e.g. block.values was an IntegerArray

pandas/core/groupby/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def get_func(fname):
440440
# https://github.com/python/mypy/issues/2608
441441
# error: "None" not callable
442442
def wrapper(*args, **kwargs):
443-
return f(afunc, *args, **kwargs) # type: ignore[misc]
443+
return f(afunc, *args, **kwargs) # type: ignore
444444

445445
# need to curry our sub-function
446446
func = wrapper

pandas/core/indexes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ def astype(self, dtype, copy=True):
762762
tz = pandas_dtype(dtype).tz
763763
# error: "DatetimeIndex" has no attribute "tz_localize"
764764
return (
765-
DatetimeIndex(np.asarray(self)) # type: ignore[attr-defined]
765+
DatetimeIndex(np.asarray(self)) # type: ignore
766766
.tz_localize("UTC")
767767
.tz_convert(tz)
768768
)

pandas/core/indexes/datetimelike.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ class DatetimeIndexOpsMixin(ExtensionOpsMixin, _Base):
9090
# properties there. They can be made into cache_readonly for Index
9191
# subclasses bc they are immutable
9292
inferred_freq = cache_readonly(
93-
DatetimeLikeArrayMixin.inferred_freq.fget # type: ignore[attr-defined]
93+
DatetimeLikeArrayMixin.inferred_freq.fget # type: ignore
9494
)
9595
_isnan = cache_readonly(
96-
DatetimeLikeArrayMixin._isnan.fget # type: ignore[attr-defined]
96+
DatetimeLikeArrayMixin._isnan.fget # type: ignore
9797
)
9898
hasnans = cache_readonly(
99-
DatetimeLikeArrayMixin._hasnans.fget # type: ignore[attr-defined]
99+
DatetimeLikeArrayMixin._hasnans.fget # type: ignore
100100
)
101101
_hasnans = hasnans # for index / array -agnostic code
102102
_resolution = cache_readonly(
103-
DatetimeLikeArrayMixin._resolution.fget # type: ignore[attr-defined]
103+
DatetimeLikeArrayMixin._resolution.fget # type: ignore
104104
)
105105
resolution = cache_readonly(
106-
DatetimeLikeArrayMixin.resolution.fget # type: ignore[attr-defined]
106+
DatetimeLikeArrayMixin.resolution.fget # type: ignore
107107
)
108108

109109
_maybe_mask_results = ea_passthrough(DatetimeLikeArrayMixin._maybe_mask_results)
@@ -173,7 +173,7 @@ def values(self):
173173

174174
# https://github.com/python/mypy/issues/1362
175175
# error: Decorated property not supported [misc]
176-
@property # type: ignore[misc]
176+
@property # type: ignore
177177
@Appender(DatetimeLikeArrayMixin.asi8.__doc__)
178178
def asi8(self):
179179
return self._data.asi8
@@ -234,7 +234,7 @@ def _join_i8_wrapper(joinf, dtype, with_indexers=True):
234234

235235
# https://github.com/python/mypy/issues/1006
236236
# error: 'staticmethod' used with a non-method
237-
@staticmethod # type: ignore[misc]
237+
@staticmethod # type: ignore
238238
def wrapper(left, right):
239239
if isinstance(
240240
left, (np.ndarray, ABCIndex, ABCSeries, DatetimeLikeArrayMixin)

pandas/core/indexes/datetimes.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def _maybe_utc_convert(self, other):
809809
if not timezones.tz_compare(self.tz, other.tz):
810810
this = self.tz_convert("UTC")
811811
# error: "DatetimeIndex" has no attribute "tz_convert" [attr-defined]
812-
other = other.tz_convert("UTC") # type: ignore[attr-defined]
812+
other = other.tz_convert("UTC") # type: ignore
813813
return this, other
814814

815815
def _wrap_joined_index(self, joined, other):
@@ -1163,7 +1163,7 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
11631163
mask = (self <= end_casted) & mask
11641164

11651165
# error: "bool" has no attribute "nonzero" [attr-defined]
1166-
indexer = mask.nonzero()[0][::step] # type: ignore[attr-defined]
1166+
indexer = mask.nonzero()[0][::step] # type: ignore
11671167
if len(indexer) == len(self):
11681168
return slice(None)
11691169
else:
@@ -1180,13 +1180,13 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
11801180
_is_unique = Index.is_unique
11811181

11821182
_timezone = cache_readonly(
1183-
DatetimeArray._timezone.fget # type: ignore[attr-defined]
1183+
DatetimeArray._timezone.fget # type: ignore
11841184
)
11851185
is_normalized = cache_readonly(
1186-
DatetimeArray.is_normalized.fget # type: ignore[attr-defined]
1186+
DatetimeArray.is_normalized.fget # type: ignore
11871187
)
11881188
_resolution = cache_readonly(
1189-
DatetimeArray._resolution.fget # type: ignore[attr-defined]
1189+
DatetimeArray._resolution.fget # type: ignore
11901190
)
11911191

11921192
_has_same_tz = ea_passthrough(DatetimeArray._has_same_tz)

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1751,7 +1751,7 @@ def _get_partial_string_timestamp_match_key(self, key, labels):
17511751
# https://github.com/python/mypy/issues/5492
17521752
# error: List item 0 has incompatible type "slice"; expected "str"
17531753
[key]
1754-
+ [slice(None)] # type: ignore[list-item]
1754+
+ [slice(None)] # type: ignore
17551755
* (len(labels.levels) - 1)
17561756
)
17571757

pandas/core/ops/array_ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,6 @@ def fill_bool(x, left=None):
386386
res_values = na_logical_op(lvalues, rvalues, op)
387387
# https://github.com/python/mypy/issues/5128
388388
# error: Cannot call function of unknown type
389-
res_values = filler(res_values) # type: ignore[operator]
389+
res_values = filler(res_values) # type: ignore
390390

391391
return res_values

pandas/core/resample.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ def _wrap_result(self, result):
411411
obj = self.obj
412412
if isinstance(obj.index, PeriodIndex):
413413
# error: "PeriodIndex" has no attribute "asfreq"
414-
result.index = obj.index.asfreq(self.freq) # type: ignore[attr-defined]
414+
result.index = obj.index.asfreq(self.freq) # type: ignore
415415
else:
416416
result.index = obj.index._shallow_copy(freq=self.freq)
417417
result.name = getattr(obj, "name", None)
@@ -1580,7 +1580,7 @@ def _get_period_bins(self, ax):
15801580
)
15811581

15821582
# error: "PeriodIndex" has no attribute "asfreq"
1583-
memb = ax.asfreq(self.freq, how=self.convention) # type: ignore[attr-defined]
1583+
memb = ax.asfreq(self.freq, how=self.convention) # type: ignore
15841584

15851585
# NaT handling as in pandas._lib.lib.generate_bins_dt64()
15861586
nat_count = 0
@@ -1819,7 +1819,7 @@ def asfreq(obj, freq, method=None, how=None, normalize=False, fill_value=None):
18191819

18201820
new_obj = obj.copy()
18211821
# error: "PeriodIndex" has no attribute "asfreq"
1822-
new_obj.index = obj.index.asfreq(freq, how=how) # type: ignore[attr-defined]
1822+
new_obj.index = obj.index.asfreq(freq, how=how) # type: ignore
18231823

18241824
elif len(obj.index) == 0:
18251825
new_obj = obj.copy()

pandas/core/tools/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def _convert_listlike_datetimes(
327327
if tz == "utc":
328328
# error: Item "DatetimeIndex" of "Union[DatetimeArray, DatetimeIndex]"
329329
# has no attribute "tz_convert" [union-attr]
330-
arg = arg.tz_convert(None).tz_localize(tz) # type: ignore[union-attr]
330+
arg = arg.tz_convert(None).tz_localize(tz) # type: ignore
331331
return arg
332332

333333
elif is_datetime64_ns_dtype(arg):

pandas/core/window/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, obj, *args, **kwargs):
4141
self._groupby.grouper.mutated = True
4242
# https://github.com/python/mypy/issues/5887
4343
# error: Too many arguments for "__init__" of "object"
44-
super().__init__(obj, *args, **kwargs) # type: ignore[call-arg]
44+
super().__init__(obj, *args, **kwargs) # type: ignore
4545

4646
count = GroupByMixin._dispatch("count")
4747
corr = GroupByMixin._dispatch("corr", other=None, pairwise=None)

pandas/core/window/rolling.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def _apply(
455455
def calc(x):
456456
# https://github.com/python/mypy/issues/2608
457457
# error: "str" not callable
458-
return func( # type: ignore[operator]
458+
return func( # type: ignore
459459
np.concatenate((x, additional_nans)),
460460
window,
461461
min_periods=self.min_periods,
@@ -467,7 +467,7 @@ def calc(x):
467467
def calc(x):
468468
# https://github.com/python/mypy/issues/2608
469469
# error: "str" not callable
470-
return func( # type: ignore[operator]
470+
return func( # type: ignore
471471
x, window, min_periods=self.min_periods, closed=self.closed
472472
)
473473

pandas/io/clipboard/exceptions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ class PyperclipWindowsException(PyperclipException):
99
def __init__(self, message):
1010
# error: Module has no attribute "WinError"
1111
message += " ({err})".format(
12-
err=ctypes.WinError() # type: ignore[attr-defined]
12+
err=ctypes.WinError() # type: ignore
1313
)
1414
super().__init__(message)

pandas/io/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _stringify_path(
164164
if hasattr(filepath_or_buffer, "__fspath__"):
165165
# https://github.com/python/mypy/issues/1424
166166
# error: Item "str" of "Union[str, Path, IO[str]]" has no attribute "__fspath__"
167-
return filepath_or_buffer.__fspath__() # type: ignore[union-attr]
167+
return filepath_or_buffer.__fspath__() # type: ignore
168168
elif isinstance(filepath_or_buffer, pathlib.Path):
169169
return str(filepath_or_buffer)
170170
return _expand_user(filepath_or_buffer)
@@ -527,7 +527,7 @@ def _get_handle(
527527
# definition in base class "IO" [misc]
528528
# error: Definition of "__exit__" in base class "ZipFile" is incompatible with
529529
# definition in base class "BytesIO" [misc]
530-
class BytesZipFile(zipfile.ZipFile, BytesIO): # type: ignore[misc]
530+
class BytesZipFile(zipfile.ZipFile, BytesIO): # type: ignore
531531
"""
532532
Wrapper for standard library class ZipFile and allow the returned file-like
533533
handle to accept byte strings via `write` method.

pandas/io/formats/console.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def check_main():
6666

6767
try:
6868
# error: Name '__IPYTHON__' is not defined
69-
return __IPYTHON__ or check_main() # type: ignore[name-defined] # noqa
69+
return __IPYTHON__ or check_main() # type: ignore # noqa
7070
except NameError:
7171
return check_main()
7272

@@ -77,7 +77,7 @@ def in_ipython_frontend():
7777
"""
7878
try:
7979
# error: Name 'get_ipython' is not defined
80-
ip = get_ipython() # type: ignore[name-defined] # noqa
80+
ip = get_ipython() # type: ignore # noqa
8181
return "zmq" in str(type(ip)).lower()
8282
except NameError:
8383
pass

pandas/io/formats/css.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def _error():
162162

163163
try:
164164
# error: Item "None" of "Optional[Match[Any]]" has no attribute "groups"
165-
val, unit = re.match( # type: ignore[union-attr]
165+
val, unit = re.match( # type: ignore
166166
r"^(\S*?)([a-zA-Z%!].*)", in_val
167167
).groups()
168168
except AttributeError:

pandas/io/formats/format.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ def base_formatter(v):
12911291
# "EngFormatter"
12921292
# error: "None" not callable
12931293
return (
1294-
float_format(value=v) # type: ignore[operator, call-arg, misc]
1294+
float_format(value=v) # type: ignore
12951295
if notna(v)
12961296
else self.na_rep
12971297
)
@@ -1739,7 +1739,7 @@ def just(x):
17391739
if conf_max is not None:
17401740
# https://github.com/python/mypy/issues/2608
17411741
# error: Item "None" of "Optional[TextAdjustment]" has no attribute "len"
1742-
if (conf_max > 3) & (adj.len(x) > max_len): # type: ignore[union-attr]
1742+
if (conf_max > 3) & (adj.len(x) > max_len): # type: ignore
17431743
x = x[: max_len - 3] + "..."
17441744
return x
17451745

pandas/io/formats/html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _get_columns_formatted_values(self) -> Iterable:
8686
# https://github.com/python/mypy/issues/1237
8787
# error: Signature of "is_truncated" incompatible with supertype "TableFormatter"
8888
@property
89-
def is_truncated(self) -> bool: # type: ignore[override]
89+
def is_truncated(self) -> bool: # type: ignore
9090
return self.fmt.is_truncated
9191

9292
@property

0 commit comments

Comments
 (0)