Skip to content

Commit 95144f0

Browse files
Apply ruff/flake8-comprehensions rule C420
C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
1 parent 31d55e8 commit 95144f0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

setuptools/tests/config/test_expand.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_glob_relative(tmp_path, monkeypatch):
2929
"dir1/dir2/a.ini",
3030
}
3131

32-
write_files({k: "" for k in files}, tmp_path)
32+
write_files(dict.fromkeys(files, ""), tmp_path)
3333
patterns = ["**/*.txt", "[ab].*", "**/[ac].ini"]
3434
monkeypatch.chdir(tmp_path)
3535
assert set(expand.glob_relative(patterns)) == files
@@ -198,7 +198,7 @@ def test_find_packages(tmp_path, args, pkgs):
198198
"other/__init__.py",
199199
"dir1/dir2/__init__.py",
200200
}
201-
write_files({k: "" for k in files}, tmp_path)
201+
write_files(dict.fromkeys(files, ""), tmp_path)
202202

203203
package_dir = {}
204204
kwargs = {"root_dir": tmp_path, "fill_package_dir": package_dir, **args}
@@ -237,7 +237,7 @@ def test_find_packages(tmp_path, args, pkgs):
237237
],
238238
)
239239
def test_fill_package_dir(tmp_path, files, where, expected_package_dir):
240-
write_files({k: "" for k in files}, tmp_path)
240+
write_files(dict.fromkeys(files, ""), tmp_path)
241241
pkg_dir = {}
242242
kwargs = {"root_dir": tmp_path, "fill_package_dir": pkg_dir, "namespaces": False}
243243
pkgs = expand.find_packages(where=where, **kwargs)

setuptools/tests/test_glob.py

Lines changed: 1 addition & 1 deletion
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)