Skip to content

Commit 1e9e2a4

Browse files
simonjayhawkinsproost
authored andcommitted
CLN: various lgtm.com cleanups (pandas-dev#30258)
1 parent bdb8783 commit 1e9e2a4

File tree

19 files changed

+56
-21
lines changed

19 files changed

+56
-21
lines changed

pandas/core/apply.py

-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ def apply_series_generator(self) -> Tuple[ResType, "Index"]:
320320
series_gen = self.series_generator
321321
res_index = self.result_index
322322

323-
i = None
324323
keys = []
325324
results = {}
326325
if self.ignore_failures:

pandas/core/arrays/datetimes.py

-1
Original file line numberDiff line numberDiff line change
@@ -2109,7 +2109,6 @@ def _validate_dt64_dtype(dtype):
21092109
dtype = pandas_dtype(dtype)
21102110
if is_dtype_equal(dtype, np.dtype("M8")):
21112111
# no precision, disallowed GH#24806
2112-
dtype = _NS_DTYPE
21132112
msg = (
21142113
"Passing in 'datetime64' dtype with no precision is not allowed. "
21152114
"Please pass in 'datetime64[ns]' instead."

pandas/core/arrays/integer.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def itemsize(self):
7878

7979
@classmethod
8080
def construct_array_type(cls):
81-
"""Return the array type associated with this dtype
81+
"""
82+
Return the array type associated with this dtype.
8283
8384
Returns
8485
-------

pandas/core/arrays/numpy_.py

+8
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ def construct_from_string(cls, string):
7979
f"Cannot construct a 'PandasDtype' from '{string}'"
8080
) from err
8181

82+
@classmethod
8283
def construct_array_type(cls):
84+
"""
85+
Return the array type associated with this dtype.
86+
87+
Returns
88+
-------
89+
type
90+
"""
8391
return PandasArray
8492

8593
@property

pandas/core/arrays/sparse/dtype.py

+7
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ def __repr__(self) -> str:
168168

169169
@classmethod
170170
def construct_array_type(cls):
171+
"""
172+
Return the array type associated with this dtype.
173+
174+
Returns
175+
-------
176+
type
177+
"""
171178
from .array import SparseArray
172179

173180
return SparseArray

pandas/core/arrays/timedeltas.py

-1
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,6 @@ def _validate_td64_dtype(dtype):
11221122
dtype = pandas_dtype(dtype)
11231123
if is_dtype_equal(dtype, np.dtype("timedelta64")):
11241124
# no precision disallowed GH#24806
1125-
dtype = _TD_DTYPE
11261125
msg = (
11271126
"Passing in 'timedelta' dtype with no precision is not allowed. "
11281127
"Please pass in 'timedelta64[ns]' instead."

pandas/core/dtypes/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def names(self) -> Optional[List[str]]:
183183
@classmethod
184184
def construct_array_type(cls):
185185
"""
186-
Return the array type associated with this dtype
186+
Return the array type associated with this dtype.
187187
188188
Returns
189189
-------

pandas/core/dtypes/dtypes.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ def _hash_categories(categories, ordered: Ordered = True) -> int:
486486
@classmethod
487487
def construct_array_type(cls):
488488
"""
489-
Return the array type associated with this dtype
489+
Return the array type associated with this dtype.
490490
491491
Returns
492492
-------
@@ -668,7 +668,7 @@ def __init__(self, unit="ns", tz=None):
668668
unit = result.unit
669669
tz = result.tz
670670
msg = (
671-
"Passing a dtype alias like 'datetime64[ns, {tz}]' "
671+
f"Passing a dtype alias like 'datetime64[ns, {tz}]' "
672672
"to DatetimeTZDtype is no longer supported. Use "
673673
"'DatetimeTZDtype.construct_from_string()' instead."
674674
)
@@ -704,7 +704,7 @@ def tz(self):
704704
@classmethod
705705
def construct_array_type(cls):
706706
"""
707-
Return the array type associated with this dtype
707+
Return the array type associated with this dtype.
708708
709709
Returns
710710
-------
@@ -936,6 +936,13 @@ def is_dtype(cls, dtype) -> bool:
936936

937937
@classmethod
938938
def construct_array_type(cls):
939+
"""
940+
Return the array type associated with this dtype.
941+
942+
Returns
943+
-------
944+
type
945+
"""
939946
from pandas.core.arrays import PeriodArray
940947

941948
return PeriodArray
@@ -1030,7 +1037,7 @@ def subtype(self):
10301037
@classmethod
10311038
def construct_array_type(cls):
10321039
"""
1033-
Return the array type associated with this dtype
1040+
Return the array type associated with this dtype.
10341041
10351042
Returns
10361043
-------

pandas/core/frame.py

-1
Original file line numberDiff line numberDiff line change
@@ -2587,7 +2587,6 @@ def _ixs(self, i: int, axis: int = 0):
25872587
"""
25882588
# irow
25892589
if axis == 0:
2590-
label = self.index[i]
25912590
new_values = self._data.fast_xs(i)
25922591

25932592
# if we are a copy, mark as such

pandas/core/generic.py

-2
Original file line numberDiff line numberDiff line change
@@ -5746,8 +5746,6 @@ def __deepcopy__(self: FrameOrSeries, memo=None) -> FrameOrSeries:
57465746
memo, default None
57475747
Standard signature. Unused
57485748
"""
5749-
if memo is None:
5750-
memo = {}
57515749
return self.copy(deep=True)
57525750

57535751
def _convert(

pandas/core/groupby/grouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def _get_grouper(self, obj, validate: bool = True):
131131
"""
132132

133133
self._set_grouper(obj)
134-
self.grouper, exclusions, self.obj = get_grouper(
134+
self.grouper, _, self.obj = get_grouper(
135135
self.obj,
136136
[self.key],
137137
axis=self.axis,

pandas/core/indexes/base.py

-2
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,6 @@ def __deepcopy__(self, memo=None):
911911
memo, default None
912912
Standard signature. Unused
913913
"""
914-
if memo is None:
915-
memo = {}
916914
return self.copy(deep=True)
917915

918916
# --------------------------------------------------------------------

pandas/core/internals/blocks.py

-1
Original file line numberDiff line numberDiff line change
@@ -3024,7 +3024,6 @@ def _merge_blocks(blocks, dtype=None, _can_consolidate=True):
30243024
if dtype is None:
30253025
if len({b.dtype for b in blocks}) != 1:
30263026
raise AssertionError("_merge_blocks are invalid!")
3027-
dtype = blocks[0].dtype
30283027

30293028
# FIXME: optimization potential in case all mgrs contain slices and
30303029
# combination of those slices is a slice, too.

pandas/core/reshape/reshape.py

-2
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,9 @@ def get_new_values(self):
230230
if needs_i8_conversion(values):
231231
sorted_values = sorted_values.view("i8")
232232
new_values = new_values.view("i8")
233-
name = "int64"
234233
elif is_bool_dtype(values):
235234
sorted_values = sorted_values.astype("object")
236235
new_values = new_values.astype("object")
237-
name = "object"
238236
else:
239237
sorted_values = sorted_values.astype(name, copy=False)
240238

pandas/plotting/_matplotlib/hist.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _args_adjust(self):
2727
values = np.ravel(values)
2828
values = values[~isna(values)]
2929

30-
hist, self.bins = np.histogram(
30+
_, self.bins = np.histogram(
3131
values,
3232
bins=self.bins,
3333
range=self.kwds.get("range", None),

pandas/tests/arrays/test_array.py

+7
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ class DecimalDtype2(DecimalDtype):
287287

288288
@classmethod
289289
def construct_array_type(cls):
290+
"""
291+
Return the array type associated with this dtype.
292+
293+
Returns
294+
-------
295+
type
296+
"""
290297
return DecimalArray2
291298

292299

pandas/tests/extension/arrow/arrays.py

+14
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ def construct_from_string(cls, string):
3737

3838
@classmethod
3939
def construct_array_type(cls):
40+
"""
41+
Return the array type associated with this dtype.
42+
43+
Returns
44+
-------
45+
type
46+
"""
4047
return ArrowBoolArray
4148

4249
def _is_boolean(self):
@@ -60,6 +67,13 @@ def construct_from_string(cls, string):
6067

6168
@classmethod
6269
def construct_array_type(cls):
70+
"""
71+
Return the array type associated with this dtype.
72+
73+
Returns
74+
-------
75+
type
76+
"""
6377
return ArrowStringArray
6478

6579

pandas/tests/extension/decimal/array.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def __repr__(self) -> str:
2727

2828
@classmethod
2929
def construct_array_type(cls):
30-
"""Return the array type associated with this dtype
30+
"""
31+
Return the array type associated with this dtype.
3132
3233
Returns
3334
-------

pandas/tests/extension/json/array.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class JSONDtype(ExtensionDtype):
3131

3232
@classmethod
3333
def construct_array_type(cls):
34-
"""Return the array type associated with this dtype
34+
"""
35+
Return the array type associated with this dtype.
3536
3637
Returns
3738
-------

0 commit comments

Comments
 (0)