1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
class Cls():
class_attr = ''
def __init__(self, input):
self.instance_attr = 3
self.input = input
def f(self):
#! 12 attribute-error
return self.not_existing
def undefined_object(self, obj):
"""
Uses an arbitrary object and performs an operation on it, shouldn't
be a problem.
"""
obj.arbitrary_lookup
def defined_lookup(self, obj):
"""
`obj` is defined by a call into this function.
"""
obj.upper
#! 4 attribute-error
obj.arbitrary_lookup
#! 13 name-error
class_attr = a
Cls(1).defined_lookup('')
c = Cls(1)
c.class_attr
Cls.class_attr
#! 4 attribute-error
Cls.class_attr_error
c.instance_attr
#! 2 attribute-error
c.instance_attr_error
c.something = None
#! 12 name-error
something = a
something
# -----------------
# Unused array variables should still raise attribute errors.
# -----------------
# should not raise anything.
for loop_variable in [1, 2]:
#! 4 name-error
x = undefined
loop_variable
#! 28 name-error
for loop_variable in [1, 2, undefined]:
pass
#! 7 attribute-error
[1, ''.undefined_attr]
def return_one(something):
return 1
#! 14 attribute-error
return_one(''.undefined_attribute)
#! 12 name-error
[r for r in undefined]
#! 1 name-error
[undefined for r in [1, 2]]
[r for r in [1, 2]]
# some random error that showed up
class NotCalled():
def match_something(self, param):
seems_to_need_an_assignment = param
return [value.match_something() for value in []]
# -----------------
# decorators
# -----------------
#! 1 name-error
@undefined_decorator
def func():
return 1
# -----------------
# operators
# -----------------
string = '%s %s' % (1, 2)
# Shouldn't raise an error, because `string` is really just a string, not an
# array or something.
string.upper
# -----------------
# imports
# -----------------
# Star imports and the like in modules should not cause attribute errors in
# this module.
import import_tree
import_tree.a
import_tree.b
# This is something that raised an error, because it was using a complex
# mixture of Jedi fakes and compiled objects.
import _sre
#! 15 attribute-error
_sre.compile().not_existing
|