Skip to content

Commit a1d2f1b

Browse files
OriNachumclaude
andcommitted
fix(sonar): S5886 explicit Profile construction; S5778 single-call raises block
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TJc5yvfweHP2AEccKNeaVd
2 parents c2a8495 + 0dbd82e commit a1d2f1b

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

lobes/profiles/loader.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@ def _apply_machine_registry(profile: Profile) -> Profile:
7979
continue
8080
overrides = {knob_name: knob.value for knob_name, knob in knobs.items()}
8181
updated_roles[role] = replace(updated_roles[role], **overrides)
82-
return replace(profile, roles=MappingProxyType(updated_roles))
82+
# Construct the Profile directly (rather than dataclasses.replace(profile,
83+
# ...)) so the declared return type matches what a static checker infers —
84+
# replace()'s generic signature resolves to the base DataclassInstance
85+
# protocol for some checkers, not the concrete Profile subtype.
86+
return Profile(
87+
name=profile.name, summary=profile.summary, roles=MappingProxyType(updated_roles)
88+
)
8389

8490

8591
def builtin_names() -> tuple[str, ...]:

tests/test_machines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ def test_render_is_json_friendly_with_provenance() -> None:
157157

158158

159159
def test_duplicate_registration_rejected_without_replace() -> None:
160+
spark = machines.get("spark")
160161
with pytest.raises(ValueError):
161-
machines.register(machines.get("spark"))
162+
machines.register(spark)
162163

163164

164165
# --- criterion 1: one file + one line, zero edits elsewhere ---------------

0 commit comments

Comments
 (0)