Skip to content

Commit 67e35b3

Browse files
ritwik-gclaude
andcommitted
Format code with ruff for CI compliance
- Apply ruff format to all Python files - Fix code formatting and remove newline issues - Ensure consistent formatting across codebase - CI should now pass format checks 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4a79089 commit 67e35b3

23 files changed

+1286
-1120
lines changed

helm_values_manager/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.0"

helm_values_manager/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ def main(
4646

4747

4848
if __name__ == "__main__":
49-
app()
49+
app()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Commands module for helm-values-manager."""
1+
"""Commands module for helm-values-manager."""

helm_values_manager/commands/generate.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generate command implementation."""
2+
23
from typing import Optional
34

45
import typer
@@ -17,29 +18,31 @@
1718
def generate_command(
1819
env: str = typer.Option(..., "--env", "-e", help="Environment to generate values for"),
1920
schema: str = typer.Option("schema.json", "--schema", "-s", help="Path to schema file"),
20-
values: Optional[str] = typer.Option(None, "--values", help="Path to values file (default: values-{env}.json)"),
21+
values: Optional[str] = typer.Option(
22+
None, "--values", help="Path to values file (default: values-{env}.json)"
23+
),
2124
):
2225
"""Generate values.yaml for a specific environment."""
2326
# Load schema
2427
schema_obj = load_schema(schema)
2528
if not schema_obj:
2629
ErrorHandler.print_error("generate", "Schema file not found")
27-
30+
2831
# Load values
2932
values_data = load_values(env, values)
30-
33+
3134
# Run validation first
3235
errors = validate_single_environment(schema_obj, values_data, env)
33-
36+
3437
if errors:
3538
ErrorHandler.print_errors(errors, f"generate --env {env}")
36-
39+
3740
# Generate values.yaml
3841
try:
3942
yaml_content = generate_values(schema_obj, values_data, env)
4043
# Output to stdout
41-
print(yaml_content, end='')
44+
print(yaml_content, end="")
4245
except GeneratorError as e:
4346
ErrorHandler.handle_exception(e, "generate")
4447
except Exception as e:
45-
ErrorHandler.handle_exception(e, "generate")
48+
ErrorHandler.handle_exception(e, "generate")

helm_values_manager/commands/init.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,16 @@ def init_command(
1616
):
1717
"""Initialize a new schema.json file with empty schema."""
1818
schema_path = Path(SCHEMA_FILE)
19-
19+
2020
if schema_path.exists() and not force:
21-
ErrorHandler.print_error(
22-
"init",
23-
f"{SCHEMA_FILE} already exists. Use --force to overwrite."
24-
)
25-
26-
initial_schema = {
27-
"values": []
28-
}
29-
21+
ErrorHandler.print_error("init", f"{SCHEMA_FILE} already exists. Use --force to overwrite.")
22+
23+
initial_schema = {"values": []}
24+
3025
try:
3126
with open(schema_path, "w") as f:
3227
json.dump(initial_schema, f, indent=2)
33-
28+
3429
console.print(f"[green]✓[/green] Created {SCHEMA_FILE}")
3530
except Exception as e:
36-
ErrorHandler.handle_exception(e, "init")
31+
ErrorHandler.handle_exception(e, "init")

helm_values_manager/commands/schema.py

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77

88
from helm_values_manager.errors import ErrorHandler, SchemaError, error_console
99
from helm_values_manager.models import SchemaValue, ValueType
10-
from helm_values_manager.utils import load_schema, save_schema, validate_key_unique, validate_path_format
10+
from helm_values_manager.utils import (
11+
load_schema,
12+
save_schema,
13+
validate_key_unique,
14+
validate_path_format,
15+
)
1116

1217
console = Console()
1318
app = typer.Typer()
@@ -54,33 +59,35 @@ def add_command(
5459
schema = load_schema(schema_path)
5560
if not schema:
5661
ErrorHandler.print_error("schema", "No schema.json found. Run 'init' first.")
57-
62+
5863
console.print("[bold]Add new value to schema[/bold]\n")
59-
64+
6065
# Prompt for key
6166
while True:
6267
key = Prompt.ask("Key (unique identifier)")
6368
if not key:
6469
error_console.print("[red]Key cannot be empty[/red]")
6570
continue
66-
71+
6772
if not validate_key_unique(schema, key):
6873
error_console.print(f"[red]Key '{key}' already exists in schema[/red]")
6974
continue
70-
75+
7176
break
72-
77+
7378
# Prompt for path
7479
while True:
7580
path = Prompt.ask("Path (dot-separated YAML path)")
7681
if not validate_path_format(path):
77-
error_console.print("[red]Invalid path format. Use alphanumeric characters and dots only.[/red]")
82+
error_console.print(
83+
"[red]Invalid path format. Use alphanumeric characters and dots only.[/red]"
84+
)
7885
continue
7986
break
80-
87+
8188
# Prompt for description
8289
description = Prompt.ask("Description")
83-
90+
8491
# Prompt for type
8592
type_choices = ["string", "number", "boolean", "array", "object"]
8693
console.print("\nType options: " + ", ".join(type_choices))
@@ -89,10 +96,10 @@ def add_command(
8996
if value_type in type_choices:
9097
break
9198
error_console.print(f"[red]Invalid type. Choose from: {', '.join(type_choices)}[/red]")
92-
99+
93100
# Prompt for required
94101
required = Confirm.ask("Required?", default=True)
95-
102+
96103
# Prompt for default value
97104
default = None
98105
if Confirm.ask("Set default value?", default=False):
@@ -103,10 +110,10 @@ def add_command(
103110
break
104111
except SchemaError as e:
105112
error_console.print(f"[red]{e}[/red]")
106-
113+
107114
# Prompt for sensitive
108115
sensitive = Confirm.ask("Sensitive value?", default=False)
109-
116+
110117
# Create and add the new value
111118
new_value = SchemaValue(
112119
key=key,
@@ -117,12 +124,12 @@ def add_command(
117124
default=default,
118125
sensitive=sensitive,
119126
)
120-
127+
121128
schema.values.append(new_value)
122-
129+
123130
# Save the updated schema
124131
save_schema(schema, schema_path)
125-
132+
126133
console.print(f"\n[green]✓[/green] Added '{key}' to schema")
127134
console.print(f" Path: {path}")
128135
console.print(f" Type: {value_type}")
@@ -140,13 +147,13 @@ def list_command(
140147
schema = load_schema(schema_path)
141148
if not schema:
142149
ErrorHandler.print_error("schema", "No schema.json found. Run 'init' first.")
143-
150+
144151
if not schema.values:
145152
console.print("No values defined in schema.")
146153
return
147-
154+
148155
console.print("[bold]Schema Values:[/bold]\n")
149-
156+
150157
for value in schema.values:
151158
status = "[green]●[/green]" if value.required else "[yellow]○[/yellow]"
152159
sensitive = " 🔒" if value.sensitive else ""
@@ -168,20 +175,22 @@ def get_command(
168175
schema = load_schema(schema_path)
169176
if not schema:
170177
ErrorHandler.print_error("schema", "No schema.json found. Run 'init' first.")
171-
178+
172179
# Find the value
173180
value = next((v for v in schema.values if v.key == key), None)
174181
if not value:
175182
ErrorHandler.print_error("schema", f"Value with key '{key}' not found")
176-
183+
177184
# Display details
178185
console.print(f"\n[bold]{value.key}[/bold]")
179186
console.print(f"Path: {value.path}")
180187
console.print(f"Type: {value.type}")
181188
console.print(f"Description: {value.description}")
182189
console.print(f"Required: {value.required}")
183190
if value.default is not None:
184-
console.print(f"Default: {json.dumps(value.default, indent=2) if value.type in ['array', 'object'] else value.default}")
191+
console.print(
192+
f"Default: {json.dumps(value.default, indent=2) if value.type in ['array', 'object'] else value.default}"
193+
)
185194
console.print(f"Sensitive: {value.sensitive}")
186195

187196

@@ -194,28 +203,30 @@ def update_command(
194203
schema = load_schema(schema_path)
195204
if not schema:
196205
ErrorHandler.print_error("schema", "No schema.json found. Run 'init' first.")
197-
206+
198207
# Find the value
199208
value_index = next((i for i, v in enumerate(schema.values) if v.key == key), None)
200209
if value_index is None:
201210
ErrorHandler.print_error("schema", f"Value with key '{key}' not found")
202-
211+
203212
value = schema.values[value_index]
204213
console.print(f"[bold]Updating '{key}'[/bold]\n")
205214
console.print("Press Enter to keep current value\n")
206-
215+
207216
# Update path
208217
new_path = Prompt.ask(f"Path [{value.path}]", default=value.path)
209218
if new_path != value.path:
210219
while not validate_path_format(new_path):
211-
error_console.print("[red]Invalid path format. Use alphanumeric characters and dots only.[/red]")
220+
error_console.print(
221+
"[red]Invalid path format. Use alphanumeric characters and dots only.[/red]"
222+
)
212223
new_path = Prompt.ask(f"Path [{value.path}]", default=value.path)
213224
value.path = new_path
214-
225+
215226
# Update description
216227
new_description = Prompt.ask(f"Description [{value.description}]", default=value.description)
217228
value.description = new_description
218-
229+
219230
# Update type
220231
type_choices = ["string", "number", "boolean", "array", "object"]
221232
console.print(f"\nType options: {', '.join(type_choices)}")
@@ -229,10 +240,10 @@ def update_command(
229240
if value.default is not None:
230241
if Confirm.ask("Type changed. Clear default value?", default=True):
231242
value.default = None
232-
243+
233244
# Update required
234245
value.required = Confirm.ask("Required?", default=value.required)
235-
246+
236247
# Update default
237248
if value.default is None:
238249
if Confirm.ask("Set default value?", default=False):
@@ -244,18 +255,20 @@ def update_command(
244255
except SchemaError as e:
245256
error_console.print(f"[red]{e}[/red]")
246257
else:
247-
default_display = json.dumps(value.default) if value.type in ['array', 'object'] else str(value.default)
258+
default_display = (
259+
json.dumps(value.default) if value.type in ["array", "object"] else str(value.default)
260+
)
248261
console.print(f"\nCurrent default value: {default_display}")
249-
262+
250263
# Offer options for existing default
251264
console.print("Options:")
252265
console.print("1. Keep current default")
253266
console.print("2. Update default value")
254267
console.print("3. Remove default value")
255-
268+
256269
while True:
257270
choice = Prompt.ask("Choose option", choices=["1", "2", "3"], default="1")
258-
271+
259272
if choice == "1":
260273
# Keep current default
261274
break
@@ -272,20 +285,22 @@ def update_command(
272285
elif choice == "3":
273286
# Remove default value
274287
if value.required:
275-
ErrorHandler.print_warning("This field is required but will have no default value")
288+
ErrorHandler.print_warning(
289+
"This field is required but will have no default value"
290+
)
276291
if not Confirm.ask("Continue removing default?", default=False):
277292
continue
278-
293+
279294
value.default = None
280295
console.print("[green]✓[/green] Default value removed")
281296
break
282-
297+
283298
# Update sensitive
284299
value.sensitive = Confirm.ask("Sensitive value?", default=value.sensitive)
285-
300+
286301
# Save the updated schema
287302
save_schema(schema, schema_path)
288-
303+
289304
console.print(f"\n[green]✓[/green] Updated '{key}' in schema")
290305

291306

@@ -299,29 +314,29 @@ def remove_command(
299314
schema = load_schema(schema_path)
300315
if not schema:
301316
ErrorHandler.print_error("schema", "No schema.json found. Run 'init' first.")
302-
317+
303318
# Find the value
304319
value_index = next((i for i, v in enumerate(schema.values) if v.key == key), None)
305320
if value_index is None:
306321
ErrorHandler.print_error("schema", f"Value with key '{key}' not found")
307-
322+
308323
value = schema.values[value_index]
309-
324+
310325
# Confirm removal
311326
if not force:
312327
console.print("\n[bold]Value to remove:[/bold]")
313328
console.print(f"Key: {value.key}")
314329
console.print(f"Path: {value.path}")
315330
console.print(f"Description: {value.description}")
316-
331+
317332
if not Confirm.ask("\nRemove this value?", default=False):
318333
console.print("Cancelled")
319334
raise typer.Exit(0)
320-
335+
321336
# Remove the value
322337
schema.values.pop(value_index)
323-
338+
324339
# Save the updated schema
325340
save_schema(schema, schema_path)
326-
327-
console.print(f"\n[green]✓[/green] Removed '{key}' from schema")
341+
342+
console.print(f"\n[green]✓[/green] Removed '{key}' from schema")

0 commit comments

Comments
 (0)