( # type: ignore[return]
installation_id: str, owner: str, repo: str
)
| 299 | |
| 300 | |
| 301 | def create_flagsmith_flag_label( # type: ignore[return] |
| 302 | installation_id: str, owner: str, repo: str |
| 303 | ) -> dict[str, Any]: |
| 304 | # Create "Flagsmith Flag" label in linked repo |
| 305 | url = f"{GITHUB_API_URL}repos/{owner}/{repo}/labels" |
| 306 | headers = build_request_headers(installation_id) |
| 307 | payload = { |
| 308 | "name": GITHUB_FLAGSMITH_LABEL, |
| 309 | "color": GITHUB_FLAGSMITH_LABEL_COLOR, |
| 310 | "description": GITHUB_FLAGSMITH_LABEL_DESCRIPTION, |
| 311 | } |
| 312 | try: |
| 313 | response = requests.post( |
| 314 | url, json=payload, headers=headers, timeout=GITHUB_API_CALLS_TIMEOUT |
| 315 | ) |
| 316 | response.raise_for_status() |
| 317 | return response.json() # type: ignore[no-any-return] |
| 318 | |
| 319 | except HTTPError: |
| 320 | response_content = response.content.decode("utf-8") |
| 321 | error_data = json.loads(response_content) |
| 322 | if any( |
| 323 | error["code"] == "already_exists" for error in error_data.get("errors", []) |
| 324 | ): |
| 325 | logger.warning("Label already exists") |
| 326 | return {"message": "Label already exists"}, 200 # type: ignore[return-value] |
| 327 | |
| 328 | |
| 329 | def label_github_issue_pr( |
no test coverage detected
searching dependent graphs…