From 863e2ffbeaec253a8a5caf23b391f21458373ded Mon Sep 17 00:00:00 2001 From: Joe Jevnik Date: Tue, 6 Sep 2016 15:11:43 -0400 Subject: [PATCH] ENH: improve warning for protocol getitem --- zipline/protocol.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zipline/protocol.py b/zipline/protocol.py index bfdc04f1..35cc5b7c 100644 --- a/zipline/protocol.py +++ b/zipline/protocol.py @@ -97,14 +97,15 @@ def _deprecated_getitem_method(name, attrs): The ``__getitem__`` method to put in the class dict. """ attrs = frozenset(attrs) - msg = "'{0}[attr]' is deprecated, please use '{0}.attr' instead".format( - name, + msg = ( + "'{name}[{attr!r}]' is deprecated, please use" + " '{name}.{attr}' instead" ) def __getitem__(self, key): """``__getitem__`` is deprecated, please use attribute access instead. """ - warn(msg, DeprecationWarning, stacklevel=1) + warn(msg.format(name=name, attr=key), DeprecationWarning, stacklevel=2) if key in attrs: return self.__dict__[key] raise KeyError(key)