From 5ed93ca7215a45f68f539d017bfc5364765c300e Mon Sep 17 00:00:00 2001 From: Backend Developer 1 Date: Sat, 18 Jul 2026 19:04:01 +0000 Subject: [PATCH] [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). --- roboco/services/company_goals.py | 26 ++++++++++++++------------ roboco/services/git.py | 1 + 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/roboco/services/company_goals.py b/roboco/services/company_goals.py index 138952dc..2ec255e2 100644 --- a/roboco/services/company_goals.py +++ b/roboco/services/company_goals.py @@ -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() diff --git a/roboco/services/git.py b/roboco/services/git.py index cda49e98..866b843f 100644 --- a/roboco/services/git.py +++ b/roboco/services/git.py @@ -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