Skip to content

Remove python2 logic from server/deps.py #13267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/checkstrformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def build_dict_type(self, expr: FormatStringExpr) -> Type:
str_type = self.chk.named_generic_type("builtins.str", [])
return self.chk.named_generic_type("typing.Mapping", [str_type, any_type])
else:
assert False, "There should not be UnicodeExpr on Python 3"
assert False, "Unreachable"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be nice to use assert_never in the future


def build_replacement_checkers(
self, specifiers: List[ConversionSpecifier], context: Context, expr: FormatStringExpr
Expand Down
10 changes: 1 addition & 9 deletions mypy/server/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def __init__(
) -> None:
self.scope = Scope()
self.type_map = type_map
self.python2 = python_version[0] == 2
# This attribute holds a mapping from target to names of type aliases
# it depends on. These need to be processed specially, since they are
# only present in expanded form in symbol tables. For example, after:
Expand Down Expand Up @@ -603,11 +602,7 @@ def visit_for_stmt(self, o: ForStmt) -> None:
self.add_attribute_dependency_for_expr(o.expr, "__iter__")
self.add_attribute_dependency_for_expr(o.expr, "__getitem__")
if o.inferred_iterator_type:
if self.python2:
method = "next"
else:
method = "__next__"
self.add_attribute_dependency(o.inferred_iterator_type, method)
self.add_attribute_dependency(o.inferred_iterator_type, "__next__")
else:
self.add_attribute_dependency_for_expr(o.expr, "__aiter__")
if o.inferred_iterator_type:
Expand Down Expand Up @@ -803,9 +798,6 @@ def visit_comparison_expr(self, e: ComparisonExpr) -> None:
left = e.operands[i]
right = e.operands[i + 1]
self.process_binary_op(op, left, right)
if self.python2 and op in ("==", "!=", "<", "<=", ">", ">="):
self.add_operator_method_dependency(left, "__cmp__")
self.add_operator_method_dependency(right, "__cmp__")

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