diff --git a/src/pdm/cli/templates/__init__.py b/src/pdm/cli/templates/__init__.py index f2b55ee844..e46a9a5f19 100644 --- a/src/pdm/cli/templates/__init__.py +++ b/src/pdm/cli/templates/__init__.py @@ -59,9 +59,10 @@ def replace_all(path: str, old: str, new: str) -> None: import_name = normalize_name(original_name).replace("-", "_") encoding = "utf-8" for root, dirs, filenames in os.walk(self._path): - for d in dirs: + for i, d in enumerate(dirs): if d == import_name: os.rename(os.path.join(root, d), os.path.join(root, new_import_name)) + dirs[i] = new_import_name for f in filenames: if f.endswith(".py"): replace_all(os.path.join(root, f), import_name, new_import_name)