| 1 |
""" |
| 2 |
Jedi issues warnings for possible errors if ``__getattr__``, |
| 3 |
``__getattribute__`` or ``setattr`` are used. |
| 4 |
""" |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
class Cls(): |
| 12 |
def __getattr__(self, name): |
| 13 |
return getattr(str, name) |
| 14 |
|
| 15 |
|
| 16 |
Cls().upper |
| 17 |
|
| 18 |
|
| 19 |
Cls().undefined |
| 20 |
|
| 21 |
|
| 22 |
class Inherited(Cls): |
| 23 |
pass |
| 24 |
|
| 25 |
Inherited().upper |
| 26 |
|
| 27 |
|
| 28 |
Inherited().undefined |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class SetattrCls(): |
| 36 |
def __init__(self, dct): |
| 37 |
|
| 38 |
for k, v in dct.items(): |
| 39 |
setattr(self, k, v) |
| 40 |
|
| 41 |
self.defined = 3 |
| 42 |
|
| 43 |
c = SetattrCls({'a': 'b'}) |
| 44 |
c.defined |
| 45 |
|
| 46 |
c.undefined |