Skip to content

Comments

[flake8-logging] Avoid false positive for exc_info=True outside logger.exception (LOG014)#18737

Merged
ntBre merged 1 commit intoastral-sh:mainfrom
hmvp:fix_log014
Jun 20, 2025
Merged

[flake8-logging] Avoid false positive for exc_info=True outside logger.exception (LOG014)#18737
ntBre merged 1 commit intoastral-sh:mainfrom
hmvp:fix_log014

Conversation

@hmvp
Copy link
Contributor

@hmvp hmvp commented Jun 17, 2025

Summary

Fixes #18726 by also checking if its a literal and not only that it is truthy. See also the first comment in the issue.

It would have been nice to check for inheritance of BaseException but I figured that is not possible yet...

Test Plan

I added a few tests for valid input to exc_info

@ntBre ntBre added bug Something isn't working rule Implementing or modifying a lint rule labels Jun 17, 2025
@ntBre ntBre self-requested a review June 17, 2025 22:45
@github-actions
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

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

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

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

- airflow-core/src/airflow/api_fastapi/execution_api/app.py:187:55: LOG014 `exc_info=` outside exception handlers

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
LOG014 1 0 1 0 0

Linter (preview)

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

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

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

- airflow-core/src/airflow/api_fastapi/execution_api/app.py:187:55: LOG014 `exc_info=` outside exception handlers

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
LOG014 1 0 1 0 0

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.

Looks great, thank you!

@ntBre ntBre merged commit 49763a7 into astral-sh:main Jun 20, 2025
34 checks passed
dcreager added a commit that referenced this pull request Jun 20, 2025
* main: (21 commits)
  [`flake8-logging`] Avoid false positive for `exc_info=True` outside `logger.exception` (`LOG014`) (#18737)
  [`flake8-pie`] Small docs fix to `PIE794` (#18829)
  [`pylint`] Ignore __init__.py files in (PLC0414) (#18400)
  Avoid generating diagnostics with per-file ignores (#18801)
  [`flake8-simplify`] Fix false negatives for shadowed bindings  (`SIM910`, `SIM911`) (#18794)
  [ty] Fix panics when pulling types for `ClassVar` or `Final` parameterized with >1 argument (#18824)
  [`pylint`] add fix safety section (`PLR1714`) (#18415)
  [Perflint] Small docs improvement to `PERF401` (#18786)
  [`pylint`] Avoid flattening nested `min`/`max` when outer call has single argument (`PLW3301`) (#16885)
  [`ruff`] Added `cls.__dict__.get('__annotations__')` check (`RUF063`) (#18233)
  [ty] Use `HashTable` in `PlaceTable` (#18819)
  docs: Correct collections-named-tuple example to use PascalCase assignment (#16884)
  [ty] ecosystem-analyzer workflow (#18719)
  [ty] Add support for `@staticmethod`s (#18809)
  unnecessary_dict_kwargs doc - a note on type checking benefits (#18666)
  [`flake8-pytest-style`] Mark autofix for `PT001` and `PT023` as unsafe if there's comments in the decorator (#18792)
  [ty] Surface matched overload diagnostic directly (#18452)
  [ty] Report when a dataclass contains more than one `KW_ONLY` field (#18731)
  [`flake8-pie`] Add fix safety section to `PIE794` (#18802)
  [`pycodestyle`] Add fix safety section to `W291` and `W293`  (#18800)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LOG014 Gives false positives

2 participants