- Mar 16, 2018
-
-
Claudiu Popa authored
-
Bryce Guinta authored
A ClassDef of str or bytes may have the same qname as a Const value of str or bytes causing an AttributeError in len builtin inference
-
- Mar 11, 2018
-
-
Claudiu Popa authored
-
Claudiu Popa authored
-
Bryce Guinta authored
-
Bryce Guinta authored
This reverts commit 06273cd07d4b3701998df7b2c656d1b029bdee8e.
-
Bryce Guinta authored
Close #112
-
Bryce Guinta authored
importing astroid.objects causes curcular imports with manager
-
- Mar 10, 2018
-
-
Claudiu Popa authored
-
Claudiu Popa authored
-
Claudiu Popa authored
This is in a similar vein with the `isinstance` builtin, with minor changes.
-
- Mar 06, 2018
-
-
Bryce Guinta authored
Close PyCQA/pylint#1746
-
- Mar 05, 2018
-
-
Claudiu Popa authored
I'm not sure why AstroidError was added in the first place, as this is the most general exception in astroid.
-
Claudiu Popa authored
-
Claudiu Popa authored
We want to test only what astroid is doing, not Python itself.
-
- Mar 03, 2018
-
-
Bryce Guinta authored
-
- Mar 02, 2018
-
-
Nick Drozd authored
nodes_of_class is a very flexible method, which is great for use in client code (e.g. Pylint). However, that flexibility requires a great deal of runtime type checking: def nodes_of_class(self, klass, skip_klass=None): if isinstance(self, klass): yield self if skip_klass is None: for child_node in self.get_children(): for matching in child_node.nodes_of_class(klass, skip_klass): yield matching return for child_node in self.get_children(): if isinstance(child_node, skip_klass): continue for matching in child_node.nodes_of_class(klass, skip_klass): yield matching First, the node has to check its own type to see whether it's of the desired class. Then the skip_klass flag has to be checked to see whether anything needs to be skipped. If so, the type of every yielded node has to be check to see if it should be skipped. This is fine for calling code whose arguments can't be known in advance ("Give me all the Assign and ClassDef nodes, but skip all the BinOps, YieldFroms, and Globals."), but in Astroid itself, every call to this function can be known in advance. There's no need to do any type checking if all the nodes know how to respond to certain requests. Take get_assign_nodes for example. The Assign nodes know that they should yield themselves and then yield their Assign children. Other nodes know in advance that they aren't Assign nodes, so they don't need to check their own type, just immediately yield their Assign children. Overly specific functions like get_yield_nodes_skip_lambdas certainly aren't very elegant, but the tradeoff is to take advantage of knowing how the library code works to improve speed.
-
Nick Drozd authored
The check was being repeated unnecessarily in a tight loop.
-
Nick Drozd authored
get_children is elegant and flexible and slow. def get_children(self): for field in self._astroid_fields: attr = getattr(self, field) if attr is None: continue if isinstance(attr, (list, tuple)): for elt in attr: yield elt else: yield attr It iterates over a list, dynamically accesses attributes, does null checks, and does type checking. This function gets called a lot, and all that extra work is a real drag on performance. In most cases there isn't any need to do any of these checks. Take an Assign node for instance: def get_children(self): for elt in self.targets: yield elt yield self.value It's known in advance that Assign nodes have a list of targets and a value, so just yield those without checking anything.
-
Bryce Guinta authored
Prevents users from having to dig through the call chain to figure out which possible exceptions are raised
-
Bryce Guinta authored
Close #98
-
Bryce Guinta authored
-
Bryce Guinta authored
-
- Feb 27, 2018
-
-
Bryce Guinta authored
-
- Feb 22, 2018
-
-
Bryce Guinta authored
-
Bryce Guinta authored
-
- Feb 21, 2018
-
-
Claudiu Popa authored
-
Claudiu Popa authored
-
Claudiu Popa authored
-
Claudiu Popa authored
-
Bryce Guinta authored
Astroid cannot infer this attribute because of the way attr builds its classes Close PyCQA/pylint#1884
-
- Feb 19, 2018
-
-
Bryce Guinta authored
The augmented assign rhs context path was deleted most likely due to a recently fixed inference bug where InferenceContext path attributes were shared between objects. Recursive functions on the right hand side of the augmented assign would forget that they were already called, causing an eventual RecursionError in astroid inference Now that the InferenceContext clone() method properly copies the inference path between Contexts, it's fine to remove this hack. Fixes #437, Fixes #447, Fixes #313, Fixes PyCQA/pylint#1642, Fixes PyCQA/pylint#1805, Fixes PyCQA/pylint#1854, Fixes PyCQA/pylint#1452
-
- Feb 17, 2018
-
-
Bryce Guinta authored
The calls previously implied that the result is being called from inside itself
-
- Feb 16, 2018
-
-
Ioana Tagirta authored
-
Bryce Guinta authored
This class, called 'whatever' ended up appearing in pyreverse due to a local called __class__ which pointed to it. pyreverse seemed to have found this class by recursively visiting nodes and calling the values() method of each node. Closes PyCQA/pylint#1875
-
- Feb 15, 2018
-
-
Ioana Tagirta authored
-
Ioana Tagirta authored
-
Bryce Guinta authored
-
Bryce Guinta authored
-
Bryce Guinta authored
There was some trouble getting this to work. I needed to use --pyargs for pytest to work in tox Allow for test file prefix unittest_ to be changed to standard test_ Helps with updating the astroid tests to standard pytest conventions Make pytest use proper test directory by default
-