[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:
Max Mynter 2025-08-22 16:29:42 +02:00 committed by GitHub
parent 11f521c768
commit c22395dbc6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -118,3 +118,10 @@ def func():
return lambda: value
defaultdict(constant_factory("<missing>"))
def func():
defaultdict(default_factory=t"") # OK
def func():
defaultdict(default_factory=t"hello") # OK

View file

@ -123,7 +123,8 @@ fn is_non_callable_value(value: &Expr) -> bool {
| Expr::SetComp(_)
| Expr::DictComp(_)
| Expr::Generator(_)
| Expr::FString(_))
| Expr::FString(_)
| Expr::TString(_))
}
/// Generate an [`Expr`] to replace `defaultdict(default_factory=callable)` with