Skip to content

Commit 4f621f2

Browse files
committed
Remove unused NameExpr.info property
It seems like the `info` attribute inside NameExpr is not actually set or used anywhere. This commit removes it altogether.
1 parent cc90602 commit 4f621f2

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

mypy/checkexpr.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ def extract_refexpr_names(expr: RefExpr) -> Set[str]:
5757
output.add(expr.fullname)
5858

5959
if isinstance(expr, NameExpr):
60-
is_silenced_import = isinstance(expr.node, Var) and expr.node.is_import
61-
if expr.info is not None:
62-
# Reference to regular type
63-
output.update(split_module_names(expr.info.module_name))
64-
elif isinstance(expr.node, TypeInfo):
65-
# Nested class
60+
is_suppressed_import = isinstance(expr.node, Var) and expr.node.is_suppressed_import
61+
if isinstance(expr.node, TypeInfo):
62+
# Reference to a class or a nested class
6663
output.update(split_module_names(expr.node.module_name))
67-
elif expr.fullname is not None and '.' in expr.fullname and not is_silenced_import:
64+
elif expr.fullname is not None and '.' in expr.fullname and not is_suppressed_import:
65+
# Everything else (that is not a silenced import within a class)
6866
output.add(expr.fullname.rsplit('.', 1)[0])
6967
break
7068
elif isinstance(expr, MemberExpr):

mypy/nodes.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,6 @@ class NameExpr(RefExpr):
11081108
"""
11091109

11101110
name = None # type: str # Name referred to (may be qualified)
1111-
# TypeInfo of class surrounding expression (may be None)
1112-
info = None # type: TypeInfo
11131111

11141112
literal = LITERAL_TYPE
11151113

mypy/treetransform.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ def duplicate_name(self, node: NameExpr) -> NameExpr:
340340
# This method is used when the transform result must be a NameExpr.
341341
# visit_name_expr() is used when there is no such restriction.
342342
new = NameExpr(node.name)
343-
new.info = node.info
344343
self.copy_ref(new, node)
345344
return new
346345

0 commit comments

Comments
 (0)