mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Remove remove-six-compat (UP016) (#2332)
This commit is contained in:
parent
0a6d2294a7
commit
3ee6a90905
10 changed files with 1 additions and 1479 deletions
|
@ -794,7 +794,6 @@ For more, see [pyupgrade](https://pypi.org/project/pyupgrade/) on PyPI.
|
|||
| UP013 | convert-typed-dict-functional-to-class | Convert `{name}` from `TypedDict` functional to class syntax | 🛠 |
|
||||
| UP014 | convert-named-tuple-functional-to-class | Convert `{name}` from `NamedTuple` functional to class syntax | 🛠 |
|
||||
| UP015 | redundant-open-modes | Unnecessary open mode parameters | 🛠 |
|
||||
| UP016 | remove-six-compat | Unnecessary `six` compatibility usage | 🛠 |
|
||||
| UP017 | datetime-timezone-utc | Use `datetime.UTC` alias | 🛠 |
|
||||
| UP018 | native-literals | Unnecessary call to `{literal_type}` | 🛠 |
|
||||
| UP019 | typing-text-str-alias | `typing.Text` is deprecated, use `str` | 🛠 |
|
||||
|
|
87
resources/test/fixtures/pyupgrade/UP016.py
vendored
87
resources/test/fixtures/pyupgrade/UP016.py
vendored
|
@ -1,87 +0,0 @@
|
|||
# Replace names by built-in names, whether namespaced or not
|
||||
# https://github.com/search?q=%22from+six+import%22&type=code
|
||||
import six
|
||||
from six.moves import map # No need
|
||||
from six import text_type
|
||||
|
||||
six.text_type # str
|
||||
six.binary_type # bytes
|
||||
six.class_types # (type,)
|
||||
six.string_types # (str,)
|
||||
six.integer_types # (int,)
|
||||
six.unichr # chr
|
||||
six.iterbytes # iter
|
||||
six.print_(...) # print(...)
|
||||
six.exec_(c, g, l) # exec(c, g, l)
|
||||
six.advance_iterator(it) # next(it)
|
||||
six.next(it) # next(it)
|
||||
six.callable(x) # callable(x)
|
||||
six.moves.range(x) # range(x)
|
||||
six.moves.xrange(x) # range(x)
|
||||
isinstance(..., six.class_types) # isinstance(..., type)
|
||||
issubclass(..., six.integer_types) # issubclass(..., int)
|
||||
isinstance(..., six.string_types) # isinstance(..., str)
|
||||
|
||||
# Replace call on arg by method call on arg
|
||||
six.iteritems(dct) # dct.items()
|
||||
six.iterkeys(dct) # dct.keys()
|
||||
six.itervalues(dct) # dct.values()
|
||||
six.viewitems(dct) # dct.items()
|
||||
six.viewkeys(dct) # dct.keys()
|
||||
six.viewvalues(dct) # dct.values()
|
||||
six.assertCountEqual(self, a1, a2) # self.assertCountEqual(a1, a2)
|
||||
six.assertRaisesRegex(self, e, r, fn) # self.assertRaisesRegex(e, r, fn)
|
||||
six.assertRegex(self, s, r) # self.assertRegex(s, r)
|
||||
|
||||
# Replace call on arg by arg attribute
|
||||
six.get_method_function(meth) # meth.__func__
|
||||
six.get_method_self(meth) # meth.__self__
|
||||
six.get_function_closure(fn) # fn.__closure__
|
||||
six.get_function_code(fn) # fn.__code__
|
||||
six.get_function_defaults(fn) # fn.__defaults__
|
||||
six.get_function_globals(fn) # fn.__globals__
|
||||
|
||||
# Replace by string literal
|
||||
six.b("...") # b'...'
|
||||
six.u("...") # '...'
|
||||
six.ensure_binary("...") # b'...'
|
||||
six.ensure_str("...") # '...'
|
||||
six.ensure_text("...") # '...'
|
||||
six.b(string) # no change
|
||||
|
||||
# Replace by simple expression
|
||||
six.get_unbound_function(meth) # meth
|
||||
six.create_unbound_method(fn, cls) # fn
|
||||
|
||||
# Raise exception
|
||||
six.raise_from(exc, exc_from) # raise exc from exc_from
|
||||
six.reraise(tp, exc, tb) # raise exc.with_traceback(tb)
|
||||
six.reraise(*sys.exc_info()) # raise
|
||||
|
||||
# Int / Bytes conversion
|
||||
six.byte2int(bs) # bs[0]
|
||||
six.indexbytes(bs, i) # bs[i]
|
||||
six.int2byte(i) # bytes((i, ))
|
||||
|
||||
# Special cases for next calls
|
||||
next(six.iteritems(dct)) # next(iter(dct.items()))
|
||||
next(six.iterkeys(dct)) # next(iter(dct.keys()))
|
||||
next(six.itervalues(dct)) # next(iter(dct.values()))
|
||||
|
||||
# TODO: To implement
|
||||
|
||||
|
||||
# Rewrite classes
|
||||
@six.python_2_unicode_compatible # Remove
|
||||
class C(six.Iterator):
|
||||
pass # class C: pass
|
||||
|
||||
|
||||
class C(six.with_metaclass(M, B)):
|
||||
pass # class C(B, metaclass=M): pass
|
||||
|
||||
|
||||
# class C(B, metaclass=M): pass
|
||||
@six.add_metaclass(M)
|
||||
class C(B):
|
||||
pass
|
|
@ -1870,7 +1870,6 @@
|
|||
"UP013",
|
||||
"UP014",
|
||||
"UP015",
|
||||
"UP016",
|
||||
"UP017",
|
||||
"UP018",
|
||||
"UP019",
|
||||
|
|
|
@ -2089,11 +2089,6 @@ where
|
|||
{
|
||||
pyupgrade::rules::use_pep585_annotation(self, expr);
|
||||
}
|
||||
|
||||
if self.settings.rules.enabled(&Rule::RemoveSixCompat) {
|
||||
pyupgrade::rules::remove_six_compat(self, expr);
|
||||
}
|
||||
|
||||
if self.settings.rules.enabled(&Rule::DatetimeTimezoneUTC)
|
||||
&& self.settings.target_version >= PythonVersion::Py311
|
||||
{
|
||||
|
@ -2105,16 +2100,13 @@ where
|
|||
if self.settings.rules.enabled(&Rule::RewriteMockImport) {
|
||||
pyupgrade::rules::rewrite_mock_attribute(self, expr);
|
||||
}
|
||||
|
||||
if self.settings.rules.enabled(&Rule::SixPY3Referenced) {
|
||||
flake8_2020::rules::name_or_attribute(self, expr);
|
||||
}
|
||||
|
||||
pandas_vet::rules::check_attr(self, attr, value, expr);
|
||||
|
||||
if self.settings.rules.enabled(&Rule::BannedApi) {
|
||||
flake8_tidy_imports::banned_api::banned_attribute_access(self, expr);
|
||||
}
|
||||
pandas_vet::rules::check_attr(self, attr, value, expr);
|
||||
}
|
||||
ExprKind::Call {
|
||||
func,
|
||||
|
@ -2227,9 +2219,6 @@ where
|
|||
if self.settings.rules.enabled(&Rule::RedundantOpenModes) {
|
||||
pyupgrade::rules::redundant_open_modes(self, expr);
|
||||
}
|
||||
if self.settings.rules.enabled(&Rule::RemoveSixCompat) {
|
||||
pyupgrade::rules::remove_six_compat(self, expr);
|
||||
}
|
||||
if self.settings.rules.enabled(&Rule::NativeLiterals) {
|
||||
pyupgrade::rules::native_literals(self, expr, func, args, keywords);
|
||||
}
|
||||
|
|
|
@ -237,7 +237,6 @@ ruff_macros::define_rule_mapping!(
|
|||
UP013 => violations::ConvertTypedDictFunctionalToClass,
|
||||
UP014 => violations::ConvertNamedTupleFunctionalToClass,
|
||||
UP015 => violations::RedundantOpenModes,
|
||||
UP016 => violations::RemoveSixCompat,
|
||||
UP017 => violations::DatetimeTimezoneUTC,
|
||||
UP018 => violations::NativeLiterals,
|
||||
UP019 => violations::TypingTextStrAlias,
|
||||
|
|
|
@ -35,7 +35,6 @@ mod tests {
|
|||
#[test_case(Rule::ConvertTypedDictFunctionalToClass, Path::new("UP013.py"); "UP013")]
|
||||
#[test_case(Rule::ConvertNamedTupleFunctionalToClass, Path::new("UP014.py"); "UP014")]
|
||||
#[test_case(Rule::RedundantOpenModes, Path::new("UP015.py"); "UP015")]
|
||||
#[test_case(Rule::RemoveSixCompat, Path::new("UP016.py"); "UP016")]
|
||||
#[test_case(Rule::NativeLiterals, Path::new("UP018.py"); "UP018")]
|
||||
#[test_case(Rule::TypingTextStrAlias, Path::new("UP019.py"); "UP019")]
|
||||
#[test_case(Rule::ReplaceUniversalNewlines, Path::new("UP021.py"); "UP021")]
|
||||
|
|
|
@ -14,7 +14,6 @@ pub(crate) use os_error_alias::os_error_alias;
|
|||
pub(crate) use printf_string_formatting::printf_string_formatting;
|
||||
pub(crate) use redundant_open_modes::redundant_open_modes;
|
||||
use regex::Regex;
|
||||
pub(crate) use remove_six_compat::remove_six_compat;
|
||||
pub(crate) use replace_stdout_stderr::replace_stdout_stderr;
|
||||
pub(crate) use replace_universal_newlines::replace_universal_newlines;
|
||||
pub(crate) use rewrite_c_element_tree::replace_c_element_tree;
|
||||
|
@ -55,7 +54,6 @@ mod open_alias;
|
|||
mod os_error_alias;
|
||||
mod printf_string_formatting;
|
||||
mod redundant_open_modes;
|
||||
mod remove_six_compat;
|
||||
mod replace_stdout_stderr;
|
||||
mod replace_universal_newlines;
|
||||
mod rewrite_c_element_tree;
|
||||
|
|
|
@ -1,437 +0,0 @@
|
|||
use rustpython_ast::{Constant, Expr, ExprContext, ExprKind, Keyword, StmtKind};
|
||||
|
||||
use crate::ast::helpers::{create_expr, create_stmt, unparse_expr, unparse_stmt};
|
||||
use crate::ast::types::Range;
|
||||
use crate::checkers::ast::Checker;
|
||||
use crate::fix::Fix;
|
||||
use crate::registry::{Diagnostic, Rule};
|
||||
use crate::source_code::{Locator, Stylist};
|
||||
use crate::violations;
|
||||
|
||||
/// Return `true` if the call path is a reference to `${module}.${any}`.
|
||||
fn is_module_member(call_path: &[&str], module: &str) -> bool {
|
||||
call_path
|
||||
.first()
|
||||
.map_or(false, |module_name| *module_name == module)
|
||||
}
|
||||
|
||||
fn map_name(name: &str, expr: &Expr, patch: bool) -> Option<Diagnostic> {
|
||||
let replacement = match name {
|
||||
"text_type" => Some("str"),
|
||||
"binary_type" => Some("bytes"),
|
||||
"class_types" => Some("(type,)"),
|
||||
"string_types" => Some("(str,)"),
|
||||
"integer_types" => Some("(int,)"),
|
||||
"unichr" => Some("chr"),
|
||||
"iterbytes" => Some("iter"),
|
||||
"print_" => Some("print"),
|
||||
"exec_" => Some("exec"),
|
||||
"advance_iterator" => Some("next"),
|
||||
"next" => Some("next"),
|
||||
"range" => Some("range"), // TODO: six.moves
|
||||
"xrange" => Some("range"), // TODO: six.moves
|
||||
"callable" => Some("callable"),
|
||||
_ => None,
|
||||
};
|
||||
if let Some(replacement) = replacement {
|
||||
let mut diagnostic =
|
||||
Diagnostic::new(violations::RemoveSixCompat, Range::from_located(expr));
|
||||
if patch {
|
||||
diagnostic.amend(Fix::replacement(
|
||||
replacement.to_string(),
|
||||
expr.location,
|
||||
expr.end_location.unwrap(),
|
||||
));
|
||||
}
|
||||
Some(diagnostic)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn replace_by_str_literal(
|
||||
arg: &Expr,
|
||||
binary: bool,
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
locator: &Locator,
|
||||
) -> Option<Diagnostic> {
|
||||
match &arg.node {
|
||||
ExprKind::Constant { .. } => {
|
||||
let mut diagnostic =
|
||||
Diagnostic::new(violations::RemoveSixCompat, Range::from_located(expr));
|
||||
if patch {
|
||||
let content = format!(
|
||||
"{}{}",
|
||||
if binary { "b" } else { "" },
|
||||
locator.slice_source_code_range(&Range::new(
|
||||
arg.location,
|
||||
arg.end_location.unwrap(),
|
||||
))
|
||||
);
|
||||
diagnostic.amend(Fix::replacement(
|
||||
content,
|
||||
expr.location,
|
||||
expr.end_location.unwrap(),
|
||||
));
|
||||
};
|
||||
Some(diagnostic)
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
// `func(arg)` => `arg.attr`
|
||||
fn replace_call_on_arg_by_arg_attribute(
|
||||
attr: &str,
|
||||
arg: &Expr,
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
) -> Diagnostic {
|
||||
let attribute = ExprKind::Attribute {
|
||||
value: Box::new(arg.clone()),
|
||||
attr: attr.to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
};
|
||||
replace_by_expr_kind(attribute, expr, patch, stylist)
|
||||
}
|
||||
|
||||
// `func(arg, **args)` => `arg.method(**args)`
|
||||
fn replace_call_on_arg_by_arg_method_call(
|
||||
method_name: &str,
|
||||
args: &[Expr],
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
) -> Option<Diagnostic> {
|
||||
if args.is_empty() {
|
||||
None
|
||||
} else if let ([arg], other_args) = args.split_at(1) {
|
||||
let call = ExprKind::Call {
|
||||
func: Box::new(create_expr(ExprKind::Attribute {
|
||||
value: Box::new(arg.clone()),
|
||||
attr: method_name.to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
args: other_args
|
||||
.iter()
|
||||
.map(|arg| create_expr(arg.node.clone()))
|
||||
.collect(),
|
||||
keywords: vec![],
|
||||
};
|
||||
Some(replace_by_expr_kind(call, expr, patch, stylist))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// `expr` => `Expr(expr_kind)`
|
||||
fn replace_by_expr_kind(node: ExprKind, expr: &Expr, patch: bool, stylist: &Stylist) -> Diagnostic {
|
||||
let mut diagnostic = Diagnostic::new(violations::RemoveSixCompat, Range::from_located(expr));
|
||||
if patch {
|
||||
diagnostic.amend(Fix::replacement(
|
||||
unparse_expr(&create_expr(node), stylist),
|
||||
expr.location,
|
||||
expr.end_location.unwrap(),
|
||||
));
|
||||
}
|
||||
diagnostic
|
||||
}
|
||||
|
||||
fn replace_by_stmt_kind(node: StmtKind, expr: &Expr, patch: bool, stylist: &Stylist) -> Diagnostic {
|
||||
let mut diagnostic = Diagnostic::new(violations::RemoveSixCompat, Range::from_located(expr));
|
||||
if patch {
|
||||
diagnostic.amend(Fix::replacement(
|
||||
unparse_stmt(&create_stmt(node), stylist),
|
||||
expr.location,
|
||||
expr.end_location.unwrap(),
|
||||
));
|
||||
}
|
||||
diagnostic
|
||||
}
|
||||
|
||||
// => `raise exc from cause`
|
||||
fn replace_by_raise_from(
|
||||
exc: Option<ExprKind>,
|
||||
cause: Option<ExprKind>,
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
) -> Diagnostic {
|
||||
let stmt_kind = StmtKind::Raise {
|
||||
exc: exc.map(|exc| Box::new(create_expr(exc))),
|
||||
cause: cause.map(|cause| Box::new(create_expr(cause))),
|
||||
};
|
||||
replace_by_stmt_kind(stmt_kind, expr, patch, stylist)
|
||||
}
|
||||
|
||||
fn replace_by_index_on_arg(
|
||||
arg: &Expr,
|
||||
index: &ExprKind,
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
) -> Diagnostic {
|
||||
let index = ExprKind::Subscript {
|
||||
value: Box::new(create_expr(arg.node.clone())),
|
||||
slice: Box::new(create_expr(index.clone())),
|
||||
ctx: ExprContext::Load,
|
||||
};
|
||||
replace_by_expr_kind(index, expr, patch, stylist)
|
||||
}
|
||||
|
||||
fn handle_reraise(
|
||||
args: &[Expr],
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
) -> Option<Diagnostic> {
|
||||
if let [_, exc, tb] = args {
|
||||
Some(replace_by_raise_from(
|
||||
Some(ExprKind::Call {
|
||||
func: Box::new(create_expr(ExprKind::Attribute {
|
||||
value: Box::new(create_expr(exc.node.clone())),
|
||||
attr: "with_traceback".to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
args: vec![create_expr(tb.node.clone())],
|
||||
keywords: vec![],
|
||||
}),
|
||||
None,
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
))
|
||||
} else if let [arg] = args {
|
||||
if let ExprKind::Starred { value, .. } = &arg.node {
|
||||
if let ExprKind::Call { func, .. } = &value.node {
|
||||
if let ExprKind::Attribute { value, attr, .. } = &func.node {
|
||||
if let ExprKind::Name { id, .. } = &value.node {
|
||||
if id == "sys" && attr == "exc_info" {
|
||||
return Some(replace_by_raise_from(None, None, expr, patch, stylist));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
None
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_func(
|
||||
func: &Expr,
|
||||
args: &[Expr],
|
||||
keywords: &[Keyword],
|
||||
expr: &Expr,
|
||||
patch: bool,
|
||||
stylist: &Stylist,
|
||||
locator: &Locator,
|
||||
) -> Option<Diagnostic> {
|
||||
let func_name = match &func.node {
|
||||
ExprKind::Attribute { attr, .. } => attr,
|
||||
ExprKind::Name { id, .. } => id,
|
||||
_ => return None,
|
||||
};
|
||||
match (func_name.as_str(), args, keywords) {
|
||||
("b", [arg], []) => replace_by_str_literal(arg, true, expr, patch, locator),
|
||||
("ensure_binary", [arg], []) => replace_by_str_literal(arg, true, expr, patch, locator),
|
||||
("u", [arg], []) => replace_by_str_literal(arg, false, expr, patch, locator),
|
||||
("ensure_str", [arg], []) => replace_by_str_literal(arg, false, expr, patch, locator),
|
||||
("ensure_text", [arg], []) => replace_by_str_literal(arg, false, expr, patch, locator),
|
||||
("iteritems", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("items", args, expr, patch, stylist)
|
||||
}
|
||||
("viewitems", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("items", args, expr, patch, stylist)
|
||||
}
|
||||
("iterkeys", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("keys", args, expr, patch, stylist)
|
||||
}
|
||||
("viewkeys", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("keys", args, expr, patch, stylist)
|
||||
}
|
||||
("itervalues", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("values", args, expr, patch, stylist)
|
||||
}
|
||||
("viewvalues", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("values", args, expr, patch, stylist)
|
||||
}
|
||||
("get_method_function", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__func__", arg, expr, patch, stylist,
|
||||
)),
|
||||
("get_method_self", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__self__", arg, expr, patch, stylist,
|
||||
)),
|
||||
("get_function_closure", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__closure__",
|
||||
arg,
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("get_function_code", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__code__", arg, expr, patch, stylist,
|
||||
)),
|
||||
("get_function_defaults", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__defaults__",
|
||||
arg,
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("get_function_globals", [arg], []) => Some(replace_call_on_arg_by_arg_attribute(
|
||||
"__globals__",
|
||||
arg,
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("create_unbound_method", [arg, _], _) => {
|
||||
Some(replace_by_expr_kind(arg.node.clone(), expr, patch, stylist))
|
||||
}
|
||||
("get_unbound_function", [arg], []) => {
|
||||
Some(replace_by_expr_kind(arg.node.clone(), expr, patch, stylist))
|
||||
}
|
||||
("assertCountEqual", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("assertCountEqual", args, expr, patch, stylist)
|
||||
}
|
||||
("assertRaisesRegex", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("assertRaisesRegex", args, expr, patch, stylist)
|
||||
}
|
||||
("assertRegex", args, []) => {
|
||||
replace_call_on_arg_by_arg_method_call("assertRegex", args, expr, patch, stylist)
|
||||
}
|
||||
("raise_from", [exc, cause], []) => Some(replace_by_raise_from(
|
||||
Some(exc.node.clone()),
|
||||
Some(cause.node.clone()),
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("reraise", args, []) => handle_reraise(args, expr, patch, stylist),
|
||||
("byte2int", [arg], []) => Some(replace_by_index_on_arg(
|
||||
arg,
|
||||
&ExprKind::Constant {
|
||||
value: Constant::Int(0.into()),
|
||||
kind: None,
|
||||
},
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("indexbytes", [arg, index], []) => Some(replace_by_index_on_arg(
|
||||
arg,
|
||||
&index.node,
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
("int2byte", [arg], []) => Some(replace_by_expr_kind(
|
||||
ExprKind::Call {
|
||||
func: Box::new(create_expr(ExprKind::Name {
|
||||
id: "bytes".to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
args: vec![create_expr(ExprKind::Tuple {
|
||||
elts: vec![create_expr(arg.node.clone())],
|
||||
ctx: ExprContext::Load,
|
||||
})],
|
||||
keywords: vec![],
|
||||
},
|
||||
expr,
|
||||
patch,
|
||||
stylist,
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_next_on_six_dict(expr: &Expr, patch: bool, checker: &Checker) -> Option<Diagnostic> {
|
||||
let ExprKind::Call { func, args, .. } = &expr.node else {
|
||||
return None;
|
||||
};
|
||||
let ExprKind::Name { id, .. } = &func.node else {
|
||||
return None;
|
||||
};
|
||||
if id != "next" {
|
||||
return None;
|
||||
}
|
||||
let [arg] = &args[..] else { return None; };
|
||||
if !checker
|
||||
.resolve_call_path(arg)
|
||||
.map_or(false, |call_path| is_module_member(&call_path, "six"))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let ExprKind::Call { func, args, .. } = &arg.node else {return None;};
|
||||
let ExprKind::Attribute { attr, .. } = &func.node else {return None;};
|
||||
let [dict_arg] = &args[..] else {return None;};
|
||||
let method_name = match attr.as_str() {
|
||||
"iteritems" => "items",
|
||||
"iterkeys" => "keys",
|
||||
"itervalues" => "values",
|
||||
_ => return None,
|
||||
};
|
||||
Some(replace_by_expr_kind(
|
||||
ExprKind::Call {
|
||||
func: Box::new(create_expr(ExprKind::Name {
|
||||
id: "iter".to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
args: vec![create_expr(ExprKind::Call {
|
||||
func: Box::new(create_expr(ExprKind::Attribute {
|
||||
value: Box::new(dict_arg.clone()),
|
||||
attr: method_name.to_string(),
|
||||
ctx: ExprContext::Load,
|
||||
})),
|
||||
args: vec![],
|
||||
keywords: vec![],
|
||||
})],
|
||||
keywords: vec![],
|
||||
},
|
||||
arg,
|
||||
patch,
|
||||
checker.stylist,
|
||||
))
|
||||
}
|
||||
|
||||
/// UP016
|
||||
pub fn remove_six_compat(checker: &mut Checker, expr: &Expr) {
|
||||
if let Some(diagnostic) =
|
||||
handle_next_on_six_dict(expr, checker.patch(&Rule::RemoveSixCompat), checker)
|
||||
{
|
||||
checker.diagnostics.push(diagnostic);
|
||||
return;
|
||||
}
|
||||
|
||||
if checker
|
||||
.resolve_call_path(expr)
|
||||
.map_or(false, |call_path| is_module_member(&call_path, "six"))
|
||||
{
|
||||
let patch = checker.patch(&Rule::RemoveSixCompat);
|
||||
let diagnostic = match &expr.node {
|
||||
ExprKind::Call {
|
||||
func,
|
||||
args,
|
||||
keywords,
|
||||
} => handle_func(
|
||||
func,
|
||||
args,
|
||||
keywords,
|
||||
expr,
|
||||
patch,
|
||||
checker.stylist,
|
||||
checker.locator,
|
||||
),
|
||||
ExprKind::Attribute { attr, .. } => map_name(attr.as_str(), expr, patch),
|
||||
ExprKind::Name { id, .. } => map_name(id.as_str(), expr, patch),
|
||||
_ => return,
|
||||
};
|
||||
if let Some(diagnostic) = diagnostic {
|
||||
checker.diagnostics.push(diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,923 +0,0 @@
|
|||
---
|
||||
source: src/rules/pyupgrade/mod.rs
|
||||
expression: diagnostics
|
||||
---
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 13
|
||||
fix:
|
||||
content:
|
||||
- str
|
||||
location:
|
||||
row: 7
|
||||
column: 0
|
||||
end_location:
|
||||
row: 7
|
||||
column: 13
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 15
|
||||
fix:
|
||||
content:
|
||||
- bytes
|
||||
location:
|
||||
row: 8
|
||||
column: 0
|
||||
end_location:
|
||||
row: 8
|
||||
column: 15
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 15
|
||||
fix:
|
||||
content:
|
||||
- "(type,)"
|
||||
location:
|
||||
row: 9
|
||||
column: 0
|
||||
end_location:
|
||||
row: 9
|
||||
column: 15
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 16
|
||||
fix:
|
||||
content:
|
||||
- "(str,)"
|
||||
location:
|
||||
row: 10
|
||||
column: 0
|
||||
end_location:
|
||||
row: 10
|
||||
column: 16
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 11
|
||||
column: 0
|
||||
end_location:
|
||||
row: 11
|
||||
column: 17
|
||||
fix:
|
||||
content:
|
||||
- "(int,)"
|
||||
location:
|
||||
row: 11
|
||||
column: 0
|
||||
end_location:
|
||||
row: 11
|
||||
column: 17
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 12
|
||||
column: 10
|
||||
fix:
|
||||
content:
|
||||
- chr
|
||||
location:
|
||||
row: 12
|
||||
column: 0
|
||||
end_location:
|
||||
row: 12
|
||||
column: 10
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 13
|
||||
fix:
|
||||
content:
|
||||
- iter
|
||||
location:
|
||||
row: 13
|
||||
column: 0
|
||||
end_location:
|
||||
row: 13
|
||||
column: 13
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 14
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 10
|
||||
fix:
|
||||
content:
|
||||
- print
|
||||
location:
|
||||
row: 14
|
||||
column: 0
|
||||
end_location:
|
||||
row: 14
|
||||
column: 10
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 15
|
||||
column: 0
|
||||
end_location:
|
||||
row: 15
|
||||
column: 9
|
||||
fix:
|
||||
content:
|
||||
- exec
|
||||
location:
|
||||
row: 15
|
||||
column: 0
|
||||
end_location:
|
||||
row: 15
|
||||
column: 9
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 16
|
||||
column: 20
|
||||
fix:
|
||||
content:
|
||||
- next
|
||||
location:
|
||||
row: 16
|
||||
column: 0
|
||||
end_location:
|
||||
row: 16
|
||||
column: 20
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 17
|
||||
column: 0
|
||||
end_location:
|
||||
row: 17
|
||||
column: 8
|
||||
fix:
|
||||
content:
|
||||
- next
|
||||
location:
|
||||
row: 17
|
||||
column: 0
|
||||
end_location:
|
||||
row: 17
|
||||
column: 8
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 18
|
||||
column: 12
|
||||
fix:
|
||||
content:
|
||||
- callable
|
||||
location:
|
||||
row: 18
|
||||
column: 0
|
||||
end_location:
|
||||
row: 18
|
||||
column: 12
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 15
|
||||
fix:
|
||||
content:
|
||||
- range
|
||||
location:
|
||||
row: 19
|
||||
column: 0
|
||||
end_location:
|
||||
row: 19
|
||||
column: 15
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 20
|
||||
column: 0
|
||||
end_location:
|
||||
row: 20
|
||||
column: 16
|
||||
fix:
|
||||
content:
|
||||
- range
|
||||
location:
|
||||
row: 20
|
||||
column: 0
|
||||
end_location:
|
||||
row: 20
|
||||
column: 16
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 21
|
||||
column: 16
|
||||
end_location:
|
||||
row: 21
|
||||
column: 31
|
||||
fix:
|
||||
content:
|
||||
- "(type,)"
|
||||
location:
|
||||
row: 21
|
||||
column: 16
|
||||
end_location:
|
||||
row: 21
|
||||
column: 31
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 22
|
||||
column: 16
|
||||
end_location:
|
||||
row: 22
|
||||
column: 33
|
||||
fix:
|
||||
content:
|
||||
- "(int,)"
|
||||
location:
|
||||
row: 22
|
||||
column: 16
|
||||
end_location:
|
||||
row: 22
|
||||
column: 33
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 23
|
||||
column: 16
|
||||
end_location:
|
||||
row: 23
|
||||
column: 32
|
||||
fix:
|
||||
content:
|
||||
- "(str,)"
|
||||
location:
|
||||
row: 23
|
||||
column: 16
|
||||
end_location:
|
||||
row: 23
|
||||
column: 32
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 26
|
||||
column: 0
|
||||
end_location:
|
||||
row: 26
|
||||
column: 18
|
||||
fix:
|
||||
content:
|
||||
- dct.items()
|
||||
location:
|
||||
row: 26
|
||||
column: 0
|
||||
end_location:
|
||||
row: 26
|
||||
column: 18
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 27
|
||||
column: 0
|
||||
end_location:
|
||||
row: 27
|
||||
column: 17
|
||||
fix:
|
||||
content:
|
||||
- dct.keys()
|
||||
location:
|
||||
row: 27
|
||||
column: 0
|
||||
end_location:
|
||||
row: 27
|
||||
column: 17
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 28
|
||||
column: 0
|
||||
end_location:
|
||||
row: 28
|
||||
column: 19
|
||||
fix:
|
||||
content:
|
||||
- dct.values()
|
||||
location:
|
||||
row: 28
|
||||
column: 0
|
||||
end_location:
|
||||
row: 28
|
||||
column: 19
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 29
|
||||
column: 0
|
||||
end_location:
|
||||
row: 29
|
||||
column: 18
|
||||
fix:
|
||||
content:
|
||||
- dct.items()
|
||||
location:
|
||||
row: 29
|
||||
column: 0
|
||||
end_location:
|
||||
row: 29
|
||||
column: 18
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 30
|
||||
column: 0
|
||||
end_location:
|
||||
row: 30
|
||||
column: 17
|
||||
fix:
|
||||
content:
|
||||
- dct.keys()
|
||||
location:
|
||||
row: 30
|
||||
column: 0
|
||||
end_location:
|
||||
row: 30
|
||||
column: 17
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 31
|
||||
column: 0
|
||||
end_location:
|
||||
row: 31
|
||||
column: 19
|
||||
fix:
|
||||
content:
|
||||
- dct.values()
|
||||
location:
|
||||
row: 31
|
||||
column: 0
|
||||
end_location:
|
||||
row: 31
|
||||
column: 19
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 32
|
||||
column: 0
|
||||
end_location:
|
||||
row: 32
|
||||
column: 34
|
||||
fix:
|
||||
content:
|
||||
- "self.assertCountEqual(a1, a2)"
|
||||
location:
|
||||
row: 32
|
||||
column: 0
|
||||
end_location:
|
||||
row: 32
|
||||
column: 34
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 33
|
||||
column: 0
|
||||
end_location:
|
||||
row: 33
|
||||
column: 37
|
||||
fix:
|
||||
content:
|
||||
- "self.assertRaisesRegex(e, r, fn)"
|
||||
location:
|
||||
row: 33
|
||||
column: 0
|
||||
end_location:
|
||||
row: 33
|
||||
column: 37
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 34
|
||||
column: 0
|
||||
end_location:
|
||||
row: 34
|
||||
column: 27
|
||||
fix:
|
||||
content:
|
||||
- "self.assertRegex(s, r)"
|
||||
location:
|
||||
row: 34
|
||||
column: 0
|
||||
end_location:
|
||||
row: 34
|
||||
column: 27
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 37
|
||||
column: 0
|
||||
end_location:
|
||||
row: 37
|
||||
column: 29
|
||||
fix:
|
||||
content:
|
||||
- meth.__func__
|
||||
location:
|
||||
row: 37
|
||||
column: 0
|
||||
end_location:
|
||||
row: 37
|
||||
column: 29
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 38
|
||||
column: 0
|
||||
end_location:
|
||||
row: 38
|
||||
column: 25
|
||||
fix:
|
||||
content:
|
||||
- meth.__self__
|
||||
location:
|
||||
row: 38
|
||||
column: 0
|
||||
end_location:
|
||||
row: 38
|
||||
column: 25
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 39
|
||||
column: 0
|
||||
end_location:
|
||||
row: 39
|
||||
column: 28
|
||||
fix:
|
||||
content:
|
||||
- fn.__closure__
|
||||
location:
|
||||
row: 39
|
||||
column: 0
|
||||
end_location:
|
||||
row: 39
|
||||
column: 28
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 40
|
||||
column: 0
|
||||
end_location:
|
||||
row: 40
|
||||
column: 25
|
||||
fix:
|
||||
content:
|
||||
- fn.__code__
|
||||
location:
|
||||
row: 40
|
||||
column: 0
|
||||
end_location:
|
||||
row: 40
|
||||
column: 25
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 41
|
||||
column: 0
|
||||
end_location:
|
||||
row: 41
|
||||
column: 29
|
||||
fix:
|
||||
content:
|
||||
- fn.__defaults__
|
||||
location:
|
||||
row: 41
|
||||
column: 0
|
||||
end_location:
|
||||
row: 41
|
||||
column: 29
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 42
|
||||
column: 0
|
||||
end_location:
|
||||
row: 42
|
||||
column: 28
|
||||
fix:
|
||||
content:
|
||||
- fn.__globals__
|
||||
location:
|
||||
row: 42
|
||||
column: 0
|
||||
end_location:
|
||||
row: 42
|
||||
column: 28
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 45
|
||||
column: 0
|
||||
end_location:
|
||||
row: 45
|
||||
column: 12
|
||||
fix:
|
||||
content:
|
||||
- "b\"...\""
|
||||
location:
|
||||
row: 45
|
||||
column: 0
|
||||
end_location:
|
||||
row: 45
|
||||
column: 12
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 46
|
||||
column: 0
|
||||
end_location:
|
||||
row: 46
|
||||
column: 12
|
||||
fix:
|
||||
content:
|
||||
- "\"...\""
|
||||
location:
|
||||
row: 46
|
||||
column: 0
|
||||
end_location:
|
||||
row: 46
|
||||
column: 12
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 47
|
||||
column: 0
|
||||
end_location:
|
||||
row: 47
|
||||
column: 24
|
||||
fix:
|
||||
content:
|
||||
- "b\"...\""
|
||||
location:
|
||||
row: 47
|
||||
column: 0
|
||||
end_location:
|
||||
row: 47
|
||||
column: 24
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 48
|
||||
column: 0
|
||||
end_location:
|
||||
row: 48
|
||||
column: 21
|
||||
fix:
|
||||
content:
|
||||
- "\"...\""
|
||||
location:
|
||||
row: 48
|
||||
column: 0
|
||||
end_location:
|
||||
row: 48
|
||||
column: 21
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 49
|
||||
column: 0
|
||||
end_location:
|
||||
row: 49
|
||||
column: 22
|
||||
fix:
|
||||
content:
|
||||
- "\"...\""
|
||||
location:
|
||||
row: 49
|
||||
column: 0
|
||||
end_location:
|
||||
row: 49
|
||||
column: 22
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 53
|
||||
column: 0
|
||||
end_location:
|
||||
row: 53
|
||||
column: 30
|
||||
fix:
|
||||
content:
|
||||
- meth
|
||||
location:
|
||||
row: 53
|
||||
column: 0
|
||||
end_location:
|
||||
row: 53
|
||||
column: 30
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 54
|
||||
column: 0
|
||||
end_location:
|
||||
row: 54
|
||||
column: 34
|
||||
fix:
|
||||
content:
|
||||
- fn
|
||||
location:
|
||||
row: 54
|
||||
column: 0
|
||||
end_location:
|
||||
row: 54
|
||||
column: 34
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 57
|
||||
column: 0
|
||||
end_location:
|
||||
row: 57
|
||||
column: 29
|
||||
fix:
|
||||
content:
|
||||
- raise exc from exc_from
|
||||
location:
|
||||
row: 57
|
||||
column: 0
|
||||
end_location:
|
||||
row: 57
|
||||
column: 29
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 58
|
||||
column: 0
|
||||
end_location:
|
||||
row: 58
|
||||
column: 24
|
||||
fix:
|
||||
content:
|
||||
- raise exc.with_traceback(tb)
|
||||
location:
|
||||
row: 58
|
||||
column: 0
|
||||
end_location:
|
||||
row: 58
|
||||
column: 24
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 59
|
||||
column: 0
|
||||
end_location:
|
||||
row: 59
|
||||
column: 28
|
||||
fix:
|
||||
content:
|
||||
- raise
|
||||
location:
|
||||
row: 59
|
||||
column: 0
|
||||
end_location:
|
||||
row: 59
|
||||
column: 28
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 62
|
||||
column: 0
|
||||
end_location:
|
||||
row: 62
|
||||
column: 16
|
||||
fix:
|
||||
content:
|
||||
- "bs[0]"
|
||||
location:
|
||||
row: 62
|
||||
column: 0
|
||||
end_location:
|
||||
row: 62
|
||||
column: 16
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 63
|
||||
column: 0
|
||||
end_location:
|
||||
row: 63
|
||||
column: 21
|
||||
fix:
|
||||
content:
|
||||
- "bs[i]"
|
||||
location:
|
||||
row: 63
|
||||
column: 0
|
||||
end_location:
|
||||
row: 63
|
||||
column: 21
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 64
|
||||
column: 0
|
||||
end_location:
|
||||
row: 64
|
||||
column: 15
|
||||
fix:
|
||||
content:
|
||||
- "bytes((i,))"
|
||||
location:
|
||||
row: 64
|
||||
column: 0
|
||||
end_location:
|
||||
row: 64
|
||||
column: 15
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 67
|
||||
column: 5
|
||||
end_location:
|
||||
row: 67
|
||||
column: 23
|
||||
fix:
|
||||
content:
|
||||
- iter(dct.items())
|
||||
location:
|
||||
row: 67
|
||||
column: 5
|
||||
end_location:
|
||||
row: 67
|
||||
column: 23
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 67
|
||||
column: 5
|
||||
end_location:
|
||||
row: 67
|
||||
column: 23
|
||||
fix:
|
||||
content:
|
||||
- dct.items()
|
||||
location:
|
||||
row: 67
|
||||
column: 5
|
||||
end_location:
|
||||
row: 67
|
||||
column: 23
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 68
|
||||
column: 5
|
||||
end_location:
|
||||
row: 68
|
||||
column: 22
|
||||
fix:
|
||||
content:
|
||||
- iter(dct.keys())
|
||||
location:
|
||||
row: 68
|
||||
column: 5
|
||||
end_location:
|
||||
row: 68
|
||||
column: 22
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 68
|
||||
column: 5
|
||||
end_location:
|
||||
row: 68
|
||||
column: 22
|
||||
fix:
|
||||
content:
|
||||
- dct.keys()
|
||||
location:
|
||||
row: 68
|
||||
column: 5
|
||||
end_location:
|
||||
row: 68
|
||||
column: 22
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 69
|
||||
column: 5
|
||||
end_location:
|
||||
row: 69
|
||||
column: 24
|
||||
fix:
|
||||
content:
|
||||
- iter(dct.values())
|
||||
location:
|
||||
row: 69
|
||||
column: 5
|
||||
end_location:
|
||||
row: 69
|
||||
column: 24
|
||||
parent: ~
|
||||
- kind:
|
||||
RemoveSixCompat: ~
|
||||
location:
|
||||
row: 69
|
||||
column: 5
|
||||
end_location:
|
||||
row: 69
|
||||
column: 24
|
||||
fix:
|
||||
content:
|
||||
- dct.values()
|
||||
location:
|
||||
row: 69
|
||||
column: 5
|
||||
end_location:
|
||||
row: 69
|
||||
column: 24
|
||||
parent: ~
|
||||
|
|
@ -2935,20 +2935,6 @@ impl AlwaysAutofixableViolation for RedundantOpenModes {
|
|||
}
|
||||
}
|
||||
|
||||
define_violation!(
|
||||
pub struct RemoveSixCompat;
|
||||
);
|
||||
impl AlwaysAutofixableViolation for RemoveSixCompat {
|
||||
#[derive_message_formats]
|
||||
fn message(&self) -> String {
|
||||
format!("Unnecessary `six` compatibility usage")
|
||||
}
|
||||
|
||||
fn autofix_title(&self) -> String {
|
||||
"Remove `six` usage".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
define_violation!(
|
||||
pub struct DatetimeTimezoneUTC {
|
||||
pub straight_import: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue