Skip to content

Commit fd27cc7

Browse files
committed
chore(ingestion): keep main's baseline + globally ignore TRY400
Per gitar-bot's review on PR #27774: 1. Main's PR #27728 promoted ~60 `logger.warning()` → `logger.error()` inside `except` blocks. Those changes landed on main with their own baseline updates. Our PR doesn't promote anything — the merge from origin/main brought those `error` calls along with their baseline entries. The bot interpreted the `# noqa: TRY400` we added next to those lines as us silencing the rule case-by-case. Cleaner: globally ignore TRY400 in pyproject.toml, with a comment explaining why the codebase's `logger.error(...)` + separate `logger.debug(traceback.format_exc())` pattern is intentional. Strip ~430 per-line `# noqa: TRY400` markers from source. 2. Document that `S101` in `per-file-ignores` is a forward-looking entry — flake8-bandit (`S`) is not yet selected, so the rule is no-op today; the entry stays so when `S` lands later, tests don't immediately error. Reverts the platform pin and Linux Docker–generated baseline. Keep main's baseline intact and let CI surface the exact column-shifted entries; the team will decide whether to fix in-place (revert format on affected files) or add per-line `# pyright: ignore` markers.
1 parent 0f5f81f commit fd27cc7

206 files changed

Lines changed: 6060 additions & 20744 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ingestion/.basedpyright/baseline.json

Lines changed: 5611 additions & 20299 deletions
Large diffs are not rendered by default.

ingestion/operators/docker/exit_handler.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_kubernetes_client() -> Optional[client.CoreV1Api]: # noqa: UP045
105105
)
106106
return None
107107
except Exception as unexpected_error: # noqa: B025
108-
logger.error(f"Unexpected error initializing Kubernetes client: {unexpected_error}") # noqa: TRY400
108+
logger.error(f"Unexpected error initializing Kubernetes client: {unexpected_error}")
109109
return None
110110

111111

@@ -178,7 +178,7 @@ def find_main_pod(
178178
return None # noqa: TRY300
179179

180180
except Exception as e:
181-
logger.error(f"Failed to find main pod for job {job_name}: {e}") # noqa: TRY400
181+
logger.error(f"Failed to find main pod for job {job_name}: {e}")
182182
return None
183183

184184

@@ -314,7 +314,7 @@ def get_main_pod_description(k8s_client: client.CoreV1Api, main_pod: V1Pod, name
314314
return description if description_parts else None # noqa: TRY300
315315

316316
except Exception as e:
317-
logger.error(f"Failed to get pod description: {e}") # noqa: TRY400
317+
logger.error(f"Failed to get pod description: {e}")
318318
return None
319319

320320

@@ -463,7 +463,7 @@ def gather_failure_diagnostics(
463463

464464
except Exception as e:
465465
# Catch-all for any unexpected errors - diagnostics should never break the exit handler
466-
logger.error(f"Unexpected error while gathering diagnostics: {e}") # noqa: TRY400
466+
logger.error(f"Unexpected error while gathering diagnostics: {e}")
467467
return FailureDiagnostics()
468468

469469

@@ -499,7 +499,7 @@ def update_pipeline_status_with_diagnostics(
499499
logger.warning(f"Failed to update pipeline status with diagnostics: {e}")
500500

501501
except Exception as e:
502-
logger.error(f"Failed to create pod diagnostics: {e}") # noqa: TRY400
502+
logger.error(f"Failed to create pod diagnostics: {e}")
503503

504504

505505
def main():
@@ -571,14 +571,14 @@ def main():
571571
update_pipeline_status_with_diagnostics(pipeline_status, diagnostics)
572572
except Exception as e:
573573
# Log the error but continue - diagnostics should never prevent status updates
574-
logger.error(f"Failed to gather or add diagnostics, continuing with status update: {e}") # noqa: TRY400
574+
logger.error(f"Failed to gather or add diagnostics, continuing with status update: {e}")
575575

576576
# Send updated status to OpenMetadata - this is the critical operation that must succeed
577577
try:
578578
metadata.create_or_update_pipeline_status(workflow_config.ingestionPipelineFQN, pipeline_status)
579579
logger.info(f"Successfully updated pipeline status to {pipeline_status.pipelineState.value}")
580580
except Exception as e:
581-
logger.error(f"CRITICAL: Failed to send pipeline status update to OpenMetadata: {e}") # noqa: TRY400
581+
logger.error(f"CRITICAL: Failed to send pipeline status update to OpenMetadata: {e}")
582582
raise
583583
else:
584584
logger.info("Missing required fields - not updating pipeline status")
@@ -589,5 +589,5 @@ def main():
589589
try:
590590
main()
591591
except Exception as e:
592-
logger.error(f"Exit handler failed: {e}") # noqa: TRY400
592+
logger.error(f"Exit handler failed: {e}")
593593
raise

ingestion/pyproject.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ ignore = [
180180

181181
# ── Tryceratops nits ──
182182
"TRY003", # long exception messages — community consensus: skip
183+
"TRY400", # use logger.exception over logger.error in except — the
184+
# codebase intentionally logs `logger.debug(traceback.format_exc())`
185+
# separately from the summary log line, splitting traceback
186+
# (debug-only) from the user-facing summary so production
187+
# log levels can filter independently. Forcing
188+
# `logger.exception` would conflate the two.
183189

184190
# ── Perflint unavoidable cases ──
185191
"PERF203", # try inside for-loop — sometimes the only correct shape (row-by-row)
@@ -211,6 +217,9 @@ ignore = [
211217
# Each path listed twice — once relative to `ingestion/` (cwd for `make
212218
# py_format_check`) and once with the `ingestion/` prefix (cwd is repo root
213219
# for pre-commit hooks). Same pattern as `extend-exclude` above.
220+
# `S101` (assert in test) is forward-looking — flake8-bandit (`S`) is not
221+
# yet selected; the rule is no-op today but the entry stays so when `S`
222+
# lands in a later stage tests don't immediately error out.
214223
"tests/**/*.py" = ["S101", "PLR2004", "PLC0415"]
215224
"ingestion/tests/**/*.py" = ["S101", "PLR2004", "PLC0415"]
216225
# Auto-generated from JSON Schema — never edit, never lint.
@@ -262,11 +271,6 @@ exclude = [
262271
# 3.12 is verified separately by the unit-test matrix in py-tests.yml.
263272
# Keep this in sync with `requires-python` above.
264273
pythonVersion = "3.10"
265-
# Pin platform analysis to Linux so the baseline file (generated against
266-
# CI's Ubuntu runner) matches results from any developer machine. Without
267-
# this, macOS arm64 analyzers resolve some stubs differently and produce
268-
# column-shifted error positions that don't match the committed baseline.
269-
pythonPlatform = "Linux"
270274

271275
# Existing violations are grandfathered via .basedpyright/baseline.json
272276
# (regenerate with `basedpyright -p ingestion/pyproject.toml --writebaseline`

ingestion/src/airflow_provider_openmetadata/lineage/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ def send_lineage(
101101
runner.execute()
102102

103103
except Exception as exc: # pylint: disable=broad-except
104-
operator.log.error(traceback.format_exc()) # noqa: TRY400
105-
operator.log.error(exc) # noqa: TRY400
104+
operator.log.error(traceback.format_exc())
105+
operator.log.error(exc)

ingestion/src/airflow_provider_openmetadata/lineage/callback.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def failure_callback(context: Dict[str, str]) -> None: # noqa: UP006
6565
)
6666

6767
except Exception as exc: # pylint: disable=broad-except
68-
logging.error(traceback.format_exc()) # noqa: TRY400
69-
logging.error("Lineage Callback exception %s", exc) # noqa: TRY400
68+
logging.error(traceback.format_exc())
69+
logging.error("Lineage Callback exception %s", exc)
7070

7171

7272
def success_callback(context: Dict[str, str]) -> None: # noqa: UP006
@@ -102,5 +102,5 @@ def success_callback(context: Dict[str, str]) -> None: # noqa: UP006
102102
)
103103

104104
except Exception as exc: # pylint: disable=broad-except
105-
logging.error(traceback.format_exc()) # noqa: TRY400
106-
logging.error("Lineage Callback exception %s", exc) # noqa: TRY400
105+
logging.error(traceback.format_exc())
106+
logging.error("Lineage Callback exception %s", exc)

ingestion/src/airflow_provider_openmetadata/lineage/operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,5 @@ def execute(self, context: Context) -> None:
8282
runner.execute()
8383
except Exception as err:
8484
logger.info(traceback.format_exc())
85-
logger.error(f"Error executing the lineage runner - {err}") # noqa: TRY400
85+
logger.error(f"Error executing the lineage runner - {err}")
8686
raise err # noqa: TRY201

ingestion/src/airflow_provider_openmetadata/lineage/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,10 @@ def get_pipeline_status_via_api(self) -> List[PipelineStatus]: # noqa: C901, UP
418418
return pipeline_statuses # noqa: TRY300
419419

420420
except Exception as e:
421-
logger.error(f"Error collecting pipeline status via API: {e}") # noqa: TRY400
421+
logger.error(f"Error collecting pipeline status via API: {e}")
422422
import traceback # noqa: PLC0415
423423

424-
logger.error(f"Traceback: {traceback.format_exc()}") # noqa: TRY400
424+
logger.error(f"Traceback: {traceback.format_exc()}")
425425
raise
426426

427427
def get_all_pipeline_status(self) -> List[PipelineStatus]: # noqa: UP006

ingestion/src/metadata/cli/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run_app(config_path: Path) -> None:
3636
# no logging for config because apps might have custom secrets
3737
workflow = ApplicationWorkflow.create(config_dict)
3838
except Exception as exc:
39-
logger.error(f"Error running the application {exc}") # noqa: TRY400
39+
logger.error(f"Error running the application {exc}")
4040
logger.debug(traceback.format_exc())
4141
sys.exit(1)
4242

ingestion/src/metadata/cli/ingest_dbt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,6 @@ def run_ingest_dbt(dbt_project_path: Path) -> None:
332332
logger.info("DBT artifacts ingestion completed successfully")
333333

334334
except Exception as exc:
335-
logger.error(f"Error during DBT artifacts ingestion: {exc}") # noqa: TRY400
335+
logger.error(f"Error during DBT artifacts ingestion: {exc}")
336336
logger.debug(traceback.format_exc())
337337
sys.exit(1)

ingestion/src/metadata/clients/azure_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def create_client(
5151
logger.info("Using Default Azure Credentials")
5252
return DefaultAzureCredential()
5353
except Exception as e:
54-
logger.error(f"Error creating Azure Client: {e}") # noqa: TRY400
54+
logger.error(f"Error creating Azure Client: {e}")
5555
raise e # noqa: TRY201
5656

5757
def create_blob_client(self):
@@ -66,7 +66,7 @@ def create_blob_client(self):
6666
)
6767
raise ValueError("Account Name is required to create Blob Service Client") # noqa: TRY301
6868
except Exception as e:
69-
logger.error(f"Error creating Blob Service Client: {e}") # noqa: TRY400
69+
logger.error(f"Error creating Blob Service Client: {e}")
7070
raise e # noqa: TRY201
7171

7272
def create_secret_client(self):
@@ -81,5 +81,5 @@ def create_secret_client(self):
8181
)
8282
raise ValueError("Vault Name is required to create a Secret Client") # noqa: TRY301
8383
except Exception as e:
84-
logger.error(f"Error creating Secret Client: {e}") # noqa: TRY400
84+
logger.error(f"Error creating Secret Client: {e}")
8585
raise e # noqa: TRY201

0 commit comments

Comments
 (0)