Skip to content

Commit

Permalink
Apply ruff/flake8-comprehensions rule C420
Browse files Browse the repository at this point in the history
C420 Unnecessary dict comprehension for iterable; use `dict.fromkeys` instead
  • Loading branch information
DimitriPapadopoulos committed Jan 5, 2025
1 parent 2e7afb5 commit af9e60c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions setuptools/tests/config/test_expand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setuptools/tests/test_glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit af9e60c

Please sign in to comment.