[pylint] Ignore __init__.py files in (PLC0414)#18400
Merged
dylwil3 merged 7 commits intoastral-sh:mainfrom Jun 20, 2025
Merged
Conversation
pylint] Ignore __init__.py files in (PLC0414)
Contributor
|
| 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 |
Member
dylwil3
requested changes
Jun 20, 2025
crates/ruff_linter/resources/test/fixtures/pylint/import_aliasing_2/__init__.py
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs
Outdated
Show resolved
Hide resolved
crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs
Outdated
Show resolved
Hide resolved
dylwil3
approved these changes
Jun 20, 2025
Co-authored-by: Dylan <[email protected]>
Co-authored-by: Dylan <[email protected]>
72d9d86 to
9f9c0a0
Compare
Collaborator
|
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). |
Contributor
|
Thank you both! |
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) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ignore
__init__.pyfiles inuseless-import-alias(PLC0414).See discussion in #18365 and #6294: we want to allow redundant aliases in
__init__.pyfiles, as they're almost always intentional explicit re-exports.Closes #18365
Closes #6294
Test Plan
I added a new snapshot test.