From 918b138b46cd2d14fb95bc7034b56dacbf5e8d4c Mon Sep 17 00:00:00 2001 From: Ekaterina Kuzkina Date: Tue, 8 Mar 2022 22:12:14 +0000 Subject: [PATCH 1/3] TYP: annotation of __init__ return type (PEP 484) --- pandas/tests/base/test_constructors.py | 2 +- pandas/tests/dtypes/test_inference.py | 6 +++--- pandas/tests/extension/arrow/arrays.py | 4 ++-- pandas/tests/extension/arrow/test_timestamp.py | 2 +- pandas/tests/extension/decimal/array.py | 4 ++-- pandas/tests/extension/json/array.py | 2 +- pandas/tests/extension/list/array.py | 2 +- pandas/tests/extension/test_common.py | 2 +- pandas/tests/extension/test_extension.py | 2 +- pandas/tests/frame/constructors/test_from_records.py | 2 +- pandas/tests/frame/methods/test_select_dtypes.py | 4 ++-- pandas/tests/frame/methods/test_set_index.py | 4 ++-- pandas/tests/frame/methods/test_to_records.py | 2 +- pandas/tests/frame/test_arithmetic.py | 2 +- pandas/tests/frame/test_constructors.py | 2 +- pandas/tests/frame/test_stack_unstack.py | 2 +- pandas/tests/frame/test_subclass.py | 2 +- pandas/tests/groupby/test_counting.py | 2 +- pandas/tests/indexes/datetimes/test_timezones.py | 2 +- pandas/tests/indexes/test_index_new.py | 2 +- pandas/tests/indexing/test_iloc.py | 2 +- pandas/tests/io/formats/test_console.py | 2 +- pandas/tests/io/json/test_pandas.py | 4 ++-- pandas/tests/io/json/test_readlines.py | 2 +- pandas/tests/io/json/test_ujson.py | 4 ++-- pandas/tests/io/parser/common/test_common_basic.py | 2 +- pandas/tests/io/parser/test_python_parser_only.py | 2 +- pandas/tests/io/parser/test_unsupported.py | 2 +- pandas/tests/io/test_common.py | 2 +- pandas/tests/io/test_html.py | 2 +- pandas/tests/io/test_pickle.py | 4 ++-- pandas/tests/io/test_sql.py | 2 +- pandas/tests/reshape/test_pivot.py | 2 +- pandas/tests/scalar/timedelta/test_arithmetic.py | 2 +- pandas/tests/series/methods/test_is_unique.py | 2 +- pandas/tests/series/test_ufunc.py | 4 ++-- pandas/tests/test_register_accessor.py | 6 +++--- pandas/tests/tseries/holiday/test_calendar.py | 2 +- 38 files changed, 50 insertions(+), 50 deletions(-) diff --git a/pandas/tests/base/test_constructors.py b/pandas/tests/base/test_constructors.py index c845be1d0d1f5..44d6bc57b0431 100644 --- a/pandas/tests/base/test_constructors.py +++ b/pandas/tests/base/test_constructors.py @@ -51,7 +51,7 @@ def bar(self, *args, **kwargs): pass class Delegate(PandasDelegate, PandasObject): - def __init__(self, obj): + def __init__(self, obj) -> None: self.obj = obj def test_invalid_delegation(self): diff --git a/pandas/tests/dtypes/test_inference.py b/pandas/tests/dtypes/test_inference.py index 99037226782db..bf13e6b7b4629 100644 --- a/pandas/tests/dtypes/test_inference.py +++ b/pandas/tests/dtypes/test_inference.py @@ -91,7 +91,7 @@ class MockNumpyLikeArray: a scalar (`is_scalar(np.array(1)) == False`), but it is not list-like either. """ - def __init__(self, values): + def __init__(self, values) -> None: self._values = values def __iter__(self): @@ -323,7 +323,7 @@ def test_is_dict_like_fails(ll): @pytest.mark.parametrize("has_contains", [True, False]) def test_is_dict_like_duck_type(has_keys, has_getitem, has_contains): class DictLike: - def __init__(self, d): + def __init__(self, d) -> None: self.d = d if has_keys: @@ -1937,7 +1937,7 @@ def test_is_scalar_number(self): # subclasses are. class Numeric(Number): - def __init__(self, value): + def __init__(self, value) -> None: self.value = value def __int__(self): diff --git a/pandas/tests/extension/arrow/arrays.py b/pandas/tests/extension/arrow/arrays.py index 1ab3d49392052..33eef35153bce 100644 --- a/pandas/tests/extension/arrow/arrays.py +++ b/pandas/tests/extension/arrow/arrays.py @@ -179,7 +179,7 @@ def all(self, axis=0, out=None): class ArrowBoolArray(ArrowExtensionArray): - def __init__(self, values): + def __init__(self, values) -> None: if not isinstance(values, pa.ChunkedArray): raise ValueError @@ -189,7 +189,7 @@ def __init__(self, values): class ArrowStringArray(ArrowExtensionArray): - def __init__(self, values): + def __init__(self, values) -> None: if not isinstance(values, pa.ChunkedArray): raise ValueError diff --git a/pandas/tests/extension/arrow/test_timestamp.py b/pandas/tests/extension/arrow/test_timestamp.py index 28e6ce0e77b34..b2750784ab3d6 100644 --- a/pandas/tests/extension/arrow/test_timestamp.py +++ b/pandas/tests/extension/arrow/test_timestamp.py @@ -40,7 +40,7 @@ def construct_array_type(cls) -> type_t[ArrowTimestampUSArray]: class ArrowTimestampUSArray(ArrowExtensionArray): - def __init__(self, values): + def __init__(self, values) -> None: if not isinstance(values, pa.ChunkedArray): raise ValueError diff --git a/pandas/tests/extension/decimal/array.py b/pandas/tests/extension/decimal/array.py index fe489c7605d0a..a3edc95fce96b 100644 --- a/pandas/tests/extension/decimal/array.py +++ b/pandas/tests/extension/decimal/array.py @@ -41,7 +41,7 @@ class DecimalDtype(ExtensionDtype): na_value = decimal.Decimal("NaN") _metadata = ("context",) - def __init__(self, context=None): + def __init__(self, context=None) -> None: self.context = context or decimal.getcontext() def __repr__(self) -> str: @@ -66,7 +66,7 @@ def _is_numeric(self) -> bool: class DecimalArray(OpsMixin, ExtensionScalarOpsMixin, ExtensionArray): __array_priority__ = 1000 - def __init__(self, values, dtype=None, copy=False, context=None): + def __init__(self, values, dtype=None, copy=False, context=None) -> None: for i, val in enumerate(values): if is_float(val): if np.isnan(val): diff --git a/pandas/tests/extension/json/array.py b/pandas/tests/extension/json/array.py index 2ce242baf2e5e..125a0aee2089d 100644 --- a/pandas/tests/extension/json/array.py +++ b/pandas/tests/extension/json/array.py @@ -67,7 +67,7 @@ class JSONArray(ExtensionArray): dtype = JSONDtype() __array_priority__ = 1000 - def __init__(self, values, dtype=None, copy=False): + def __init__(self, values, dtype=None, copy=False) -> None: for val in values: if not isinstance(val, self.dtype.type): raise TypeError("All values must be of type " + str(self.dtype.type)) diff --git a/pandas/tests/extension/list/array.py b/pandas/tests/extension/list/array.py index 47015ed334ddf..f281a0f82e0e7 100644 --- a/pandas/tests/extension/list/array.py +++ b/pandas/tests/extension/list/array.py @@ -44,7 +44,7 @@ class ListArray(ExtensionArray): dtype = ListDtype() __array_priority__ = 1000 - def __init__(self, values, dtype=None, copy=False): + def __init__(self, values, dtype=None, copy=False) -> None: if not isinstance(values, np.ndarray): raise TypeError("Need to pass a numpy array as values") for val in values: diff --git a/pandas/tests/extension/test_common.py b/pandas/tests/extension/test_common.py index e43650c291200..62bc250193564 100644 --- a/pandas/tests/extension/test_common.py +++ b/pandas/tests/extension/test_common.py @@ -14,7 +14,7 @@ class DummyDtype(dtypes.ExtensionDtype): class DummyArray(ExtensionArray): - def __init__(self, data): + def __init__(self, data) -> None: self.data = data def __array__(self, dtype): diff --git a/pandas/tests/extension/test_extension.py b/pandas/tests/extension/test_extension.py index 939b836a11556..1ed626cd51080 100644 --- a/pandas/tests/extension/test_extension.py +++ b/pandas/tests/extension/test_extension.py @@ -8,7 +8,7 @@ class MyEA(ExtensionArray): - def __init__(self, values): + def __init__(self, values) -> None: self._values = values diff --git a/pandas/tests/frame/constructors/test_from_records.py b/pandas/tests/frame/constructors/test_from_records.py index 4aa150afadef6..c6d54e28ca1c8 100644 --- a/pandas/tests/frame/constructors/test_from_records.py +++ b/pandas/tests/frame/constructors/test_from_records.py @@ -194,7 +194,7 @@ def test_from_records_bad_index_column(self): def test_from_records_non_tuple(self): class Record: - def __init__(self, *args): + def __init__(self, *args) -> None: self.args = args def __getitem__(self, i): diff --git a/pandas/tests/frame/methods/test_select_dtypes.py b/pandas/tests/frame/methods/test_select_dtypes.py index 4cfd9975652e3..9da6b61e67603 100644 --- a/pandas/tests/frame/methods/test_select_dtypes.py +++ b/pandas/tests/frame/methods/test_select_dtypes.py @@ -15,7 +15,7 @@ class DummyDtype(ExtensionDtype): type = int - def __init__(self, numeric): + def __init__(self, numeric) -> None: self._numeric = numeric @property @@ -28,7 +28,7 @@ def _is_numeric(self): class DummyArray(ExtensionArray): - def __init__(self, data, dtype): + def __init__(self, data, dtype) -> None: self.data = data self._dtype = dtype diff --git a/pandas/tests/frame/methods/test_set_index.py b/pandas/tests/frame/methods/test_set_index.py index 1b3db10ec6158..4c39cf99f18ff 100644 --- a/pandas/tests/frame/methods/test_set_index.py +++ b/pandas/tests/frame/methods/test_set_index.py @@ -595,7 +595,7 @@ def test_set_index_custom_label_type(self): # GH#24969 class Thing: - def __init__(self, name, color): + def __init__(self, name, color) -> None: self.name = name self.color = color @@ -673,7 +673,7 @@ def test_set_index_custom_label_type_raises(self): # purposefully inherit from something unhashable class Thing(set): - def __init__(self, name, color): + def __init__(self, name, color) -> None: self.name = name self.color = color diff --git a/pandas/tests/frame/methods/test_to_records.py b/pandas/tests/frame/methods/test_to_records.py index a2e94782142ac..1a84fb73fd524 100644 --- a/pandas/tests/frame/methods/test_to_records.py +++ b/pandas/tests/frame/methods/test_to_records.py @@ -358,7 +358,7 @@ def test_to_records_dtype_mi(self, df, kwargs, expected): def test_to_records_dict_like(self): # see GH#18146 class DictLike: - def __init__(self, **kwargs): + def __init__(self, **kwargs) -> None: self.d = kwargs.copy() def __getitem__(self, key): diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index da5e7d15ab9d2..7c33242192d2e 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -41,7 +41,7 @@ def switch_numexpr_min_elements(request): class DummyElement: - def __init__(self, value, dtype): + def __init__(self, value, dtype) -> None: self.value = value self.dtype = np.dtype(dtype) diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index e5b1673da1e27..82c7117cc00c6 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1363,7 +1363,7 @@ def test_constructor_sequence_like(self): # collections.Sequence like class DummyContainer(abc.Sequence): - def __init__(self, lst): + def __init__(self, lst) -> None: self._lst = lst def __getitem__(self, n): diff --git a/pandas/tests/frame/test_stack_unstack.py b/pandas/tests/frame/test_stack_unstack.py index 19326c185075f..ba89a76a7f8c2 100644 --- a/pandas/tests/frame/test_stack_unstack.py +++ b/pandas/tests/frame/test_stack_unstack.py @@ -1861,7 +1861,7 @@ def test_unstack_number_of_levels_larger_than_int32(self, monkeypatch): # GH 26314: Change ValueError to PerformanceWarning class MockUnstacker(reshape_lib._Unstacker): - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: # __init__ will raise the warning super().__init__(*args, **kwargs) raise Exception("Don't compute final result.") diff --git a/pandas/tests/frame/test_subclass.py b/pandas/tests/frame/test_subclass.py index 9ec4179bf83fd..d5331b1060b23 100644 --- a/pandas/tests/frame/test_subclass.py +++ b/pandas/tests/frame/test_subclass.py @@ -42,7 +42,7 @@ class CustomDataFrame(DataFrame): custom plotting functions. """ - def __init__(self, *args, **kw): + def __init__(self, *args, **kw) -> None: super().__init__(*args, **kw) @property diff --git a/pandas/tests/groupby/test_counting.py b/pandas/tests/groupby/test_counting.py index 73b2d8ac2c1f5..f0a3219d0b419 100644 --- a/pandas/tests/groupby/test_counting.py +++ b/pandas/tests/groupby/test_counting.py @@ -364,7 +364,7 @@ class RaisingObjectException(Exception): pass class RaisingObject: - def __init__(self, msg="I will raise inside Cython"): + def __init__(self, msg="I will raise inside Cython") -> None: super().__init__() self.msg = msg diff --git a/pandas/tests/indexes/datetimes/test_timezones.py b/pandas/tests/indexes/datetimes/test_timezones.py index 9a1cb6a303c72..51bc054010aca 100644 --- a/pandas/tests/indexes/datetimes/test_timezones.py +++ b/pandas/tests/indexes/datetimes/test_timezones.py @@ -40,7 +40,7 @@ class FixedOffset(tzinfo): """Fixed offset in minutes east from UTC.""" - def __init__(self, offset, name): + def __init__(self, offset, name) -> None: self.__offset = timedelta(minutes=offset) self.__name = name diff --git a/pandas/tests/indexes/test_index_new.py b/pandas/tests/indexes/test_index_new.py index 3052c9d7ee69b..9a57e3e08a59c 100644 --- a/pandas/tests/indexes/test_index_new.py +++ b/pandas/tests/indexes/test_index_new.py @@ -352,7 +352,7 @@ def test_constructor_ndarray_like(self, array): # it should be possible to convert any object that satisfies the numpy # ndarray interface directly into an Index class ArrayLike: - def __init__(self, array): + def __init__(self, array) -> None: self.array = array def __array__(self, dtype=None) -> np.ndarray: diff --git a/pandas/tests/indexing/test_iloc.py b/pandas/tests/indexing/test_iloc.py index a965d32c82c61..426192ab46914 100644 --- a/pandas/tests/indexing/test_iloc.py +++ b/pandas/tests/indexing/test_iloc.py @@ -1072,7 +1072,7 @@ def test_iloc_getitem_float_duplicates(self): def test_iloc_setitem_custom_object(self): # iloc with an object class TO: - def __init__(self, value): + def __init__(self, value) -> None: self.value = value def __str__(self) -> str: diff --git a/pandas/tests/io/formats/test_console.py b/pandas/tests/io/formats/test_console.py index 5bd73e6045e32..dd7b57df9baed 100644 --- a/pandas/tests/io/formats/test_console.py +++ b/pandas/tests/io/formats/test_console.py @@ -12,7 +12,7 @@ class MockEncoding: side effect should be an exception that will be raised. """ - def __init__(self, encoding): + def __init__(self, encoding) -> None: super().__init__() self.val = encoding diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index e08b7592c4d82..1a18f034074e8 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -585,7 +585,7 @@ def test_frame_nonprintable_bytes(self): # GH14256: failing column caused segfaults, if it is not the last one class BinaryThing: - def __init__(self, hexed): + def __init__(self, hexed) -> None: self.hexed = hexed self.binary = bytes.fromhex(hexed) @@ -1817,7 +1817,7 @@ def test_to_json_multiindex_escape(self): def test_to_json_series_of_objects(self): class _TestObject: - def __init__(self, a, b, _c, d): + def __init__(self, a, b, _c, d) -> None self.a = a self.b = b self._c = _c diff --git a/pandas/tests/io/json/test_readlines.py b/pandas/tests/io/json/test_readlines.py index 4ba9f48a40fbc..6fa0c4d5c51a1 100644 --- a/pandas/tests/io/json/test_readlines.py +++ b/pandas/tests/io/json/test_readlines.py @@ -281,7 +281,7 @@ def test_chunksize_is_incremental(): ) class MyReader: - def __init__(self, contents): + def __init__(self, contents) -> None: self.read_count = 0 self.stringio = StringIO(contents) diff --git a/pandas/tests/io/json/test_ujson.py b/pandas/tests/io/json/test_ujson.py index d3cf144451c95..93318bed2a6af 100644 --- a/pandas/tests/io/json/test_ujson.py +++ b/pandas/tests/io/json/test_ujson.py @@ -660,7 +660,7 @@ def toDict(self): def test_default_handler(self): class _TestObject: - def __init__(self, val): + def __init__(self, val) -> None: self.val = val @property @@ -714,7 +714,7 @@ def my_obj_handler(_): def test_encode_object(self): class _TestObject: - def __init__(self, a, b, _c, d): + def __init__(self, a, b, _c, d) -> None: self.a = a self.b = b self._c = _c diff --git a/pandas/tests/io/parser/common/test_common_basic.py b/pandas/tests/io/parser/common/test_common_basic.py index bde69e365cfd1..5472bd99fa746 100644 --- a/pandas/tests/io/parser/common/test_common_basic.py +++ b/pandas/tests/io/parser/common/test_common_basic.py @@ -41,7 +41,7 @@ def test_override_set_noconvert_columns(): # Usecols needs to be sorted in _set_noconvert_columns based # on the test_usecols_with_parse_dates test from test_usecols.py class MyTextFileReader(TextFileReader): - def __init__(self): + def __init__(self) -> None: self._currow = 0 self.squeeze = False diff --git a/pandas/tests/io/parser/test_python_parser_only.py b/pandas/tests/io/parser/test_python_parser_only.py index 999a6217efb68..f72d22c9e5b0c 100644 --- a/pandas/tests/io/parser/test_python_parser_only.py +++ b/pandas/tests/io/parser/test_python_parser_only.py @@ -319,7 +319,7 @@ def test_python_engine_file_no_next(python_parser_only): parser = python_parser_only class NoNextBuffer: - def __init__(self, csv_data): + def __init__(self, csv_data) -> None: self.data = csv_data def __iter__(self): diff --git a/pandas/tests/io/parser/test_unsupported.py b/pandas/tests/io/parser/test_unsupported.py index b28417c9a3625..7937f47e8bff5 100644 --- a/pandas/tests/io/parser/test_unsupported.py +++ b/pandas/tests/io/parser/test_unsupported.py @@ -114,7 +114,7 @@ def test_python_engine(self, python_engine): def test_python_engine_file_no_iter(self, python_engine): # see gh-16530 class NoNextBuffer: - def __init__(self, csv_data): + def __init__(self, csv_data) -> None: self.data = csv_data def __next__(self): diff --git a/pandas/tests/io/test_common.py b/pandas/tests/io/test_common.py index adf4f32837acf..ca6809470b2b1 100644 --- a/pandas/tests/io/test_common.py +++ b/pandas/tests/io/test_common.py @@ -28,7 +28,7 @@ class CustomFSPath: """For testing fspath on unknown objects""" - def __init__(self, path): + def __init__(self, path) -> None: self.path = path def __fspath__(self): diff --git a/pandas/tests/io/test_html.py b/pandas/tests/io/test_html.py index 59a968bc4719a..99fa31726445a 100644 --- a/pandas/tests/io/test_html.py +++ b/pandas/tests/io/test_html.py @@ -1243,7 +1243,7 @@ def test_parse_failure_rewinds(self): # Issue #17975 class MockFile: - def __init__(self, data): + def __init__(self, data) -> None: self.data = data self.at_end = False diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 3ad8fd4051b48..fe8809718300e 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -436,7 +436,7 @@ def python_pickler(obj, path): pickle.dump(obj, fh, protocol=-1) class MockReadResponse: - def __init__(self, path): + def __init__(self, path) -> None: self.file = open(path, "rb") if "gzip" in path: self.headers = {"Content-Encoding": "gzip"} @@ -478,7 +478,7 @@ def test_pickle_fsspec_roundtrip(): class MyTz(datetime.tzinfo): - def __init__(self): + def __init__(self) -> None: pass diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 659fe7c30e552..31add4743d1e9 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -1538,7 +1538,7 @@ def test_con_unknown_dbapi2_class_does_not_error_without_sql_alchemy_installed( self, ): class MockSqliteConnection: - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: self.conn = sqlite3.Connection(*args, **kwargs) def __getattr__(self, name): diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 6c222669c37db..31f720b9ec336 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -1999,7 +1999,7 @@ def test_pivot_number_of_levels_larger_than_int32(self, monkeypatch): # GH 20601 # GH 26314: Change ValueError to PerformanceWarning class MockUnstacker(reshape_lib._Unstacker): - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: # __init__ will raise the warning super().__init__(*args, **kwargs) raise Exception("Don't compute final result.") diff --git a/pandas/tests/scalar/timedelta/test_arithmetic.py b/pandas/tests/scalar/timedelta/test_arithmetic.py index ff1f6ad42feb3..74aa7f045088e 100644 --- a/pandas/tests/scalar/timedelta/test_arithmetic.py +++ b/pandas/tests/scalar/timedelta/test_arithmetic.py @@ -988,7 +988,7 @@ def test_compare_custom_object(self): """ class CustomClass: - def __init__(self, cmp_result=None): + def __init__(self, cmp_result=None) -> None: self.cmp_result = cmp_result def generic_result(self): diff --git a/pandas/tests/series/methods/test_is_unique.py b/pandas/tests/series/methods/test_is_unique.py index c696d365662ea..960057cb3d646 100644 --- a/pandas/tests/series/methods/test_is_unique.py +++ b/pandas/tests/series/methods/test_is_unique.py @@ -26,7 +26,7 @@ def test_is_unique(data, expected): def test_is_unique_class_ne(capsys): # GH#20661 class Foo: - def __init__(self, val): + def __init__(self, val) -> None: self._value = val def __ne__(self, other): diff --git a/pandas/tests/series/test_ufunc.py b/pandas/tests/series/test_ufunc.py index 43d33f5b498bc..b8cee317af287 100644 --- a/pandas/tests/series/test_ufunc.py +++ b/pandas/tests/series/test_ufunc.py @@ -238,7 +238,7 @@ def test_binary_ufunc_drops_series_name(ufunc, sparse, arrays_for_binary_ufunc): def test_object_series_ok(): class Dummy: - def __init__(self, value): + def __init__(self, value) -> None: self.value = value def __add__(self, other): @@ -413,7 +413,7 @@ def test_binary_ufunc_other_types(type_): def test_object_dtype_ok(): class Thing: - def __init__(self, value): + def __init__(self, value) -> None: self.value = value def __add__(self, other): diff --git a/pandas/tests/test_register_accessor.py b/pandas/tests/test_register_accessor.py index 6e224245076ee..3e4e57414269a 100644 --- a/pandas/tests/test_register_accessor.py +++ b/pandas/tests/test_register_accessor.py @@ -14,7 +14,7 @@ class X(accessor.DirNamesMixin): x = 1 y: int - def __init__(self): + def __init__(self) -> None: self.z = 3 result = [attr_name for attr_name in dir(X()) if not attr_name.startswith("_")] @@ -38,7 +38,7 @@ def ensure_removed(obj, attr): class MyAccessor: - def __init__(self, obj): + def __init__(self, obj) -> None: self.obj = obj self.item = "item" @@ -102,7 +102,7 @@ def test_raises_attribute_error(): @pd.api.extensions.register_series_accessor("bad") class Bad: - def __init__(self, data): + def __init__(self, data) -> None: raise AttributeError("whoops") with pytest.raises(AttributeError, match="whoops"): diff --git a/pandas/tests/tseries/holiday/test_calendar.py b/pandas/tests/tseries/holiday/test_calendar.py index a1e3c1985a4d4..57acf15443ca8 100644 --- a/pandas/tests/tseries/holiday/test_calendar.py +++ b/pandas/tests/tseries/holiday/test_calendar.py @@ -50,7 +50,7 @@ def test_calendar_caching(): # see gh-9552. class TestCalendar(AbstractHolidayCalendar): - def __init__(self, name=None, rules=None): + def __init__(self, name=None, rules=None) -> None: super().__init__(name=name, rules=rules) jan1 = TestCalendar(rules=[Holiday("jan1", year=2015, month=1, day=1)]) From ff229f955c17dea90c1e08802b4da40b0bc61d29 Mon Sep 17 00:00:00 2001 From: Ekaterina Kuzkina Date: Tue, 8 Mar 2022 22:41:47 +0000 Subject: [PATCH 2/3] fix missing colon --- pandas/tests/io/json/test_pandas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 1a18f034074e8..985d9e47ea7bd 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -1817,7 +1817,7 @@ def test_to_json_multiindex_escape(self): def test_to_json_series_of_objects(self): class _TestObject: - def __init__(self, a, b, _c, d) -> None + def __init__(self, a, b, _c, d) -> None: self.a = a self.b = b self._c = _c From bde41adf5ca8412ea3c0d9564c317b1b8711c794 Mon Sep 17 00:00:00 2001 From: Ekaterina Kuzkina Date: Tue, 8 Mar 2022 23:33:35 +0000 Subject: [PATCH 3/3] fix unused comment and incompatible type (None->"") --- pandas/core/indexes/multi.py | 4 +--- pandas/tests/io/test_pickle.py | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index f40857059a794..cdde510927081 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1088,9 +1088,7 @@ def _engine(self): # equivalent to sorting lexicographically the codes themselves. Notice # that each level needs to be shifted by the number of bits needed to # represent the _previous_ ones: - offsets = np.concatenate([lev_bits[1:], [0]]).astype( # type: ignore[arg-type] - "uint64" - ) + offsets = np.concatenate([lev_bits[1:], [0]]).astype("uint64") # Check the total number of bits needed for our representation: if lev_bits[0] > 64: diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index fe8809718300e..8f19a54a5eedf 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -441,7 +441,7 @@ def __init__(self, path) -> None: if "gzip" in path: self.headers = {"Content-Encoding": "gzip"} else: - self.headers = {"Content-Encoding": None} + self.headers = {"Content-Encoding": ""} def __enter__(self): return self