From 9a80cb71425686234c1cb99a6b059a3c79b6d748 Mon Sep 17 00:00:00 2001 From: Sam Vilain Date: Fri, 6 Mar 2015 17:13:13 -0800 Subject: [PATCH] Empty: stringification methods Make sure that someone poking around in a REPL doesn't have to dig deeper to see what the inferred types are. --- normalize/empty.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/normalize/empty.py b/normalize/empty.py index 9404f64..fef7a10 100644 --- a/normalize/empty.py +++ b/normalize/empty.py @@ -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)