Skip to content

Commit

Permalink
Empty: stringification methods
Browse files Browse the repository at this point in the history
Make sure that someone poking around in a REPL doesn't have to
dig deeper to see what the inferred types are.
  • Loading branch information
samv committed Mar 7, 2015
1 parent 7459254 commit 9a80cb7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions normalize/empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,19 @@ def __getitem__(self, item):
def __nonzero__(self):
return False

def _typelist(self):
return "any" if self._typetuple is any else ",".join(
str(t.__name__) for t in self._typetuple
if isinstance(t, type)
)

def __repr__(self):
return "normalize.empty.placeholder(%s)" % self._typelist()

def __str__(self):
return "False(%s)" % self._typelist()

def _exc(self, which, **kwargs):
return getattr(normalize.exc, which)(
typenames=",".join(
str(t.__name__) for t in self._typetuple
if isinstance(t, type)
),
typenames=self._typelist(),
**kwargs)

0 comments on commit 9a80cb7

Please sign in to comment.