mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Short-circuit typing matches based on imports (#9800)
This commit is contained in:
parent
c53aae0b6f
commit
5c99967c4d
11 changed files with 128 additions and 48 deletions
|
@ -161,6 +161,11 @@ pub fn to_pep604_operator(
|
|||
}
|
||||
}
|
||||
|
||||
// If the typing modules were never imported, we'll never match below.
|
||||
if !semantic.seen_typing() {
|
||||
return None;
|
||||
}
|
||||
|
||||
// If the slice is a forward reference (e.g., `Optional["Foo"]`), it can only be rewritten
|
||||
// if we're in a typing-only context.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue