-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
caa1450
commit 5732931
Showing
4 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
crates/ruff_linter/resources/test/fixtures/pyflakes/F821_29.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Regression test for #10451. | ||
Annotations in a class are allowed to be forward references | ||
if `from __future__ import annotations` is active, | ||
even if they're in a class included in | ||
`lint.flake8-type-checking.runtime-evaluated-base-classes`. | ||
They're not allowed to refer to symbols that cannot be *resolved* | ||
at runtime, however. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from sqlalchemy.orm import DeclarativeBase, Mapped | ||
|
||
|
||
class Base(DeclarativeBase): | ||
some_mapping: Mapped[list[Bar]] | None = None # Should not trigger F821 (resolveable forward reference) | ||
simplified: list[Bar] | None = None # Should not trigger F821 (resolveable forward reference) | ||
|
||
|
||
class Bar: | ||
pass |
This file contains 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
4 changes: 4 additions & 0 deletions
4
...er/src/rules/pyflakes/snapshots/ruff_linter__rules__pyflakes__tests__F821_F821_29.py.snap
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
source: crates/ruff_linter/src/rules/pyflakes/mod.rs | ||
--- | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from sqlalchemy.orm import DeclarativeBase, Mapped | ||
|
||
if TYPE_CHECKING: | ||
from whatever import whatever | ||
|
||
|
||
class Base(DeclarativeBase): | ||
some_mapping: Mapped[list[Bar]] | None = None # F821 Undefined name `Bar` | ||
simplified: list[Bar] | None = None # F821 Undefined name `Bar` | ||
bad: whatever | ||
|
||
|
||
class Bar: | ||
pass |