Skip to content

Commit 396dafb

Browse files
authored
Remove python2 magic methods support (#13277)
1 parent 35e80ce commit 396dafb

File tree

4 files changed

+2
-17
lines changed

4 files changed

+2
-17
lines changed

mypy/messages.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,6 @@ def has_no_attr(
428428
matches.extend(best_matches(member, alternatives)[:3])
429429
if member == "__aiter__" and matches == ["__iter__"]:
430430
matches = [] # Avoid misleading suggestion
431-
if member == "__div__" and matches == ["__truediv__"]:
432-
# TODO: Handle differences in division between Python 2 and 3 more cleanly
433-
matches = []
434431
if matches:
435432
self.fail(
436433
'{} has no attribute "{}"; maybe {}?{}'.format(
@@ -579,12 +576,6 @@ def incompatible_argument(
579576
)
580577
return codes.OPERATOR
581578

582-
if name.startswith('"__cmp__" of'):
583-
self.unsupported_operand_types(
584-
"comparison", arg_type, base, context, code=codes.OPERATOR
585-
)
586-
return codes.INDEX
587-
588579
if name.startswith('"__getitem__" of'):
589580
self.invalid_index_type(
590581
arg_type, callee.arg_types[n - 1], base, context, code=codes.INDEX

mypy/operators.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
}
2929

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

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

@@ -83,7 +82,6 @@
8382
"__add__",
8483
"__sub__",
8584
"__mul__",
86-
"__div__",
8785
"__truediv__",
8886
"__mod__",
8987
"__divmod__",

mypy/plugins/attrs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ def attr_class_maker_callback(
274274
275275
At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or
276276
annotated variables if auto_attribs=True), then depending on how the decorator is called,
277-
it will add an __init__ or all the __cmp__ methods. For frozen=True it will turn the attrs
278-
into properties.
277+
it will add an __init__ or all the compare methods.
278+
For frozen=True it will turn the attrs into properties.
279279
280280
See http://www.attrs.org/en/stable/how-does-it-work.html for information on how attrs works.
281281

mypy/sharedparse.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@
2929
"__long__",
3030
"__neg__",
3131
"__new__",
32-
"__nonzero__",
3332
"__oct__",
3433
"__pos__",
3534
"__repr__",
3635
"__reversed__",
3736
"__setattr__",
3837
"__setitem__",
3938
"__str__",
40-
"__unicode__",
4139
}
4240

4341
MAGIC_METHODS_ALLOWING_KWARGS: Final = {
@@ -51,9 +49,7 @@
5149
BINARY_MAGIC_METHODS: Final = {
5250
"__add__",
5351
"__and__",
54-
"__cmp__",
5552
"__divmod__",
56-
"__div__",
5753
"__eq__",
5854
"__floordiv__",
5955
"__ge__",

0 commit comments

Comments
 (0)