Skip to content

STYLE: fix pylint consider-using-dict-items warnings #49243

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 1 commit into from
Oct 24, 2022
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
6 changes: 3 additions & 3 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def index(request):

@pytest.fixture(
params=[
key for key in indices_dict if not isinstance(indices_dict[key], MultiIndex)
key for key, value in indices_dict.items() if not isinstance(value, MultiIndex)
]
)
def index_flat(request):
Expand All @@ -671,12 +671,12 @@ def index_flat(request):
@pytest.fixture(
params=[
key
for key in indices_dict
for key, value in indices_dict.items()
if not (
key in ["int", "uint", "range", "empty", "repeats", "bool-dtype"]
or key.startswith("num_")
)
and not isinstance(indices_dict[key], MultiIndex)
and not isinstance(value, MultiIndex)
]
)
def index_with_missing(request):
Expand Down
3 changes: 1 addition & 2 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,9 +1646,8 @@ def _clean_options(

validate_header_arg(options["header"])

for arg in _deprecated_defaults.keys():
for arg, depr_default in _deprecated_defaults.items():
parser_default = _c_parser_defaults.get(arg, parser_defaults[arg])
depr_default = _deprecated_defaults[arg]
if result.get(arg, depr_default) != depr_default.default_value:
msg = (
f"The {arg} argument has been deprecated and will be "
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,8 +1853,8 @@ def _do_convert_missing(self, data: DataFrame, convert_missing: bool) -> DataFra
replacements[colname] = replacement

if replacements:
for col in replacements:
data[col] = replacements[col]
for col, value in replacements.items():
data[col] = value
return data

def _insert_strls(self, data: DataFrame) -> DataFrame:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/methods/test_astype.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_astype_categorical(self, dtype):
d = {"A": list("abbc"), "B": list("bccd"), "C": list("cdde")}
df = DataFrame(d)
result = df.astype(dtype)
expected = DataFrame({k: Categorical(d[k], dtype=dtype) for k in d})
expected = DataFrame({k: Categorical(v, dtype=dtype) for k, v in d.items()})
tm.assert_frame_equal(result, expected)

@pytest.mark.parametrize("cls", [CategoricalDtype, DatetimeTZDtype, IntervalDtype])
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/plotting/frame/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1827,11 +1827,11 @@ def test_memory_leak(self):
# force a garbage collection
gc.collect()
msg = "weakly-referenced object no longer exists"
for key in results:
for result_value in results.values():
# check that every plot was collected
with pytest.raises(ReferenceError, match=msg):
# need to actually access something to get an error
results[key].lines
result_value.lines

def test_df_gridspec_patterns(self):
# GH 10819
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ disable = [

# pylint type "C": convention, for programming standard violation
"consider-iterating-dictionary",
"consider-using-dict-items",
"consider-using-f-string",
"disallowed-name",
"import-outside-toplevel",
Expand Down