1
0
forked from VimPlug/jedi

Also issue warnings if setattr is used in a class instead of an error

This commit is contained in:
Dave Halter
2014-06-26 13:40:15 +02:00
parent 4238538df4
commit 1c9058ce6b
3 changed files with 38 additions and 2 deletions

View File

@@ -3,6 +3,10 @@ Jedi issues warnings for possible errors if ``__getattr__``,
``__getattribute__`` or ``setattr`` are used.
"""
# -----------------
# __getattr*__
# -----------------
class Cls():
def __getattr__(self, name):
@@ -22,3 +26,21 @@ Inherited().upper
#! 12 warning attribute-error
Inherited().undefined
# -----------------
# setattr
# -----------------
class SetattrCls():
def __init__(self, dct):
# Jedi doesn't even try to understand such code
for k, v in dct:
setattr(self, k, v)
self.defined = 3
c = SetattrCls({'a': 'b'})
c.defined
#! 2 warning attribute-error
c.undefined