-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Respect local subclasses in
flake8-type-checking
(#8768)
If you define a subclass of `pydantic.BaseModel`, and then a subclass of _that_ class in the same file, we'll now correctly treat it as runtime-evaluated. Closes #7893.
- Loading branch information
1 parent
94178a0
commit 00a015c
Showing
5 changed files
with
80 additions
and
34 deletions.
There are no files selected for viewing
11 changes: 6 additions & 5 deletions
11
...f_linter/resources/test/fixtures/flake8_type_checking/runtime_evaluated_base_classes_5.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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
from __future__ import annotations | ||
|
||
from collections.abc import Sequence # TCH003 | ||
from pandas import DataFrame | ||
from pydantic import BaseModel | ||
|
||
|
||
class MyBaseClass: | ||
pass | ||
class Parent(BaseModel): | ||
... | ||
|
||
|
||
class Foo(MyBaseClass): | ||
foo: Sequence | ||
class Child(Parent): | ||
baz: DataFrame |
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
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
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
..._checking__tests__typing-only-third-party-import_runtime_evaluated_base_classes_5.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/flake8_type_checking/mod.rs | ||
--- | ||
|