mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-28 23:43:53 +00:00
Improve handling of builtin symbols in linter rules (#10919)
Add a new method to the semantic model to simplify and improve the correctness of a common pattern
This commit is contained in:
parent
effd5188c9
commit
f779babc5f
93 changed files with 886 additions and 588 deletions
|
@ -5,12 +5,13 @@
|
|||
pub fn is_standard_library_generic(qualified_name: &[&str]) -> bool {
|
||||
matches!(
|
||||
qualified_name,
|
||||
["", "dict" | "frozenset" | "list" | "set" | "tuple" | "type"]
|
||||
| [
|
||||
"collections" | "typing" | "typing_extensions",
|
||||
"ChainMap" | "Counter"
|
||||
]
|
||||
| ["collections" | "typing", "OrderedDict"]
|
||||
[
|
||||
"" | "builtins",
|
||||
"dict" | "frozenset" | "list" | "set" | "tuple" | "type"
|
||||
] | [
|
||||
"collections" | "typing" | "typing_extensions",
|
||||
"ChainMap" | "Counter"
|
||||
] | ["collections" | "typing", "OrderedDict"]
|
||||
| ["collections", "defaultdict" | "deque"]
|
||||
| [
|
||||
"collections",
|
||||
|
@ -247,7 +248,7 @@ pub fn is_immutable_non_generic_type(qualified_name: &[&str]) -> bool {
|
|||
pub fn is_immutable_generic_type(qualified_name: &[&str]) -> bool {
|
||||
matches!(
|
||||
qualified_name,
|
||||
["", "tuple"]
|
||||
["" | "builtins", "tuple"]
|
||||
| [
|
||||
"collections",
|
||||
"abc",
|
||||
|
@ -285,7 +286,7 @@ pub fn is_immutable_generic_type(qualified_name: &[&str]) -> bool {
|
|||
pub fn is_mutable_return_type(qualified_name: &[&str]) -> bool {
|
||||
matches!(
|
||||
qualified_name,
|
||||
["", "dict" | "list" | "set"]
|
||||
["" | "builtins", "dict" | "list" | "set"]
|
||||
| [
|
||||
"collections",
|
||||
"Counter" | "OrderedDict" | "defaultdict" | "deque"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue