Skip to content

Conversation

@lubaskinc0de
Copy link
Contributor

@lubaskinc0de lubaskinc0de commented Dec 18, 2025

Summary

Fix issue #21889 by checking that the logging method is one of the debug, info, warning, error, exception, critical, log methods that support exc_info passing. Also fixed the behavior in which exc_info was considered passed only when it was equal to the literal True, now the Truthiness of the expression is checked (we will leave additional checks to type checkers)

Test Plan

Additional snapshot tests have been added for all logging functions, as well as tests in which an exception object is passed as exc_info

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 18, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+3 -32 violations, +0 -0 fixes in 3 projects; 52 projects unchanged)

apache/airflow (+0 -26 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL

- airflow-core/src/airflow/api_fastapi/execution_api/app.py:152:20: BLE001 Do not catch blind exception: `Exception`
- airflow-core/src/airflow/api_fastapi/execution_api/deps.py:91:16: BLE001 Do not catch blind exception: `Exception`
- airflow-core/src/airflow/jobs/scheduler_job_runner.py:2357:20: BLE001 Do not catch blind exception: `Exception`
- airflow-core/src/airflow/models/dagrun.py:1665:16: BLE001 Do not catch blind exception: `Exception`
- airflow-core/src/airflow/utils/serve_logs/log_server.py:111:16: BLE001 Do not catch blind exception: `Exception`
- providers/amazon/src/airflow/providers/amazon/aws/utils/suppress.py:65:20: BLE001 Do not catch blind exception: `Exception`
- providers/ftp/src/airflow/providers/ftp/operators/ftp.py:158:16: BLE001 Do not catch blind exception: `Exception`
- providers/google/src/airflow/providers/google/cloud/openlineage/mixins.py:123:16: BLE001 Do not catch blind exception: `Exception`
- providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:1802:16: BLE001 Do not catch blind exception: `Exception`
- providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:1999:16: BLE001 Do not catch blind exception: `Exception`
- providers/google/src/airflow/providers/google/cloud/operators/dataproc.py:2589:16: BLE001 Do not catch blind exception: `Exception`
- providers/google/src/airflow/providers/google/cloud/transfers/bigquery_to_sql.py:174:16: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/extractors/base.py:158:16: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/extractors/manager.py:140:20: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/plugins/adapter.py:169:16: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py:691:16: BLE001 Do not catch blind exception: `BaseException`
- providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py:743:16: BLE001 Do not catch blind exception: `BaseException`
- providers/openlineage/src/airflow/providers/openlineage/plugins/listener.py:796:16: BLE001 Do not catch blind exception: `BaseException`
- providers/openlineage/src/airflow/providers/openlineage/sqlparser.py:355:20: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/utils/utils.py:1352:12: BLE001 Do not catch blind exception: `Exception`
- providers/openlineage/src/airflow/providers/openlineage/utils/utils.py:1560:20: BLE001 Do not catch blind exception: `Exception`
- providers/sftp/src/airflow/providers/sftp/operators/sftp.py:236:16: BLE001 Do not catch blind exception: `Exception`
- providers/ssh/src/airflow/providers/ssh/hooks/ssh.py:508:24: BLE001 Do not catch blind exception: `Exception`
- providers/standard/src/airflow/providers/standard/utils/openlineage.py:178:12: BLE001 Do not catch blind exception: `Exception`
- task-sdk/src/airflow/sdk/execution_time/task_runner.py:963:12: BLE001 Do not catch blind exception: `Exception`
- task-sdk/src/airflow/sdk/serde/serializers/kubernetes.py:59:16: BLE001 Do not catch blind exception: `Exception`

apache/superset (+0 -6 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview --select ALL

- superset/db_engine_specs/bigquery.py:868:16: BLE001 Do not catch blind exception: `Exception`
- superset/db_engine_specs/bigquery.py:915:16: BLE001 Do not catch blind exception: `Exception`
- superset/models/core.py:1199:20: BLE001 Do not catch blind exception: `Exception`
- superset/security/manager.py:2888:16: BLE001 Do not catch blind exception: `Exception`
- superset/utils/screenshots.py:294:16: BLE001 Do not catch blind exception: `Exception`
- superset/utils/screenshots.py:300:20: BLE001 Do not catch blind exception: `Exception`

langchain-ai/langchain (+3 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-fix --output-format concise --preview

+ libs/langchain/langchain_classic/chains/openai_functions/openapi.py:383:32: RUF100 [*] Unused `noqa` directive (unused: `BLE001`)
+ libs/langchain/langchain_classic/smith/evaluation/runner_utils.py:1208:37: RUF100 [*] Unused `noqa` directive (unused: `BLE001`)
+ libs/langchain/langchain_classic/smith/evaluation/runner_utils.py:1216:33: RUF100 [*] Unused `noqa` directive (unused: `BLE001`)

Changes by rule (2 rules affected)

code total + violation - violation + fix - fix
BLE001 32 0 32 0 0
RUF100 3 3 0 0 0

@lubaskinc0de lubaskinc0de changed the title [flake8-blind-except] Allowed exception logging with functions other than critical and error (BLE001) [flake8-blind-except] Allowed exception logging with functions other than critical, error and exception (BLE001) Dec 18, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This looks great overall. I Just had one suggestion about trimming down the number of test cases and one to share some code for the Truthiness checks.

I also think we should make this a preview (link is to an example preview function) change since the ecosystem check is showing a number of changes, including some now-unused noqa comments.

@ntBre ntBre added rule Implementing or modifying a lint rule preview Related to preview mode features labels Dec 24, 2025
@ntBre ntBre linked an issue Jan 1, 2026 that may be closed by this pull request
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few more small comments.

lubaskinc0de and others added 2 commits January 3, 2026 13:05
…xcept.rs

Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
@lubaskinc0de lubaskinc0de requested a review from ntBre January 3, 2026 10:55
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ntBre
Copy link
Contributor

ntBre commented Jan 14, 2026

(closing and re-opening to rerun the prek check)

@ntBre ntBre closed this Jan 14, 2026
@ntBre ntBre reopened this Jan 14, 2026
@ntBre ntBre changed the title [flake8-blind-except] Allowed exception logging with functions other than critical, error and exception (BLE001) [flake8-blind-except] Allow more logging methods (BLE001) Jan 14, 2026
@ntBre ntBre enabled auto-merge (squash) January 14, 2026 21:15
@ntBre ntBre merged commit 5d99ef9 into astral-sh:main Jan 14, 2026
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BLE001 (blind-except): false positive when logging via warning

3 participants