Skip to content

Commit aa2c27f

Browse files
simonjayhawkinsjreback
authored andcommitted
CLN: more lgtm.com cleanups (#30259)
1 parent 46a4573 commit aa2c27f

File tree

8 files changed

+6
-35
lines changed

8 files changed

+6
-35
lines changed

pandas/core/arrays/_ranges.py

-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def _generate_range_overflow_safe_signed(
179179
# watch out for very special case in which we just slightly
180180
# exceed implementation bounds, but when passing the result to
181181
# np.arange will get a result slightly within the bounds
182-
assert endpoint >= 0
183182
result = np.uint64(endpoint) + np.uint64(addend)
184183
i64max = np.uint64(np.iinfo(np.int64).max)
185184
assert result > i64max

pandas/core/base.py

+1-19
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def _aggregate(self, arg, *args, **kwargs):
309309
None if not required
310310
"""
311311
is_aggregator = lambda x: isinstance(x, (list, tuple, dict))
312-
is_nested_renamer = False
313312

314313
_axis = kwargs.pop("_axis", None)
315314
if _axis is None:
@@ -398,24 +397,7 @@ def _agg(arg, func):
398397
keys = list(arg.keys())
399398
result = OrderedDict()
400399

401-
# nested renamer
402-
if is_nested_renamer:
403-
result = list(_agg(arg, _agg_1dim).values())
404-
405-
if all(isinstance(r, dict) for r in result):
406-
407-
result, results = OrderedDict(), result
408-
for r in results:
409-
result.update(r)
410-
keys = list(result.keys())
411-
412-
else:
413-
414-
if self._selection is not None:
415-
keys = None
416-
417-
# some selection on the object
418-
elif self._selection is not None:
400+
if self._selection is not None:
419401

420402
sl = set(self._selection_list)
421403

pandas/core/groupby/generic.py

-5
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,6 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
11311131
obj = self._obj_with_exclusions
11321132
result: OrderedDict = OrderedDict()
11331133
cannot_agg = []
1134-
errors = None
11351134
for item in obj:
11361135
data = obj[item]
11371136
colg = SeriesGroupBy(data, selection=item, grouper=self.grouper)
@@ -1157,10 +1156,6 @@ def _aggregate_item_by_item(self, func, *args, **kwargs) -> DataFrame:
11571156
if cannot_agg:
11581157
result_columns = result_columns.drop(cannot_agg)
11591158

1160-
# GH6337
1161-
if not len(result_columns) and errors is not None:
1162-
raise errors
1163-
11641159
return DataFrame(result, columns=result_columns)
11651160

11661161
def _wrap_applied_output(self, keys, values, not_indexed_same=False):

pandas/core/indexes/multi.py

-3
Original file line numberDiff line numberDiff line change
@@ -2195,9 +2195,6 @@ def reorder_levels(self, order):
21952195
levels=new_levels, codes=new_codes, names=new_names, verify_integrity=False
21962196
)
21972197

2198-
def __getslice__(self, i, j):
2199-
return self.__getitem__(slice(i, j))
2200-
22012198
def _get_codes_for_sorting(self):
22022199
"""
22032200
we categorizing our codes by using the

pandas/core/internals/concat.py

-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ def get_reindexed_values(self, empty_dtype, upcasted_na):
195195
return array(
196196
np.full(self.shape[1], fill_value.value), dtype=empty_dtype
197197
)
198-
pass
199198
elif getattr(self.block, "is_categorical", False):
200199
pass
201200
elif getattr(self.block, "is_extension", False):

pandas/core/ops/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def dispatch_fill_zeros(op, left, right, result):
168168
# Note: no need to do this for truediv; in py3 numpy behaves the way
169169
# we want.
170170
result = mask_zero_div_zero(left, right, result)
171-
elif op is op is rfloordiv:
171+
elif op is rfloordiv:
172172
# Note: no need to do this for rtruediv; in py3 numpy behaves the way
173173
# we want.
174174
result = mask_zero_div_zero(right, left, result)

pandas/plotting/_matplotlib/converter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,12 @@ def __call__(self):
386386
except ValueError:
387387
return []
388388

389-
if dmin > dmax:
390-
dmax, dmin = dmin, dmax
391389
# We need to cap at the endpoints of valid datetime
392390

393391
# FIXME: dont leave commented-out
394392
# TODO(wesm) unused?
393+
# if dmin > dmax:
394+
# dmax, dmin = dmin, dmax
395395
# delta = relativedelta(dmax, dmin)
396396
# try:
397397
# start = dmin - delta

scripts/validate_docstrings.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ def header(title, width=80, char="#"):
965965
"]{text}\n"
966966
)
967967
else:
968-
raise ValueError('Unknown output_format "{}"'.format(output_format))
968+
raise ValueError(f'Unknown output_format "{output_format}"')
969969

970970
output = ""
971971
for name, res in result.items():
@@ -977,11 +977,10 @@ def header(title, width=80, char="#"):
977977
continue
978978
exit_status += 1
979979
output += output_format.format(
980-
name=name,
981980
path=res["file"],
982981
row=res["file_line"],
983982
code=err_code,
984-
text="{}: {}".format(name, err_desc),
983+
text=f"{name}: {err_desc}",
985984
)
986985

987986
sys.stdout.write(output)

0 commit comments

Comments
 (0)