Skip to content

[Refactoring] Remove TypeInfo.alt_fullname #3165

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 2 commits into from
Apr 12, 2017
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
18 changes: 3 additions & 15 deletions mypy/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import mypy.strconv
from mypy.visitor import NodeVisitor, StatementVisitor, ExpressionVisitor
from mypy.util import short_type, IdMapper
from mypy.util import short_type


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

# Alternative to fullname() for 'anonymous' classes.
alt_fullname = None # type: Optional[str]

FLAGS = [
'is_abstract', 'is_enum', 'fallback_to_any', 'is_named_tuple',
'is_newtype'
Expand Down Expand Up @@ -2171,8 +2168,7 @@ def serialize(self) -> JsonDict:
data = {'.class': 'TypeInfo',
'module_name': self.module_name,
'fullname': self.fullname(),
'alt_fullname': self.alt_fullname,
'names': self.names.serialize(self.alt_fullname or self.fullname()),
'names': self.names.serialize(self.fullname()),
'defn': self.defn.serialize(),
'abstract_attributes': self.abstract_attributes,
'type_vars': self.type_vars,
Expand All @@ -2194,7 +2190,6 @@ def deserialize(cls, data: JsonDict) -> 'TypeInfo':
module_name = data['module_name']
ti = TypeInfo(names, defn, module_name)
ti._fullname = data['fullname']
ti.alt_fullname = data['alt_fullname']
# TODO: Is there a reason to reconstruct ti.subtypes?
ti.abstract_attributes = data['abstract_attributes']
ti.type_vars = data['type_vars']
Expand Down Expand Up @@ -2303,14 +2298,7 @@ def serialize(self, prefix: str, name: str) -> JsonDict:
else:
if self.node is not None:
if prefix is not None:
# Check whether this is an alias for another object.
# If the object's canonical full name differs from
# the full name computed from prefix and name,
# it's an alias, and we serialize it as a cross ref.
if isinstance(self.node, TypeInfo):
fullname = self.node.alt_fullname or self.node.fullname()
else:
fullname = self.node.fullname()
fullname = self.node.fullname()
if (fullname is not None and '.' in fullname and
fullname != prefix + '.' + name):
data['cross_ref'] = fullname
Expand Down
1 change: 0 additions & 1 deletion mypy/server/astdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def is_similar_node_shallow(n: SymbolTableNode, m: SymbolTableNode) -> bool:
nn.fallback_to_any == mn.fallback_to_any and
nn.is_named_tuple == mn.is_named_tuple and
nn.is_newtype == mn.is_newtype and
nn.alt_fullname == mn.alt_fullname and
is_same_mro(nn.mro, mn.mro))
if isinstance(n.node, Var) and isinstance(m.node, Var):
return is_identical_type(n.node.type, m.node.type)
Expand Down
2 changes: 1 addition & 1 deletion mypy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ def accept(self, visitor: 'TypeVisitor[T]') -> T:

def serialize(self) -> Union[JsonDict, str]:
assert self.type is not None
type_ref = self.type.alt_fullname or self.type.fullname()
type_ref = self.type.fullname()
if not self.args:
return type_ref
data = {'.class': 'Instance',
Expand Down