Skip to content

Commit 0d8a3a8

Browse files
elazarggvanrossum
authored andcommitted
[Refactoring] Remove TypeInfo.alt_fullname (#3165)
1 parent b7c7b77 commit 0d8a3a8

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

mypy/nodes.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import mypy.strconv
1111
from mypy.visitor import NodeVisitor, StatementVisitor, ExpressionVisitor
12-
from mypy.util import short_type, IdMapper
12+
from mypy.util import short_type
1313

1414

1515
class Context:
@@ -1988,9 +1988,6 @@ class is generic then it will be a type constructor of higher kind.
19881988
# Is this a newtype type?
19891989
is_newtype = False
19901990

1991-
# Alternative to fullname() for 'anonymous' classes.
1992-
alt_fullname = None # type: Optional[str]
1993-
19941991
FLAGS = [
19951992
'is_abstract', 'is_enum', 'fallback_to_any', 'is_named_tuple',
19961993
'is_newtype'
@@ -2171,8 +2168,7 @@ def serialize(self) -> JsonDict:
21712168
data = {'.class': 'TypeInfo',
21722169
'module_name': self.module_name,
21732170
'fullname': self.fullname(),
2174-
'alt_fullname': self.alt_fullname,
2175-
'names': self.names.serialize(self.alt_fullname or self.fullname()),
2171+
'names': self.names.serialize(self.fullname()),
21762172
'defn': self.defn.serialize(),
21772173
'abstract_attributes': self.abstract_attributes,
21782174
'type_vars': self.type_vars,
@@ -2194,7 +2190,6 @@ def deserialize(cls, data: JsonDict) -> 'TypeInfo':
21942190
module_name = data['module_name']
21952191
ti = TypeInfo(names, defn, module_name)
21962192
ti._fullname = data['fullname']
2197-
ti.alt_fullname = data['alt_fullname']
21982193
# TODO: Is there a reason to reconstruct ti.subtypes?
21992194
ti.abstract_attributes = data['abstract_attributes']
22002195
ti.type_vars = data['type_vars']
@@ -2303,14 +2298,7 @@ def serialize(self, prefix: str, name: str) -> JsonDict:
23032298
else:
23042299
if self.node is not None:
23052300
if prefix is not None:
2306-
# Check whether this is an alias for another object.
2307-
# If the object's canonical full name differs from
2308-
# the full name computed from prefix and name,
2309-
# it's an alias, and we serialize it as a cross ref.
2310-
if isinstance(self.node, TypeInfo):
2311-
fullname = self.node.alt_fullname or self.node.fullname()
2312-
else:
2313-
fullname = self.node.fullname()
2301+
fullname = self.node.fullname()
23142302
if (fullname is not None and '.' in fullname and
23152303
fullname != prefix + '.' + name):
23162304
data['cross_ref'] = fullname

mypy/server/astdiff.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def is_similar_node_shallow(n: SymbolTableNode, m: SymbolTableNode) -> bool:
8181
nn.fallback_to_any == mn.fallback_to_any and
8282
nn.is_named_tuple == mn.is_named_tuple and
8383
nn.is_newtype == mn.is_newtype and
84-
nn.alt_fullname == mn.alt_fullname and
8584
is_same_mro(nn.mro, mn.mro))
8685
if isinstance(n.node, Var) and isinstance(m.node, Var):
8786
return is_identical_type(n.node.type, m.node.type)

mypy/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def accept(self, visitor: 'TypeVisitor[T]') -> T:
390390

391391
def serialize(self) -> Union[JsonDict, str]:
392392
assert self.type is not None
393-
type_ref = self.type.alt_fullname or self.type.fullname()
393+
type_ref = self.type.fullname()
394394
if not self.args:
395395
return type_ref
396396
data = {'.class': 'Instance',

0 commit comments

Comments
 (0)