From af9e60cce58f16f43e14cad2525eb94eb0ba681f Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:55:01 +0100 Subject: [PATCH] Apply ruff/flake8-comprehensions rule C420 C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead --- setuptools/tests/config/test_expand.py | 6 +++--- setuptools/tests/test_glob.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/setuptools/tests/config/test_expand.py b/setuptools/tests/config/test_expand.py index fa9122b32c..52ca3f0c01 100644 --- a/setuptools/tests/config/test_expand.py +++ b/setuptools/tests/config/test_expand.py @@ -28,7 +28,7 @@ def test_glob_relative(tmp_path, monkeypatch): "dir1/dir2/a.ini", } - write_files({k: "" for k in files}, tmp_path) + write_files(dict.fromkeys(files, ""), tmp_path) patterns = ["**/*.txt", "[ab].*", "**/[ac].ini"] monkeypatch.chdir(tmp_path) assert set(expand.glob_relative(patterns)) == files @@ -172,7 +172,7 @@ def test_find_packages(tmp_path, args, pkgs): "other/__init__.py", "dir1/dir2/__init__.py", } - write_files({k: "" for k in files}, tmp_path) + write_files(dict.fromkeys(files, ""), tmp_path) package_dir = {} kwargs = {"root_dir": tmp_path, "fill_package_dir": package_dir, **args} @@ -211,7 +211,7 @@ def test_find_packages(tmp_path, args, pkgs): ], ) def test_fill_package_dir(tmp_path, files, where, expected_package_dir): - write_files({k: "" for k in files}, tmp_path) + write_files(dict.fromkeys(files, ""), tmp_path) pkg_dir = {} kwargs = {"root_dir": tmp_path, "fill_package_dir": pkg_dir, "namespaces": False} pkgs = expand.find_packages(where=where, **kwargs) diff --git a/setuptools/tests/test_glob.py b/setuptools/tests/test_glob.py index 0cb87092a2..8805e2f663 100644 --- a/setuptools/tests/test_glob.py +++ b/setuptools/tests/test_glob.py @@ -41,5 +41,5 @@ ) def test_glob(monkeypatch, tmpdir, tree, pattern, matches): monkeypatch.chdir(tmpdir) - path.build({name: '' for name in tree.split()}) + path.build(dict.fromkeys(tree.split(), '')) assert sorted(glob(pattern)) == sorted(matches)