Skip to content

Commit 6180a26

Browse files
authored
Remove python2 logic from server/deps.py (#13267)
1 parent b50a4ef commit 6180a26

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

mypy/checkstrformat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def build_dict_type(self, expr: FormatStringExpr) -> Type:
867867
str_type = self.chk.named_generic_type("builtins.str", [])
868868
return self.chk.named_generic_type("typing.Mapping", [str_type, any_type])
869869
else:
870-
assert False, "There should not be UnicodeExpr on Python 3"
870+
assert False, "Unreachable"
871871

872872
def build_replacement_checkers(
873873
self, specifiers: List[ConversionSpecifier], context: Context, expr: FormatStringExpr

mypy/server/deps.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def __init__(
225225
) -> None:
226226
self.scope = Scope()
227227
self.type_map = type_map
228-
self.python2 = python_version[0] == 2
229228
# This attribute holds a mapping from target to names of type aliases
230229
# it depends on. These need to be processed specially, since they are
231230
# only present in expanded form in symbol tables. For example, after:
@@ -603,11 +602,7 @@ def visit_for_stmt(self, o: ForStmt) -> None:
603602
self.add_attribute_dependency_for_expr(o.expr, "__iter__")
604603
self.add_attribute_dependency_for_expr(o.expr, "__getitem__")
605604
if o.inferred_iterator_type:
606-
if self.python2:
607-
method = "next"
608-
else:
609-
method = "__next__"
610-
self.add_attribute_dependency(o.inferred_iterator_type, method)
605+
self.add_attribute_dependency(o.inferred_iterator_type, "__next__")
611606
else:
612607
self.add_attribute_dependency_for_expr(o.expr, "__aiter__")
613608
if o.inferred_iterator_type:
@@ -803,9 +798,6 @@ def visit_comparison_expr(self, e: ComparisonExpr) -> None:
803798
left = e.operands[i]
804799
right = e.operands[i + 1]
805800
self.process_binary_op(op, left, right)
806-
if self.python2 and op in ("==", "!=", "<", "<=", ">", ">="):
807-
self.add_operator_method_dependency(left, "__cmp__")
808-
self.add_operator_method_dependency(right, "__cmp__")
809801

810802
def process_binary_op(self, op: str, left: Expression, right: Expression) -> None:
811803
method = op_methods.get(op)

0 commit comments

Comments
 (0)