Skip to content

Commit 89786f1

Browse files
authored
Merge pull request quantopian#1472 from quantopian/branch-protect-hook-stopped-me-from-pushing-this-commit-directly-;_;
ENH: improve warning for protocol getitem
2 parents cf2abf1 + ec1ca28 commit 89786f1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

zipline/protocol.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ def _deprecated_getitem_method(name, attrs):
9797
The ``__getitem__`` method to put in the class dict.
9898
"""
9999
attrs = frozenset(attrs)
100-
msg = "'{0}[attr]' is deprecated, please use '{0}.attr' instead".format(
101-
name,
100+
msg = (
101+
"'{name}[{attr!r}]' is deprecated, please use"
102+
" '{name}.{attr}' instead"
102103
)
103104

104105
def __getitem__(self, key):
105106
"""``__getitem__`` is deprecated, please use attribute access instead.
106107
"""
107-
warn(msg, DeprecationWarning, stacklevel=1)
108+
warn(msg.format(name=name, attr=key), DeprecationWarning, stacklevel=2)
108109
if key in attrs:
109110
return self.__dict__[key]
110111
raise KeyError(key)

0 commit comments

Comments
 (0)