Skip to content

Commit

Permalink
Issue #17: More work on minimizing code for InitVar.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvsmith committed Nov 24, 2017
1 parent 3a392ab commit 1c782f9
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ class TypingMeta(type):
constructs is done in __new__) and a nicer repr().
"""

_is_protocol = False

def __new__(cls, name, bases, namespace, *, _root=False):
if not _root:
raise TypeError("Cannot subclass %s" %
Expand All @@ -81,19 +79,6 @@ def __new__(cls, name, bases, namespace, *, _root=False):
def __init__(self, *args, **kwds):
pass

def _eval_type(self, globalns, localns):
"""Override this in subclasses to interpret forward references.
For example, List['C'] is internally stored as
List[_ForwardRef('C')], which should evaluate to List[C],
where C is an object found in globalns or localns (searching
localns first, of course).
"""
return self

def _get_type_vars(self, tvars):
pass

def __repr__(self):
return f'{self.__module__}.{self.__qualname__}'

Expand All @@ -119,13 +104,6 @@ def __new__(cls, *args, **kwds):
raise TypeError(f"Cannot subclass {cls}")
return super().__new__(cls)

# Things that are not classes also need these.
def _eval_type(self, globalns, localns):
return self

def _get_type_vars(self, tvars):
pass

def __repr__(self):
cls = type(self)
return f'{cls.__module__}.{cls.__qualname__}'
Expand Down Expand Up @@ -217,12 +195,6 @@ def __getitem__(self, item):
raise TypeError('{} cannot be further subscripted'
.format(cls.__name__[1:]))

def _eval_type(self, globalns, localns):
new_tp = _eval_type(self.__type__, globalns, localns)
if new_tp == self.__type__:
return self
return type(self)(new_tp, _root=True)

def __repr__(self):
r = super().__repr__()
if self.__type__ is not None:
Expand Down

0 comments on commit 1c782f9

Please sign in to comment.