[467e263d] fix(ci): restore green Python quality gate on slave (mypy + xenon)

Two independent bugs broke run 29653535468's 'Python quality gate' job,
not the pydantic-settings pin (already correctly 2.14.2 on this branch).

- git.py: _delete_remote_branch_best_effort's success path fell off the
  function with no return, failing mypy's missing-return-statement check
  and silently returning None instead of the documented True.
- company_goals.py: CompanyGoalsService.upsert's six repetitive
  `if key in data` branches pushed the module's average cyclomatic
  complexity past xenon's --max-modules A gate; refactored into a loop
  over the mutable-field tuple (behaviourally identical).
This commit is contained in:
Backend Developer 1
2026-07-18 19:04:01 +00:00
parent 9618e345e8
commit 5ed93ca721
2 changed files with 15 additions and 12 deletions
+14 -12
View File
@@ -24,6 +24,17 @@ if TYPE_CHECKING:
# Canonical single-row marker — the charter is a singleton.
SINGLETON_ID = UUID("00000000-0000-0000-0000-000000000000")
# Charter fields ``upsert`` writes verbatim when present in the partial-update
# payload (``updated_by`` is handled separately — it's not a charter field).
_MUTABLE_FIELDS = (
"north_star",
"objectives",
"constraints",
"operating_policy",
"brand_voice",
"company_name",
)
_EMPTY: dict[str, Any] = {
"north_star": "",
"objectives": [],
@@ -57,18 +68,9 @@ class CompanyGoalsService(BaseService):
if row is None:
row = CompanyGoalsTable(id=SINGLETON_ID)
self.session.add(row)
if "north_star" in data:
row.north_star = data["north_star"]
if "objectives" in data:
row.objectives = data["objectives"]
if "constraints" in data:
row.constraints = data["constraints"]
if "operating_policy" in data:
row.operating_policy = data["operating_policy"]
if "brand_voice" in data:
row.brand_voice = data["brand_voice"]
if "company_name" in data:
row.company_name = data["company_name"]
for field in _MUTABLE_FIELDS:
if field in data:
setattr(row, field, data[field])
if updated_by is not None:
row.updated_by = updated_by
await self.session.flush()
+1
View File
@@ -3519,6 +3519,7 @@ class GitService(BaseService):
await self._forge.delete_branch_ref(
RepoRef(owner, repo), git_token, branch, timeout=10.0
)
return True
except httpx.HTTPError:
return False