Skip to content

Commit af9e60c

Browse files
Apply ruff/flake8-comprehensions rule C420
C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
1 parent 2e7afb5 commit af9e60c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: setuptools/tests/config/test_expand.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_glob_relative(tmp_path, monkeypatch):
2828
"dir1/dir2/a.ini",
2929
}
3030

31-
write_files({k: "" for k in files}, tmp_path)
31+
write_files(dict.fromkeys(files, ""), tmp_path)
3232
patterns = ["**/*.txt", "[ab].*", "**/[ac].ini"]
3333
monkeypatch.chdir(tmp_path)
3434
assert set(expand.glob_relative(patterns)) == files
@@ -172,7 +172,7 @@ def test_find_packages(tmp_path, args, pkgs):
172172
"other/__init__.py",
173173
"dir1/dir2/__init__.py",
174174
}
175-
write_files({k: "" for k in files}, tmp_path)
175+
write_files(dict.fromkeys(files, ""), tmp_path)
176176

177177
package_dir = {}
178178
kwargs = {"root_dir": tmp_path, "fill_package_dir": package_dir, **args}
@@ -211,7 +211,7 @@ def test_find_packages(tmp_path, args, pkgs):
211211
],
212212
)
213213
def test_fill_package_dir(tmp_path, files, where, expected_package_dir):
214-
write_files({k: "" for k in files}, tmp_path)
214+
write_files(dict.fromkeys(files, ""), tmp_path)
215215
pkg_dir = {}
216216
kwargs = {"root_dir": tmp_path, "fill_package_dir": pkg_dir, "namespaces": False}
217217
pkgs = expand.find_packages(where=where, **kwargs)

Diff for: setuptools/tests/test_glob.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
)
4242
def test_glob(monkeypatch, tmpdir, tree, pattern, matches):
4343
monkeypatch.chdir(tmpdir)
44-
path.build({name: '' for name in tree.split()})
44+
path.build(dict.fromkeys(tree.split(), ''))
4545
assert sorted(glob(pattern)) == sorted(matches)

0 commit comments

Comments
 (0)