Skip to content

Commit 5f91bc6

Browse files
AtharvaCopilot
andcommitted
fix: resolve all pylint/flake8 lint errors
- Fix undefined 'inner' variable in solutionVersionId extraction - Replace broad Exception catches with specific types - Remove stale args from __init__.py (solution_template_rg, solution_instance_name, solution_dependencies) - Fix line-too-long in hierarchy_create.py - Remove unnecessary else after return - Remove unused import time - Fix ungrouped imports in target_prepare.py - Add pylint disable for too-few-public-methods on CmdProxy - Add pylint disable for unused-argument on invoke_cli_command Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5014bb0 commit 5f91bc6

5 files changed

Lines changed: 27 additions & 32 deletions

File tree

src/workload-orchestration/azext_workload_orchestration/onboarding/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ def target_deploy(
4545
solution_template_version_id=None,
4646
solution_template_name=None,
4747
solution_template_version=None,
48-
solution_template_rg=None,
49-
solution_instance_name=None,
50-
solution_dependencies=None,
5148
config=None,
5249
config_hierarchy_id=None,
5350
config_template_rg=None,
@@ -62,9 +59,6 @@ def target_deploy(
6259
solution_template_version_id=solution_template_version_id,
6360
solution_template_name=solution_template_name,
6461
solution_template_version=solution_template_version,
65-
solution_template_rg=solution_template_rg,
66-
solution_instance_name=solution_instance_name,
67-
solution_dependencies=solution_dependencies,
6862
config=config,
6963
config_hierarchy_id=config_hierarchy_id,
7064
config_template_rg=config_template_rg,

src/workload-orchestration/azext_workload_orchestration/onboarding/hierarchy_create.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def hierarchy_create(cmd, resource_group=None, configuration_location=None, hier
8888

8989
if hierarchy_type == "ServiceGroup":
9090
return _create_sg_hierarchy(cmd, spec, configuration_location, resource_group)
91-
else:
92-
return _create_rg_hierarchy(cmd, resource_group, configuration_location, name, level)
91+
return _create_rg_hierarchy(cmd, resource_group, configuration_location, name, level)
9392

9493

9594
# ---------------------------------------------------------------------------
@@ -109,9 +108,15 @@ def _log(msg, status=""):
109108
step[0] += 1
110109
print(f"[{step[0]}/{total}] {msg}...")
111110

112-
site_id = f"/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/{EDGE_RP_NAMESPACE}/sites/{name}"
111+
site_id = (
112+
f"/subscriptions/{sub_id}/resourceGroups/{resource_group}"
113+
f"/providers/{EDGE_RP_NAMESPACE}/sites/{name}"
114+
)
113115
config_name = f"{name}Config"
114-
config_id = f"/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/{EDGE_RP_NAMESPACE}/configurations/{config_name}"
116+
config_id = (
117+
f"/subscriptions/{sub_id}/resourceGroups/{resource_group}"
118+
f"/providers/{EDGE_RP_NAMESPACE}/configurations/{config_name}"
119+
)
115120

116121
print(f"\nCreating hierarchy '{name}' (level: {level}) in RG '{resource_group}'...\n")
117122

@@ -189,8 +194,6 @@ def _create_sg_hierarchy(cmd, spec, config_location, resource_group):
189194

190195
def _create_sg_level(cmd, node, config_location, sub_id, tenant_id, resource_group, parent_sg, results, depth):
191196
"""Recursively create SG + Site + Config + ConfigRef at each level."""
192-
import time
193-
194197
name = node["name"]
195198
level = node["level"]
196199

@@ -237,7 +240,10 @@ def _create_sg_level(cmd, node, config_location, sub_id, tenant_id, resource_gro
237240

238241
# 3. Create Configuration (RG-scoped, NOT under SG)
239242
config_name = f"{name}Config"
240-
config_id = f"/subscriptions/{sub_id}/resourceGroups/{resource_group}/providers/{EDGE_RP_NAMESPACE}/configurations/{config_name}"
243+
config_id = (
244+
f"/subscriptions/{sub_id}/resourceGroups/{resource_group}"
245+
f"/providers/{EDGE_RP_NAMESPACE}/configurations/{config_name}"
246+
)
241247
print(f"{indent} [+] Configuration '{config_name}' (in RG: {resource_group})...")
242248
_arm_put(cmd, f"{ARM_ENDPOINT}{config_id}", {
243249
"location": config_location,

src/workload-orchestration/azext_workload_orchestration/onboarding/target_deploy.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,15 @@ def _parse_response(resp, step_name, cmd=None):
362362
if status in (200, 201):
363363
try:
364364
return resp.json()
365-
except Exception:
365+
except (ValueError, AttributeError):
366366
return {"status": "Succeeded"}
367367
if status == 202:
368368
return _poll_lro(resp, step_name, cmd=cmd)
369369

370370
# Error
371371
try:
372372
error_body = resp.text
373-
except Exception:
373+
except (ValueError, AttributeError):
374374
error_body = f"HTTP {status}"
375375
raise CLIInternalError(f"{step_name} failed (HTTP {status}): {error_body}")
376376

@@ -391,13 +391,13 @@ def _poll_lro(resp, step_name, cmd=None):
391391
time.sleep(retry_after)
392392
try:
393393
poll_resp = send_raw_request(cmd.cli_ctx, "GET", location, resource=ARM_RESOURCE)
394-
except Exception:
394+
except (CLIInternalError, ValueError, ConnectionError):
395395
logger.debug("LRO poll attempt %d failed for %s", i + 1, step_name)
396396
continue
397397

398398
try:
399399
body = poll_resp.json()
400-
except Exception:
400+
except (ValueError, AttributeError):
401401
continue
402402

403403
poll_status = body.get("status", "").lower()
@@ -428,13 +428,13 @@ def _extract_solution_version_id(review_result):
428428
or (props.get("properties", {}) or {}).get("id") # properties.properties.id
429429
)
430430
if not sv_id:
431-
logger.warning("Could not extract solutionVersionId. Keys at top: %s, inner keys: %s, full (truncated): %s",
432-
list(review_result.keys()),
433-
list(inner.keys()) if isinstance(inner, dict) else "N/A",
434-
json.dumps(review_result, indent=2)[:800])
431+
logger.warning(
432+
"Could not extract solutionVersionId. Keys: %s, full (truncated): %s",
433+
list(review_result.keys()),
434+
json.dumps(review_result, indent=2)[:800]
435+
)
435436
raise CLIInternalError(
436-
"Review succeeded but no solutionVersionId found in response. "
437-
"Use --resume-from publish --solution-version-id <id> to continue manually."
437+
"Review succeeded but no solutionVersionId found in response."
438438
)
439439
return sv_id
440440

src/workload-orchestration/azext_workload_orchestration/onboarding/target_prepare.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
CLIInternalError,
2929
ValidationError,
3030
)
31+
from azure.cli.core.util import send_raw_request
3132

3233
from azext_workload_orchestration.onboarding.consts import (
3334
DEFAULT_CERT_MANAGER_VERSION,
@@ -53,8 +54,6 @@
5354
print_detail,
5455
)
5556

56-
from azure.cli.core.util import send_raw_request
57-
5857
logger = logging.getLogger(__name__)
5958

6059
TOTAL_STEPS = 4

src/workload-orchestration/azext_workload_orchestration/onboarding/utils.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@
2323
# CmdProxy - bridge between AAZ hooks and helpers expecting cmd.cli_ctx
2424
# ---------------------------------------------------------------------------
2525

26-
class CmdProxy:
27-
"""Lightweight proxy to pass CLI context where a full cmd object is expected.
28-
29-
AAZ-generated commands don't expose a cmd object in hooks, but many
30-
helper functions expect cmd.cli_ctx. This proxy bridges the gap.
31-
"""
26+
class CmdProxy: # pylint: disable=too-few-public-methods
27+
"""Lightweight proxy to pass CLI context where a full cmd object is expected."""
3228
def __init__(self, cli_ctx):
3329
self.cli_ctx = cli_ctx
3430

@@ -87,7 +83,7 @@ def invoke_silent(cli_args):
8783
# CLI command invocation
8884
# ---------------------------------------------------------------------------
8985

90-
def invoke_cli_command(cmd, command_args, expect_json=True):
86+
def invoke_cli_command(cmd, command_args, expect_json=True): # pylint: disable=unused-argument
9187
"""Invoke another az CLI command in-process (shares auth context).
9288
9389
Uses get_default_cli().invoke() so the child command shares

0 commit comments

Comments
 (0)