diff --git a/pandas/conftest.py b/pandas/conftest.py index 074b6068a4518..0282278183dd3 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -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): @@ -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): diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py index 81ffa74693156..abd1182214f5f 100644 --- a/pandas/io/parsers/readers.py +++ b/pandas/io/parsers/readers.py @@ -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 " diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 037aeb5339818..5e9b70aeb2a82 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -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: diff --git a/pandas/tests/frame/methods/test_astype.py b/pandas/tests/frame/methods/test_astype.py index 69087b6822f2e..8e6aa43ff434c 100644 --- a/pandas/tests/frame/methods/test_astype.py +++ b/pandas/tests/frame/methods/test_astype.py @@ -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]) diff --git a/pandas/tests/plotting/frame/test_frame.py b/pandas/tests/plotting/frame/test_frame.py index 06e04f06c38d1..44f57b02d0f0a 100644 --- a/pandas/tests/plotting/frame/test_frame.py +++ b/pandas/tests/plotting/frame/test_frame.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index f18b54a8dcd03..236d944b0c954 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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",