Codebase list astroid / 17bb84c
record new upstream branch created by importing astroid_1.4.5.orig.tar.gz and merge it Sandro Tosi 8 years ago
12 changed file(s) with 113 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
00 Change log for the astroid package (used to be astng)
11 =====================================================
2
3 2016-03-21 -- 1.4.5
4
5 * decoratornames() does not leak InferenceError anymore.
6
7 * wildcard_imported_names() got replaced by _public_names()
8
9 Our understanding of wildcard imports through __all__ was
10 half baked to say at least, since we couldn't account for
11 modifications of the list, which results in tons of false positives.
12 Instead, we replaced it with _public_names(), a method which returns
13 all the names that are publicly available in a module, that is that
14 don't start with an underscore, even though this means that there
15 is a possibility for other names to be leaked out even though
16 they are not present in the __all__ variable.
17
18 The method is private in 1.4.X.
19
220
321 2016-01-15 -- 1.4.4
422
00 Metadata-Version: 1.1
11 Name: astroid
2 Version: 1.4.4
2 Version: 1.4.5
33 Summary: A abstract syntax tree for Python with inference support.
44 Home-page: http://bitbucket.org/logilab/astroid
55 Author: Logilab
1919
2020 modname = 'astroid'
2121
22 numversion = (1, 4, 4)
22 numversion = (1, 4, 5)
2323 version = '.'.join([str(num) for num in numversion])
2424
2525 install_requires = ['six', 'lazy_object_proxy', 'wrapt']
201201 imported = node.do_import_module()
202202 except exceptions.InferenceError:
203203 continue
204 for name in imported.wildcard_import_names():
204 for name in imported._public_names():
205205 node.parent.set_local(name, node)
206206 sort_locals(node.parent.scope()._locals[name])
207207 else:
246246 yield util.YES
247247 nodes.UnaryOp._infer = bases.path_wrapper(infer_unaryop)
248248
249 def _infer_binop(operator, operand1, operand2, context, failures=None):
249 def _infer_binop(binop, operand1, operand2, context, failures=None):
250250 if operand1 is util.YES:
251251 yield operand1
252252 return
253253 try:
254 for valnode in operand1.infer_binary_op(operator, operand2, context):
254 for valnode in operand1.infer_binary_op(binop, operand2, context):
255255 yield valnode
256256 except AttributeError:
257257 try:
269269 def infer_binop(self, context=None):
270270 failures = []
271271 for lhs in self.left.infer(context):
272 for val in _infer_binop(self.op, lhs, self.right, context, failures):
272 for val in _infer_binop(self, lhs, self.right, context, failures):
273273 yield val
274274 for lhs in failures:
275275 for rhs in self.right.infer(context):
276 for val in _infer_binop(self.op, rhs, lhs, context):
276 for val in _infer_binop(self, rhs, lhs, context):
277277 yield val
278278 nodes.BinOp._infer = bases.path_wrapper(infer_binop)
279279
303303 def infer_augassign(self, context=None):
304304 failures = []
305305 for lhs in self.target.infer_lhs(context):
306 for val in _infer_binop(self.op, lhs, self.value, context, failures):
306 for val in _infer_binop(self, lhs, self.value, context, failures):
307307 yield val
308308 for lhs in failures:
309309 for rhs in self.value.infer(context):
310 for val in _infer_binop(self.op, rhs, lhs, context):
310 for val in _infer_binop(self, rhs, lhs, context):
311311 yield val
312312 nodes.AugAssign._infer = bases.path_wrapper(infer_augassign)
313313
102102 for key, impl in list(BIN_OP_IMPL.items()):
103103 BIN_OP_IMPL[key+'='] = impl
104104
105 def const_infer_binary_op(self, operator, other, context):
105 def const_infer_binary_op(self, binop, other, context):
106 operator = binop.op
106107 for other in other.infer(context):
107108 if isinstance(other, nodes.Const):
108109 try:
121122 yield other
122123 else:
123124 try:
124 for val in other.infer_binary_op(operator, self, context):
125 for val in other.infer_binary_op(binop, self, context):
125126 yield val
126127 except AttributeError:
127128 yield util.YES
129130
130131
131132
132 def _multiply_seq_by_int(self, other, context):
133 def _multiply_seq_by_int(self, binop, other, context):
133134 node = self.__class__()
135 node.parent = binop
134136 elts = []
135137 for elt in self.elts:
136138 infered = util.safe_infer(elt, context)
150152 yield inferred
151153
152154
153 def tl_infer_binary_op(self, operator, other, context):
155 def tl_infer_binary_op(self, binop, other, context):
156 operator = binop.op
154157 for other in other.infer(context):
155158 if isinstance(other, self.__class__) and operator == '+':
156159 node = self.__class__()
160 node.parent = binop
157161 elts = list(_filter_uninferable_nodes(self.elts, context))
158162 elts += list(_filter_uninferable_nodes(other.elts, context))
159163 node.elts = elts
162166 if not isinstance(other.value, int):
163167 yield util.YES
164168 continue
165 yield _multiply_seq_by_int(self, other, context)
169 yield _multiply_seq_by_int(self, binop, other, context)
166170 elif isinstance(other, bases.Instance) and not isinstance(other, nodes.Const):
167171 yield util.YES
168172 # XXX else log TypeError
170174 nodes.List.infer_binary_op = bases.yes_if_nothing_inferred(tl_infer_binary_op)
171175
172176
173 def dict_infer_binary_op(self, operator, other, context):
177 def dict_infer_binary_op(self, binop, other, context):
174178 for other in other.infer(context):
175179 if isinstance(other, bases.Instance) and isinstance(other._proxied, nodes.ClassDef):
176180 yield util.YES
177181 # XXX else log TypeError
178182 nodes.Dict.infer_binary_op = bases.yes_if_nothing_inferred(dict_infer_binary_op)
179183
180 def instance_infer_binary_op(self, operator, other, context):
184 def instance_infer_binary_op(self, binop, other, context):
185 operator = binop.op
181186 try:
182187 methods = self.getattr(BIN_OP_METHOD[operator])
183188 except (exceptions.NotFoundError, KeyError):
567567 inferred.append(inferred_node.value)
568568 return inferred
569569
570 def _public_names(self):
571 """Get the list of the names which are publicly available in this module."""
572 return [name for name in self.keys() if not name.startswith('_')]
573
570574 def bool_value(self):
571575 return True
572576
886890 decoratornodes += self.decorators.nodes
887891 decoratornodes += self.extra_decorators
888892 for decnode in decoratornodes:
889 for infnode in decnode.infer():
890 result.add(infnode.qname())
893 try:
894 for infnode in decnode.infer():
895 result.add(infnode.qname())
896 except exceptions.InferenceError:
897 continue
891898 return result
892899
893900 def is_bound(self):
148148 astroid = builder.string_build(data, __name__, __file__)
149149 callfunc = astroid.body[1].value.func
150150 inferred = callfunc.inferred()
151 self.assertEqual(len(inferred), 1)
151 self.assertEqual(len(inferred), 2)
152152
153153 @require_version('3.0')
154154 def test_nameconstant(self):
298298
299299 next(node.value.infer()).as_string()
300300
301 def test_binop_generates_nodes_with_parents(self):
302 node = extract_node('''
303 def no_op(*args):
304 pass
305 def foo(*args):
306 def inner(*more_args):
307 args + more_args #@
308 return inner
309 ''')
310 inferred = next(node.infer())
311 self.assertIsInstance(inferred, nodes.Tuple)
312 self.assertIsNotNone(inferred.parent)
313 self.assertIsInstance(inferred.parent, nodes.BinOp)
314
315 def test_decorator_names_inference_error_leaking(self):
316 node = extract_node('''
317 class Parent(object):
318 @property
319 def foo(self):
320 pass
321
322 class Child(Parent):
323 @Parent.foo.getter
324 def foo(self): #@
325 return super(Child, self).foo + ['oink']
326 ''')
327 inferred = next(node.infer())
328 self.assertEqual(inferred.decoratornames(), set())
329
301330
302331 class Whatever(object):
303332 a = property(lambda x: x, lambda x: x)
110110 res = sorted(m.wildcard_import_names())
111111 self.assertEqual(res, ['Aaa', 'func', 'name', 'other'])
112112
113 def test_public_names(self):
114 m = builder.parse('''
115 name = 'a'
116 _bla = 2
117 other = 'o'
118 class Aaa: pass
119 def func(): print('yo')
120 __all__ = 'Aaa', '_bla', 'name'
121 ''')
122 values = sorted(['Aaa', 'name', 'other', 'func'])
123 self.assertEqual(sorted(m._public_names()), values)
124 m = builder.parse('''
125 name = 'a'
126 _bla = 2
127 other = 'o'
128 class Aaa: pass
129
130 def func(): return 'yo'
131 ''')
132 res = sorted(m._public_names())
133 self.assertEqual(res, values)
134
113135 m = builder.parse('''
114136 from missing import tzop
115137 trop = "test"
116138 __all__ = (trop, "test1", tzop, 42)
117139 ''')
118 res = sorted(m.wildcard_import_names())
119 self.assertEqual(res, ["test", "test1"])
140 res = sorted(m._public_names())
141 self.assertEqual(res, ["trop", "tzop"])
120142
121143 m = builder.parse('''
122144 test = tzop = 42
123145 __all__ = ('test', ) + ('tzop', )
124146 ''')
125 res = sorted(m.wildcard_import_names())
147 res = sorted(m._public_names())
126148 self.assertEqual(res, ['test', 'tzop'])
127149
128150 def test_module_getattr(self):
00 Metadata-Version: 1.1
11 Name: astroid
2 Version: 1.4.4
2 Version: 1.4.5
33 Summary: A abstract syntax tree for Python with inference support.
44 Home-page: http://bitbucket.org/logilab/astroid
55 Author: Logilab
00 # see git-dpm(1) from git-dpm package
1 a06d33a8cf30f751f2ccac8e7bf36a9f3c734a32
2 a06d33a8cf30f751f2ccac8e7bf36a9f3c734a32
3 a06d33a8cf30f751f2ccac8e7bf36a9f3c734a32
4 a06d33a8cf30f751f2ccac8e7bf36a9f3c734a32
5 astroid_1.4.4.orig.tar.gz
6 605227603fc9d3e7b342de0005c7e82726b184a3
7 181733
1 b022987c7b522ff79f3b73511cf7293619b1df9b
2 b022987c7b522ff79f3b73511cf7293619b1df9b
3 b022987c7b522ff79f3b73511cf7293619b1df9b
4 b022987c7b522ff79f3b73511cf7293619b1df9b
5 astroid_1.4.5.orig.tar.gz
6 2ec96d60a5b40a656fdcbab77f58ba453f0cb03e
7 182251
88 debianTag="debian/%e%v"
99 patchedTag="patched/%e%v"
1010 upstreamTag="upstream/%e%u"
11 universal = 1
22
33 [egg_info]
4 tag_date = 0
5 tag_svn_revision = 0
46 tag_build =
5 tag_svn_revision = 0
6 tag_date = 0
77