Skip to content

Conversation

GideonBear
Copy link
Contributor

@GideonBear GideonBear commented May 31, 2025

Summary

Ignore __init__.py files in useless-import-alias (PLC0414).
See discussion in #18365 and #6294: we want to allow redundant aliases in __init__.py files, as they're almost always intentional explicit re-exports.
Closes #18365
Closes #6294

Test Plan

I added a new snapshot test.

@GideonBear GideonBear changed the title [pylint] Ignore __init__.py files in (PLC0414) [pylint] Ignore __init__.py files in (PLC0414) May 31, 2025
@ntBre ntBre self-requested a review May 31, 2025 14:05
@ntBre ntBre added the bug Something isn't working label May 31, 2025
Copy link
Contributor

github-actions bot commented May 31, 2025

ruff-ecosystem results

Linter (stable)

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

apache/airflow (+0 -5 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/decorators/__init__.py:20:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:21:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:22:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:23:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:24:5: PLC0414 Import alias does not rename original package

zulip/zulip (+0 -84 violations, +0 -0 fixes)

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

- corporate/models/__init__.py:10:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:11:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:1:40: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:2:39: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:3:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:4:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:5:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:6:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:7:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:8:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:9:43: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:10:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:11:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:12:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:13:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:14:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:15:38: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:16:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:17:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:18:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:19:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:1:27: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:20:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:21:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:22:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:23:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:24:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:25:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:26:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:27:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:28:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:29:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:2:39: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:30:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:31:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:32:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:33:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:34:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:35:39: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:36:44: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:37:44: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:38:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:39:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:3:32: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:40:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:41:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:42:40: PLC0414 Import alias does not rename original package
... 37 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLC0414 89 0 89 0 0

Linter (preview)

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

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

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

- airflow-core/src/airflow/decorators/__init__.py:20:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:21:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:22:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:23:5: PLC0414 Import alias does not rename original package
- airflow-core/src/airflow/decorators/__init__.py:24:5: PLC0414 Import alias does not rename original package

zulip/zulip (+0 -84 violations, +0 -0 fixes)

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

- corporate/models/__init__.py:10:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:11:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:1:40: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:2:39: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:3:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:4:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:5:36: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:6:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:7:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:8:43: PLC0414 Import alias does not rename original package
- corporate/models/__init__.py:9:43: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:10:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:11:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:12:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:13:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:14:34: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:15:38: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:16:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:17:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:18:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:19:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:1:27: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:20:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:21:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:22:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:23:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:24:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:25:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:26:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:27:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:28:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:29:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:2:39: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:30:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:31:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:32:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:33:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:34:36: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:35:39: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:36:44: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:37:44: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:38:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:39:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:3:32: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:40:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:41:40: PLC0414 Import alias does not rename original package
- zerver/models/__init__.py:42:40: PLC0414 Import alias does not rename original package
... 37 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
PLC0414 89 0 89 0 0

@MichaReiser
Copy link
Member

MichaReiser commented Jun 20, 2025

@ntBre or @dylwil3 could either of you review this PR.

Copy link
Collaborator

@dylwil3 dylwil3 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 couple nits

@dylwil3 dylwil3 added rule Implementing or modifying a lint rule preview Related to preview mode features and removed bug Something isn't working labels Jun 20, 2025
@dylwil3 dylwil3 force-pushed the fix-f401-plc0414-conflict branch from 72d9d86 to 9f9c0a0 Compare June 20, 2025 18:16
@dylwil3
Copy link
Collaborator

dylwil3 commented Jun 20, 2025

On second thought I decided to gate this behind preview for now. (I think technically we don't have to since it reduces the number of lints, but it seems like a big enough change that I think it's a good idea).

@dylwil3 dylwil3 enabled auto-merge (squash) June 20, 2025 18:17
@ntBre
Copy link
Contributor

ntBre commented Jun 20, 2025

Thank you both!

@dylwil3 dylwil3 merged commit 2910988 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)
  ...
@GideonBear GideonBear deleted the fix-f401-plc0414-conflict branch June 21, 2025 06:49
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
4 participants