Skip to content

STYLE: Enable unnecessary list index lookup #49911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4368,7 +4368,7 @@ def write_data(self, chunksize: int | None, dropna: bool = False) -> None:
bvalues = []
for i, v in enumerate(values):
new_shape = (nrows,) + self.dtype[names[nindexes + i]].shape
bvalues.append(values[i].reshape(new_shape))
bvalues.append(v.reshape(new_shape))

# write the chunks
if chunksize is None:
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/indexes/datetimes/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_iteration_preserves_tz(self):

for i, ts in enumerate(index):
result = ts
expected = index[i]
expected = index[i] # pylint: disable=unnecessary-list-index-lookup
assert result == expected

index = date_range(
Expand All @@ -107,7 +107,7 @@ def test_iteration_preserves_tz(self):

for i, ts in enumerate(index):
result = ts
expected = index[i]
expected = index[i] # pylint: disable=unnecessary-list-index-lookup
assert result._repr_base == expected._repr_base
assert result == expected

Expand All @@ -117,7 +117,7 @@ def test_iteration_preserves_tz(self):
)
for i, ts in enumerate(index):
result = ts
expected = index[i]
expected = index[i] # pylint: disable=unnecessary-list-index-lookup
assert result._repr_base == expected._repr_base
assert result == expected

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/indexes/datetimes/test_timezones.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,7 @@ def test_iteration_preserves_nanoseconds(self, tz):
["2018-02-08 15:00:00.168456358", "2018-02-08 15:00:00.168456359"], tz=tz
)
for i, ts in enumerate(index):
assert ts == index[i]
assert ts == index[i] # pylint: disable=unnecessary-list-index-lookup


def test_tz_localize_invalidates_freq():
Expand Down
2 changes: 2 additions & 0 deletions pandas/tests/series/test_iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ def test_keys(self, datetime_series):

def test_iter_datetimes(self, datetime_series):
for i, val in enumerate(datetime_series):
# pylint: disable-next=unnecessary-list-index-lookup
assert val == datetime_series[i]

def test_iter_strings(self, string_series):
for i, val in enumerate(string_series):
# pylint: disable-next=unnecessary-list-index-lookup
assert val == string_series[i]

def test_iteritems_datetimes(self, datetime_series):
Expand Down
6 changes: 2 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ exclude = '''
max-line-length = 88
disable = [
# intentionally turned off
"broad-except",
"c-extension-no-member",
"comparison-with-itself",
"import-error",
Expand All @@ -72,6 +73,7 @@ disable = [
"no-member",
"no-name-in-module",
"not-an-iterable",
"overridden-final-method",
"pointless-statement",
"redundant-keyword-arg",
"singleton-comparison",
Expand All @@ -95,7 +97,6 @@ disable = [
"use-implicit-booleaness-not-comparison",
"use-implicit-booleaness-not-len",
"wrong-import-order",
"wrong-import-order",
"wrong-import-position",

# misc
Expand All @@ -122,15 +123,13 @@ disable = [
"inconsistent-return-statements",
"redefined-argument-from-local",
"too-few-public-methods",
"unnecessary-list-index-lookup",

# pylint type "W": warning, for python specific problems
"abstract-method",
"arguments-differ",
"arguments-out-of-order",
"arguments-renamed",
"attribute-defined-outside-init",
"broad-except",
"comparison-with-callable",
"dangerous-default-value",
"deprecated-module",
Expand All @@ -140,7 +139,6 @@ disable = [
"global-statement",
"invalid-overridden-method",
"keyword-arg-before-vararg",
"overridden-final-method",
"pointless-string-statement",
"possibly-unused-variable",
"protected-access",
Expand Down