Skip to content

Commit

Permalink
Remove python2 magic methods support (#13277)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Jul 28, 2022
1 parent 35e80ce commit 396dafb
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 17 deletions.
9 changes: 0 additions & 9 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,6 @@ def has_no_attr(
matches.extend(best_matches(member, alternatives)[:3])
if member == "__aiter__" and matches == ["__iter__"]:
matches = [] # Avoid misleading suggestion
if member == "__div__" and matches == ["__truediv__"]:
# TODO: Handle differences in division between Python 2 and 3 more cleanly
matches = []
if matches:
self.fail(
'{} has no attribute "{}"; maybe {}?{}'.format(
Expand Down Expand Up @@ -579,12 +576,6 @@ def incompatible_argument(
)
return codes.OPERATOR

if name.startswith('"__cmp__" of'):
self.unsupported_operand_types(
"comparison", arg_type, base, context, code=codes.OPERATOR
)
return codes.INDEX

if name.startswith('"__getitem__" of'):
self.invalid_index_type(
arg_type, callee.arg_types[n - 1], base, context, code=codes.INDEX
Expand Down
2 changes: 0 additions & 2 deletions mypy/operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
}

op_methods_to_symbols: Final = {v: k for (k, v) in op_methods.items()}
op_methods_to_symbols["__div__"] = "/"

ops_falling_back_to_cmp: Final = {"__ne__", "__eq__", "__lt__", "__le__", "__gt__", "__ge__"}

Expand Down Expand Up @@ -83,7 +82,6 @@
"__add__",
"__sub__",
"__mul__",
"__div__",
"__truediv__",
"__mod__",
"__divmod__",
Expand Down
4 changes: 2 additions & 2 deletions mypy/plugins/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def attr_class_maker_callback(
At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or
annotated variables if auto_attribs=True), then depending on how the decorator is called,
it will add an __init__ or all the __cmp__ methods. For frozen=True it will turn the attrs
into properties.
it will add an __init__ or all the compare methods.
For frozen=True it will turn the attrs into properties.
See http://www.attrs.org/en/stable/how-does-it-work.html for information on how attrs works.
Expand Down
4 changes: 0 additions & 4 deletions mypy/sharedparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@
"__long__",
"__neg__",
"__new__",
"__nonzero__",
"__oct__",
"__pos__",
"__repr__",
"__reversed__",
"__setattr__",
"__setitem__",
"__str__",
"__unicode__",
}

MAGIC_METHODS_ALLOWING_KWARGS: Final = {
Expand All @@ -51,9 +49,7 @@
BINARY_MAGIC_METHODS: Final = {
"__add__",
"__and__",
"__cmp__",
"__divmod__",
"__div__",
"__eq__",
"__floordiv__",
"__ge__",
Expand Down

0 comments on commit 396dafb

Please sign in to comment.