Skip to content

Commit f7acab8

Browse files
author
coderfromthenorth93
committed
fix ruff formatting
1 parent 5715763 commit f7acab8

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

comfy_cli/registry/config_parser.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,43 +93,43 @@ def validate_and_extract_os_classifiers(classifiers: list) -> list:
9393
if not os_classifiers:
9494
return []
9595

96-
os_values = [c[len("Operating System :: "):] for c in os_classifiers]
96+
os_values = [c[len("Operating System :: ") :] for c in os_classifiers]
9797
valid_os_prefixes = {"Microsoft", "POSIX", "MacOS", "OS Independent"}
98-
98+
9999
for os_value in os_values:
100100
if not any(os_value.startswith(prefix) for prefix in valid_os_prefixes):
101101
typer.echo(
102102
'Warning: Invalid Operating System classifier found. Operating System classifiers must start with one of: "Microsoft", "POSIX", "MacOS", "OS Independent". '
103103
'Examples: "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Operating System :: OS Independent". '
104-
'No OS information will be populated.'
104+
"No OS information will be populated."
105105
)
106106
return []
107107

108108
return os_values
109109

110110

111-
def validate_and_extract_accelerator_classifiers(classifiers: list) -> list:
111+
def validate_and_extract_accelerator_classifiers(classifiers: list) -> list:
112112
accelerator_classifiers = [c for c in classifiers if c.startswith("Environment ::")]
113113
if not accelerator_classifiers:
114114
return []
115-
116-
accelerator_values = [c[len("Environment :: "):] for c in accelerator_classifiers]
117-
115+
116+
accelerator_values = [c[len("Environment :: ") :] for c in accelerator_classifiers]
117+
118118
valid_accelerators = {
119119
"GPU :: NVIDIA CUDA",
120120
"GPU :: AMD ROCm",
121-
"GPU :: Intel Arc",
121+
"GPU :: Intel Arc",
122122
"NPU :: Huawei Ascend",
123123
"GPU :: Apple Metal",
124124
}
125125

126126
for accelerator_value in accelerator_values:
127127
if accelerator_value not in valid_accelerators:
128128
typer.echo(
129-
'Warning: Invalid Environment classifier found. Environment classifiers must be one of: '
129+
"Warning: Invalid Environment classifier found. Environment classifiers must be one of: "
130130
'"Environment :: GPU :: NVIDIA CUDA", "Environment :: GPU :: AMD ROCm", "Environment :: GPU :: Intel Arc", '
131131
'"Environment :: NPU :: Huawei Ascend", "Environment :: GPU :: Apple Metal". '
132-
'No accelerator information will be populated.'
132+
"No accelerator information will be populated."
133133
)
134134
return []
135135

@@ -140,21 +140,21 @@ def validate_version(version: str, field_name: str) -> str:
140140
if not version:
141141
return version
142142

143-
version_pattern = r'^(?:(==|>=|<=|!=|~=|>|<|<>|=)\s*)?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?)?$'
143+
version_pattern = r"^(?:(==|>=|<=|!=|~=|>|<|<>|=)\s*)?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?)?$"
144144

145-
version_parts = [part.strip() for part in version.split(',')]
145+
version_parts = [part.strip() for part in version.split(",")]
146146
for part in version_parts:
147147
if not re.match(version_pattern, part):
148148
typer.echo(
149149
f'Warning: Invalid {field_name} format: "{version}". '
150-
f'Each version part must follow the pattern: [operator][version] where operator is optional (==, >=, <=, !=, ~=, >, <, <>, =) '
151-
f'and version is in format major.minor.patch[-suffix]. '
152-
f'Multiple versions can be comma-separated. '
150+
f"Each version part must follow the pattern: [operator][version] where operator is optional (==, >=, <=, !=, ~=, >, <, <>, =) "
151+
f"and version is in format major.minor.patch[-suffix]. "
152+
f"Multiple versions can be comma-separated. "
153153
f'Examples: ">=1.0.0", "==2.1.0-beta", "1.5.2", ">=1.0.0,<2.0.0". '
154-
f'No {field_name} will be populated.'
154+
f"No {field_name} will be populated."
155155
)
156156
return ""
157-
157+
158158
return version
159159

160160

@@ -246,7 +246,9 @@ def extract_node_configuration(
246246
supported_os = validate_and_extract_os_classifiers(classifiers)
247247
supported_accelerators = validate_and_extract_accelerator_classifiers(classifiers)
248248
supported_comfyui_version = validate_version(supported_comfyui_version, "requires-comfyui")
249-
supported_comfyui_frontend_version = validate_version(supported_comfyui_frontend_version, "comfyui-frontend-package")
249+
supported_comfyui_frontend_version = validate_version(
250+
supported_comfyui_frontend_version, "comfyui-frontend-package"
251+
)
250252

251253
license_data = project_data.get("license", {})
252254
if isinstance(license_data, str):

comfy_cli/registry/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class ProjectConfig:
7474
supported_comfyui_version: str = ""
7575
supported_comfyui_frontend_version: str = ""
7676

77+
7778
@dataclass
7879
class PyProjectConfig:
7980
project: ProjectConfig = field(default_factory=ProjectConfig)

tests/comfy_cli/registry/test_config_parser.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_extract_license_incorrect_format():
133133
assert isinstance(result, PyProjectConfig)
134134
assert result.project.license == License(text="MIT")
135135

136+
136137
def test_extract_node_configuration_with_os_classifiers():
137138
mock_data = {
138139
"project": {
@@ -216,6 +217,7 @@ def test_extract_node_configuration_with_requires_comfyui():
216217
assert result is not None
217218
assert result.project.supported_comfyui_version == "2.0.0"
218219

220+
219221
def test_validate_and_extract_os_classifiers_valid():
220222
"""Test OS validation with valid classifiers."""
221223
classifiers = [
@@ -229,7 +231,8 @@ def test_validate_and_extract_os_classifiers_valid():
229231
expected = ["Microsoft :: Windows", "POSIX :: Linux", "MacOS", "OS Independent"]
230232
assert result == expected
231233

232-
@patch('typer.echo')
234+
235+
@patch("typer.echo")
233236
def test_validate_and_extract_os_classifiers_invalid(mock_echo):
234237
"""Test OS validation with invalid classifiers."""
235238
classifiers = [
@@ -254,11 +257,17 @@ def test_validate_and_extract_accelerator_classifiers_valid():
254257
"Programming Language :: Python :: 3",
255258
]
256259
result = validate_and_extract_accelerator_classifiers(classifiers)
257-
expected = ["GPU :: NVIDIA CUDA", "GPU :: AMD ROCm", "GPU :: Intel Arc", "NPU :: Huawei Ascend", "GPU :: Apple Metal"]
260+
expected = [
261+
"GPU :: NVIDIA CUDA",
262+
"GPU :: AMD ROCm",
263+
"GPU :: Intel Arc",
264+
"NPU :: Huawei Ascend",
265+
"GPU :: Apple Metal",
266+
]
258267
assert result == expected
259268

260269

261-
@patch('typer.echo')
270+
@patch("typer.echo")
262271
def test_validate_and_extract_accelerator_classifiers_invalid(mock_echo):
263272
"""Test accelerator validation with invalid classifiers."""
264273
classifiers = [
@@ -293,13 +302,13 @@ def test_validate_version_valid():
293302
"1.0.0,2.0.0",
294303
">1.0.0,<2.0.0,!=1.5.0-beta",
295304
]
296-
305+
297306
for version in valid_versions:
298307
result = validate_version(version, "test_field")
299308
assert result == version, f"Version {version} should be valid"
300309

301310

302-
@patch('typer.echo')
311+
@patch("typer.echo")
303312
def test_validate_version_invalid(mock_echo):
304313
"""Test version validation with invalid versions."""
305314
invalid_versions = [
@@ -312,9 +321,9 @@ def test_validate_version_invalid(mock_echo):
312321
"1.0,2.0.0",
313322
">=1.0.0,>=abc",
314323
]
315-
324+
316325
for version in invalid_versions:
317326
result = validate_version(version, "test_field")
318327
assert result == "", f"Version {version} should be invalid"
319-
328+
320329
assert mock_echo.call_count == len(invalid_versions)

0 commit comments

Comments
 (0)