Skip to content

Commit c36be9e

Browse files
authored
Merge branch 'main' into TYP_io
2 parents d816772 + 0453fdf commit c36be9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+71
-77
lines changed

doc/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
single_doc=None,
4646
verbosity=0,
4747
warnings_are_errors=False,
48-
):
48+
) -> None:
4949
self.num_jobs = num_jobs
5050
self.include_api = include_api
5151
self.whatsnew = whatsnew

pandas/_config/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def get_default_val(pat: str):
204204
class DictWrapper:
205205
"""provide attribute-style access to a nested dict"""
206206

207-
def __init__(self, d: dict[str, Any], prefix: str = ""):
207+
def __init__(self, d: dict[str, Any], prefix: str = "") -> None:
208208
object.__setattr__(self, "d", d)
209209
object.__setattr__(self, "prefix", prefix)
210210

@@ -248,7 +248,7 @@ def __dir__(self) -> Iterable[str]:
248248

249249

250250
class CallableDynamicDoc:
251-
def __init__(self, func, doc_tmpl):
251+
def __init__(self, func, doc_tmpl) -> None:
252252
self.__doc_tmpl__ = doc_tmpl
253253
self.__func__ = func
254254

@@ -422,7 +422,7 @@ class option_context(ContextDecorator):
422422
... pass
423423
"""
424424

425-
def __init__(self, *args):
425+
def __init__(self, *args) -> None:
426426
if len(args) % 2 != 0 or len(args) < 2:
427427
raise ValueError(
428428
"Need to invoke as option_context(pat, val, [(pat, val), ...])."

pandas/_testing/contexts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class RNGContext:
228228
np.random.randn()
229229
"""
230230

231-
def __init__(self, seed):
231+
def __init__(self, seed) -> None:
232232
self.seed = seed
233233

234234
def __enter__(self):

pandas/compat/numpy/function.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
fname=None,
4141
method: str | None = None,
4242
max_fname_arg_count=None,
43-
):
43+
) -> None:
4444
self.fname = fname
4545
self.method = method
4646
self.defaults = defaults

pandas/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def dict_subclass():
447447
"""
448448

449449
class TestSubDict(dict):
450-
def __init__(self, *args, **kwargs):
450+
def __init__(self, *args, **kwargs) -> None:
451451
dict.__init__(self, *args, **kwargs)
452452

453453
return TestSubDict
@@ -460,7 +460,7 @@ def non_dict_mapping_subclass():
460460
"""
461461

462462
class TestNonDictMapping(abc.Mapping):
463-
def __init__(self, underlying_dict):
463+
def __init__(self, underlying_dict) -> None:
464464
self._data = underlying_dict
465465

466466
def __getitem__(self, key):
@@ -1709,7 +1709,7 @@ class TestMemoryFS(MemoryFileSystem):
17091709
protocol = "testmem"
17101710
test = [None]
17111711

1712-
def __init__(self, **kwargs):
1712+
def __init__(self, **kwargs) -> None:
17131713
self.test[0] = kwargs.pop("test", None)
17141714
super().__init__(**kwargs)
17151715

pandas/core/generic.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,7 +2956,7 @@ def to_sql(
29562956
)
29572957
def to_pickle(
29582958
self,
2959-
path,
2959+
path: FilePath | WriteBuffer[bytes],
29602960
compression: CompressionOptions = "infer",
29612961
protocol: int = pickle.HIGHEST_PROTOCOL,
29622962
storage_options: StorageOptions = None,
@@ -2966,8 +2966,10 @@ def to_pickle(
29662966
29672967
Parameters
29682968
----------
2969-
path : str
2970-
File path where the pickled object will be stored.
2969+
path : str, path object, or file-like object
2970+
String, path object (implementing ``os.PathLike[str]``), or file-like
2971+
object implementing a binary ``write()`` function. File path where
2972+
the pickled object will be stored.
29712973
{compression_options}
29722974
protocol : int
29732975
Int which indicates which protocol should be used by the pickler,

pandas/core/indexes/multi.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,7 @@ def _engine(self):
10881088
# equivalent to sorting lexicographically the codes themselves. Notice
10891089
# that each level needs to be shifted by the number of bits needed to
10901090
# represent the _previous_ ones:
1091-
offsets = np.concatenate([lev_bits[1:], [0]]).astype( # type: ignore[arg-type]
1092-
"uint64"
1093-
)
1091+
offsets = np.concatenate([lev_bits[1:], [0]]).astype("uint64")
10941092

10951093
# Check the total number of bits needed for our representation:
10961094
if lev_bits[0] > 64:

pandas/errors/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class AbstractMethodError(NotImplementedError):
186186
while keeping compatibility with Python 2 and Python 3.
187187
"""
188188

189-
def __init__(self, class_instance, methodtype="method"):
189+
def __init__(self, class_instance, methodtype="method") -> None:
190190
types = {"method", "classmethod", "staticmethod", "property"}
191191
if methodtype not in types:
192192
raise ValueError(

pandas/tests/base/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def bar(self, *args, **kwargs):
5151
pass
5252

5353
class Delegate(PandasDelegate, PandasObject):
54-
def __init__(self, obj):
54+
def __init__(self, obj) -> None:
5555
self.obj = obj
5656

5757
def test_invalid_delegation(self):

pandas/tests/dtypes/test_inference.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class MockNumpyLikeArray:
9191
a scalar (`is_scalar(np.array(1)) == False`), but it is not list-like either.
9292
"""
9393

94-
def __init__(self, values):
94+
def __init__(self, values) -> None:
9595
self._values = values
9696

9797
def __iter__(self):
@@ -323,7 +323,7 @@ def test_is_dict_like_fails(ll):
323323
@pytest.mark.parametrize("has_contains", [True, False])
324324
def test_is_dict_like_duck_type(has_keys, has_getitem, has_contains):
325325
class DictLike:
326-
def __init__(self, d):
326+
def __init__(self, d) -> None:
327327
self.d = d
328328

329329
if has_keys:
@@ -1937,7 +1937,7 @@ def test_is_scalar_number(self):
19371937
# subclasses are.
19381938

19391939
class Numeric(Number):
1940-
def __init__(self, value):
1940+
def __init__(self, value) -> None:
19411941
self.value = value
19421942

19431943
def __int__(self):

pandas/tests/extension/arrow/arrays.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def all(self, axis=0, out=None):
179179

180180

181181
class ArrowBoolArray(ArrowExtensionArray):
182-
def __init__(self, values):
182+
def __init__(self, values) -> None:
183183
if not isinstance(values, pa.ChunkedArray):
184184
raise ValueError
185185

@@ -189,7 +189,7 @@ def __init__(self, values):
189189

190190

191191
class ArrowStringArray(ArrowExtensionArray):
192-
def __init__(self, values):
192+
def __init__(self, values) -> None:
193193
if not isinstance(values, pa.ChunkedArray):
194194
raise ValueError
195195

pandas/tests/extension/arrow/test_timestamp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def construct_array_type(cls) -> type_t[ArrowTimestampUSArray]:
4040

4141

4242
class ArrowTimestampUSArray(ArrowExtensionArray):
43-
def __init__(self, values):
43+
def __init__(self, values) -> None:
4444
if not isinstance(values, pa.ChunkedArray):
4545
raise ValueError
4646

pandas/tests/extension/decimal/array.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DecimalDtype(ExtensionDtype):
4141
na_value = decimal.Decimal("NaN")
4242
_metadata = ("context",)
4343

44-
def __init__(self, context=None):
44+
def __init__(self, context=None) -> None:
4545
self.context = context or decimal.getcontext()
4646

4747
def __repr__(self) -> str:
@@ -66,7 +66,7 @@ def _is_numeric(self) -> bool:
6666
class DecimalArray(OpsMixin, ExtensionScalarOpsMixin, ExtensionArray):
6767
__array_priority__ = 1000
6868

69-
def __init__(self, values, dtype=None, copy=False, context=None):
69+
def __init__(self, values, dtype=None, copy=False, context=None) -> None:
7070
for i, val in enumerate(values):
7171
if is_float(val):
7272
if np.isnan(val):

pandas/tests/extension/json/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class JSONArray(ExtensionArray):
6767
dtype = JSONDtype()
6868
__array_priority__ = 1000
6969

70-
def __init__(self, values, dtype=None, copy=False):
70+
def __init__(self, values, dtype=None, copy=False) -> None:
7171
for val in values:
7272
if not isinstance(val, self.dtype.type):
7373
raise TypeError("All values must be of type " + str(self.dtype.type))

pandas/tests/extension/list/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ListArray(ExtensionArray):
4444
dtype = ListDtype()
4545
__array_priority__ = 1000
4646

47-
def __init__(self, values, dtype=None, copy=False):
47+
def __init__(self, values, dtype=None, copy=False) -> None:
4848
if not isinstance(values, np.ndarray):
4949
raise TypeError("Need to pass a numpy array as values")
5050
for val in values:

pandas/tests/extension/test_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DummyDtype(dtypes.ExtensionDtype):
1414

1515

1616
class DummyArray(ExtensionArray):
17-
def __init__(self, data):
17+
def __init__(self, data) -> None:
1818
self.data = data
1919

2020
def __array__(self, dtype):

pandas/tests/extension/test_extension.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
class MyEA(ExtensionArray):
11-
def __init__(self, values):
11+
def __init__(self, values) -> None:
1212
self._values = values
1313

1414

pandas/tests/frame/constructors/test_from_records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_from_records_bad_index_column(self):
194194

195195
def test_from_records_non_tuple(self):
196196
class Record:
197-
def __init__(self, *args):
197+
def __init__(self, *args) -> None:
198198
self.args = args
199199

200200
def __getitem__(self, i):

pandas/tests/frame/methods/test_select_dtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class DummyDtype(ExtensionDtype):
1616
type = int
1717

18-
def __init__(self, numeric):
18+
def __init__(self, numeric) -> None:
1919
self._numeric = numeric
2020

2121
@property
@@ -28,7 +28,7 @@ def _is_numeric(self):
2828

2929

3030
class DummyArray(ExtensionArray):
31-
def __init__(self, data, dtype):
31+
def __init__(self, data, dtype) -> None:
3232
self.data = data
3333
self._dtype = dtype
3434

pandas/tests/frame/methods/test_set_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ def test_set_index_custom_label_type(self):
595595
# GH#24969
596596

597597
class Thing:
598-
def __init__(self, name, color):
598+
def __init__(self, name, color) -> None:
599599
self.name = name
600600
self.color = color
601601

@@ -673,7 +673,7 @@ def test_set_index_custom_label_type_raises(self):
673673

674674
# purposefully inherit from something unhashable
675675
class Thing(set):
676-
def __init__(self, name, color):
676+
def __init__(self, name, color) -> None:
677677
self.name = name
678678
self.color = color
679679

pandas/tests/frame/methods/test_to_records.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ def test_to_records_dtype_mi(self, df, kwargs, expected):
358358
def test_to_records_dict_like(self):
359359
# see GH#18146
360360
class DictLike:
361-
def __init__(self, **kwargs):
361+
def __init__(self, **kwargs) -> None:
362362
self.d = kwargs.copy()
363363

364364
def __getitem__(self, key):

pandas/tests/frame/test_arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def switch_numexpr_min_elements(request):
4141

4242

4343
class DummyElement:
44-
def __init__(self, value, dtype):
44+
def __init__(self, value, dtype) -> None:
4545
self.value = value
4646
self.dtype = np.dtype(dtype)
4747

pandas/tests/frame/test_constructors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ def test_constructor_sequence_like(self):
13631363
# collections.Sequence like
13641364

13651365
class DummyContainer(abc.Sequence):
1366-
def __init__(self, lst):
1366+
def __init__(self, lst) -> None:
13671367
self._lst = lst
13681368

13691369
def __getitem__(self, n):

pandas/tests/frame/test_stack_unstack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,7 @@ def test_unstack_number_of_levels_larger_than_int32(self, monkeypatch):
18611861
# GH 26314: Change ValueError to PerformanceWarning
18621862

18631863
class MockUnstacker(reshape_lib._Unstacker):
1864-
def __init__(self, *args, **kwargs):
1864+
def __init__(self, *args, **kwargs) -> None:
18651865
# __init__ will raise the warning
18661866
super().__init__(*args, **kwargs)
18671867
raise Exception("Don't compute final result.")

pandas/tests/frame/test_subclass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CustomDataFrame(DataFrame):
4242
custom plotting functions.
4343
"""
4444

45-
def __init__(self, *args, **kw):
45+
def __init__(self, *args, **kw) -> None:
4646
super().__init__(*args, **kw)
4747

4848
@property

pandas/tests/frame/test_ufunc.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,6 @@ def test_alignment_deprecation_many_inputs(request):
263263
)
264264

265265
if np_version_gte1p22:
266-
mark = pytest.mark.xfail(
267-
reason="ufunc 'my_ufunc' did not contain a loop with signature matching "
268-
"types",
269-
)
270-
request.node.add_marker(mark)
271-
272266
mark = pytest.mark.filterwarnings(
273267
"ignore:`np.MachAr` is deprecated.*:DeprecationWarning"
274268
)

pandas/tests/groupby/test_counting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class RaisingObjectException(Exception):
364364
pass
365365

366366
class RaisingObject:
367-
def __init__(self, msg="I will raise inside Cython"):
367+
def __init__(self, msg="I will raise inside Cython") -> None:
368368
super().__init__()
369369
self.msg = msg
370370

pandas/tests/indexes/datetimes/test_timezones.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
class FixedOffset(tzinfo):
4141
"""Fixed offset in minutes east from UTC."""
4242

43-
def __init__(self, offset, name):
43+
def __init__(self, offset, name) -> None:
4444
self.__offset = timedelta(minutes=offset)
4545
self.__name = name
4646

pandas/tests/indexes/test_index_new.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def test_constructor_ndarray_like(self, array):
352352
# it should be possible to convert any object that satisfies the numpy
353353
# ndarray interface directly into an Index
354354
class ArrayLike:
355-
def __init__(self, array):
355+
def __init__(self, array) -> None:
356356
self.array = array
357357

358358
def __array__(self, dtype=None) -> np.ndarray:

pandas/tests/indexing/test_iloc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ def test_iloc_getitem_float_duplicates(self):
10721072
def test_iloc_setitem_custom_object(self):
10731073
# iloc with an object
10741074
class TO:
1075-
def __init__(self, value):
1075+
def __init__(self, value) -> None:
10761076
self.value = value
10771077

10781078
def __str__(self) -> str:

pandas/tests/io/formats/test_console.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class MockEncoding:
1212
side effect should be an exception that will be raised.
1313
"""
1414

15-
def __init__(self, encoding):
15+
def __init__(self, encoding) -> None:
1616
super().__init__()
1717
self.val = encoding
1818

0 commit comments

Comments
 (0)