Skip to content

Commit 319be7d

Browse files
committed
Refactor file_utils to fix lint and test erorrs
1 parent b105302 commit 319be7d

File tree

2 files changed

+6
-173
lines changed

2 files changed

+6
-173
lines changed

comfy_cli/file_utils.py

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@ def _load_comfyignore_spec(ignore_filename: str = ".comfyignore") -> Optional[Pa
9393
return None
9494
try:
9595
with open(ignore_filename, encoding="utf-8") as ignore_file:
96-
patterns = [
97-
line.strip()
98-
for line in ignore_file
99-
if line.strip() and not line.lstrip().startswith("#")
100-
]
96+
patterns = [line.strip() for line in ignore_file if line.strip() and not line.lstrip().startswith("#")]
10197
except OSError:
10298
return None
10399

@@ -127,20 +123,13 @@ def _normalize_path(path: str) -> str:
127123

128124

129125
def _is_force_included(rel_path: str, include_prefixes: list[str]) -> bool:
130-
return any(
131-
rel_path == prefix or rel_path.startswith(prefix + "/")
132-
for prefix in include_prefixes
133-
if prefix
134-
)
126+
return any(rel_path == prefix or rel_path.startswith(prefix + "/") for prefix in include_prefixes if prefix)
135127

136128

137129
def zip_files(zip_filename, includes=None):
138130
"""Zip git-tracked files respecting optional .comfyignore patterns."""
139131
includes = includes or []
140-
include_prefixes: list[str] = [
141-
_normalize_path(os.path.normpath(include.lstrip("/")))
142-
for include in includes
143-
]
132+
include_prefixes: list[str] = [_normalize_path(os.path.normpath(include.lstrip("/"))) for include in includes]
144133

145134
included_paths: set[str] = set()
146135
git_files: list[str] = []
@@ -185,11 +174,7 @@ def should_ignore(rel_path: str) -> bool:
185174
for root, dirs, files in os.walk("."):
186175
if ".git" in dirs:
187176
dirs.remove(".git")
188-
dirs[:] = [
189-
d
190-
for d in dirs
191-
if not should_ignore(_normalize_path(os.path.join(root, d)))
192-
]
177+
dirs[:] = [d for d in dirs if not should_ignore(_normalize_path(os.path.join(root, d)))]
193178
for file in files:
194179
file_path = os.path.join(root, file)
195180
rel_path = _normalize_path(file_path)
@@ -215,21 +200,15 @@ def should_ignore(rel_path: str) -> bool:
215200
continue
216201

217202
if not os.path.exists(include_dir):
218-
print(
219-
f"Warning: Included directory '{include_dir}' does not exist, creating empty directory"
220-
)
203+
print(f"Warning: Included directory '{include_dir}' does not exist, creating empty directory")
221204
arcname = rel_include or include_dir
222205
if not arcname.endswith("/"):
223206
arcname = arcname + "/"
224207
zipf.writestr(arcname, "")
225208
continue
226209

227210
for root, dirs, files in os.walk(include_dir):
228-
dirs[:] = [
229-
d
230-
for d in dirs
231-
if not should_ignore(_normalize_path(os.path.join(root, d)))
232-
]
211+
dirs[:] = [d for d in dirs if not should_ignore(_normalize_path(os.path.join(root, d)))]
233212
for file in files:
234213
file_path = os.path.join(root, file)
235214
rel_path = _normalize_path(file_path)

tests/test_file_utils.py

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)