mirror of https://github.com/astral-sh/ruff
[`ruff`] Fix false positive for t-strings in `default-factory-kwarg` (`RUF026`) (#20032)
Closes #19993 ## Summary Recognize t strings as never being callable to avoid false positives on RUF026.
This commit is contained in:
parent
11f521c768
commit
c22395dbc6
|
|
@ -118,3 +118,10 @@ def func():
|
||||||
return lambda: value
|
return lambda: value
|
||||||
|
|
||||||
defaultdict(constant_factory("<missing>"))
|
defaultdict(constant_factory("<missing>"))
|
||||||
|
|
||||||
|
def func():
|
||||||
|
defaultdict(default_factory=t"") # OK
|
||||||
|
|
||||||
|
|
||||||
|
def func():
|
||||||
|
defaultdict(default_factory=t"hello") # OK
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,8 @@ fn is_non_callable_value(value: &Expr) -> bool {
|
||||||
| Expr::SetComp(_)
|
| Expr::SetComp(_)
|
||||||
| Expr::DictComp(_)
|
| Expr::DictComp(_)
|
||||||
| Expr::Generator(_)
|
| Expr::Generator(_)
|
||||||
| Expr::FString(_))
|
| Expr::FString(_)
|
||||||
|
| Expr::TString(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generate an [`Expr`] to replace `defaultdict(default_factory=callable)` with
|
/// Generate an [`Expr`] to replace `defaultdict(default_factory=callable)` with
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue