mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Avoid treating deferred string annotations as required-at-runtime (#2779)
This commit is contained in:
parent
74731a3456
commit
5a70a573cd
4 changed files with 17 additions and 13 deletions
|
@ -44,7 +44,7 @@ def f():
|
|||
|
||||
|
||||
def f():
|
||||
import pandas as pd
|
||||
import pandas as pd # TCH002
|
||||
|
||||
x = dict["pd.DataFrame", "pd.DataFrame"]
|
||||
|
||||
|
|
|
@ -3900,7 +3900,10 @@ impl<'a> Checker<'a> {
|
|||
}
|
||||
|
||||
pub const fn execution_context(&self) -> ExecutionContext {
|
||||
if self.in_type_checking_block || self.in_annotation {
|
||||
if self.in_type_checking_block
|
||||
|| self.in_annotation
|
||||
|| self.in_deferred_string_type_definition
|
||||
{
|
||||
ExecutionContext::Typing
|
||||
} else {
|
||||
ExecutionContext::Runtime
|
||||
|
|
|
@ -2,15 +2,5 @@
|
|||
source: crates/ruff/src/rules/flake8_type_checking/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
RuntimeImportInTypeCheckingBlock:
|
||||
full_name: typing.Any
|
||||
location:
|
||||
row: 5
|
||||
column: 23
|
||||
end_location:
|
||||
row: 5
|
||||
column: 26
|
||||
fix: ~
|
||||
parent: ~
|
||||
[]
|
||||
|
||||
|
|
|
@ -79,4 +79,15 @@ expression: diagnostics
|
|||
column: 23
|
||||
fix: ~
|
||||
parent: ~
|
||||
- kind:
|
||||
TypingOnlyThirdPartyImport:
|
||||
full_name: pandas
|
||||
location:
|
||||
row: 47
|
||||
column: 11
|
||||
end_location:
|
||||
row: 47
|
||||
column: 23
|
||||
fix: ~
|
||||
parent: ~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue