mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-27 15:03:51 +00:00
Add autofix for magic methods (ANN204
) (#3633)
This commit is contained in:
parent
f039bf36a2
commit
f70a49ed8b
7 changed files with 405 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
use once_cell::sync::Lazy;
|
||||
use rustc_hash::FxHashSet;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
// See: https://pypi.org/project/typing-extensions/
|
||||
pub static TYPING_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
|
||||
|
@ -197,3 +197,24 @@ pub const PEP_585_BUILTINS_ELIGIBLE: &[&[&str]] = &[
|
|||
&["typing", "Type"],
|
||||
&["typing_extensions", "Type"],
|
||||
];
|
||||
|
||||
// See: https://github.com/JelleZijlstra/autotyping/blob/f65b5ee3a8fdb77999f84b4c87edb996e25269a5/autotyping/autotyping.py#L69-L84
|
||||
pub static SIMPLE_MAGIC_RETURN_TYPES: Lazy<FxHashMap<&'static str, &'static str>> =
|
||||
Lazy::new(|| {
|
||||
FxHashMap::from_iter([
|
||||
("__str__", "str"),
|
||||
("__repr__", "str"),
|
||||
("__len__", "int"),
|
||||
("__length_hint__", "int"),
|
||||
("__init__", "None"),
|
||||
("__del__", "None"),
|
||||
("__bool__", "bool"),
|
||||
("__bytes__", "bytes"),
|
||||
("__format__", "str"),
|
||||
("__contains__", "bool"),
|
||||
("__complex__", "complex"),
|
||||
("__int__", "int"),
|
||||
("__float__", "float"),
|
||||
("__index__", "int"),
|
||||
])
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue