| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
them in a dict
|
|
|
|
|
|
| |
handler.
Close PyCQA/pylint#2777
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
class for PartialFunction
In the case where the node is a PartialFunction and its name is the same as the current statement's name,
avoid the statement deletion.
The problem was that a call to a function that has been previously called vit a functools.partial was wrongly inferred.
The bug comes from the _filter_stmts method of the LookupMixin class. The deletion of the current statement should not be
made in the case where the node is an instance of the PartialFunction class and if the node's name is the same as the statement's name.
This change also extracts PartialFunction from brain_functools into astroid.objects so that we remove a circular import problem.
Close PyCQA/pylint#2588
|
| |
|
|
|
|
| |
Reformat a chained comparison so that no more 'chained-comparison' warning is emitted from node_classe.py
|
|
|
|
|
|
|
|
| |
The result is usually static, but we're hitting this function quite
a lot for big projects such as pandas. This change is a matter of compromising
between the amount of memory astroid needs for analysis (e.g. storing the
results in memory) vs the wasted CPU time in calling the same
function over and over.
|
| |
|
| |
|
|
|
|
| |
Close PyCQA/pylint#2400
|
|
|
|
| |
The explicit StopIterations were themselves were cut in ceeee097.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
This would introduce a new method of configuring astroid & pylint, while the
usual approach we used so far was to set a flag in the MANAGER itself it we'd
need to customize some behaviour (extension_package_whitelist and friends).
Also renamed the flag to `max_inferable_values` to be more suggestive on what it does.
|
|
|
|
|
|
|
|
|
|
| |
spot performance issues.
Add new envrionment variable call ASTROID_MAX_INFERABLE to tune
the max inferable amount of values at a time.
Close #579
Close PyCQA/pylint#2251
|
|
|
|
|
|
|
|
|
| |
Add context_lookup to the context class as extra_context.
Deliver the correct context with the correct boundnode
for function argument nodes.
Close #177
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The precedence and associativity rules of operators are respected
and parens are only wrapped around child nodes when needed
A single If node inside the else block is output as `elif`
Unneccesary parens in with statements are removed
Unneccesary parens in tuple returns are removed
Doc strings in classes and functions no longer get additional indenting
|
|
|
|
| |
This was overlooked in the initial implementation of
_multi_line_block_fields.
|
|
|
| |
See https://github.com/PyCQA/pylint/pull/2209
|
|
|
|
|
|
|
|
|
|
|
|
| |
Calling object.__new__ on a Const node would result in infinite recursion
Fix infinite recursion by explicitly raising AttributeError if
__getattr__ is called for value
See https://nedbatchelder.com/blog/201010/surprising_getattr_recursion.html
for more details
Close #565
|
|
|
|
|
|
|
|
| |
Stop issue where decorators with the same name as the decorated function would cause an infinite loop
This infinite recursion was caused by an oversight in name lookup which prefferred methods even if they weren't defined yet
Close #375
|
| |
|
| |
|
| |
|
|
|
|
| |
It was skipping elements and wasn't actually doing what it was supposed to do.
|
| |
|
|
|
|
| |
This allows consolidating all the empty get_children methods.
|
|
|
|
|
|
|
| |
I tried this to see if it would improve performance. It didn't, but it
does look nicer, so we might as well keep it.
See also 5fd5aa81483e709cb5c464c7d4bb37c8c39f2afa
|
|
|
| |
This provides a significant speedup.
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
52e67656d7728f8ba958c9c35bef3a44013ad6dd introduced a new type of
child iteration.
Some classes started yielding children in the incorrect order,
which was causing test failures in pylint.
This change corrects the ordering to match the _astroid_fields
of the class.
Relates to a change from #497
|
| |
|
|
|
|
|
| |
Some nodes such as the ExceptHandler has a name object but that is an AST node,
not a string. This fix prevents a crash when trying to repr() an ExceptHandler.
|
|
|
|
|
|
| |
Because we don't support Python 2 any longer in the master branch, we can
return values from generators to signal that we want to throw a StopIteration,
without actually raising the StopIteration itself.
|
|
|
|
|
|
|
|
| |
`_multi_line_block_fields` is a list of strings indicating which
fields contain multi-line blocks. `_get_multi_line_blocks` dynamically
accesses these attributes the first time it is called and then caches
the resulting references so as to avoid repeated expensive attribute
lookups.
|
|
|
|
|
|
| |
Yield statements can only appear in multiline bodies (like function
definitions) and in lambdas, so there is no need to check other nodes
for them.
|
|
|
|
|
| |
Return statements can only appear in multiline bodies (like function
definitions), so there is no need to check other nodes for them.
|
|
|
|
|
|
|
| |
Assign statements can only appear in multiline bodies (like function
definitions) and in the value side of assign statements (e.g. `b = 4`
is an assign node contained in `a = b = 4`), so there is no need to
check other nodes for them.
|
| |
|
|
|
|
|
|
| |
This allows .root().name calls to work for Unknown objects
Close #523
|
|
|
|
| |
This reverts commit 06273cd07d4b3701998df7b2c656d1b029bdee8e.
|
|
|
|
| |
importing astroid.objects causes curcular imports with manager
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
The check was being repeated unnecessarily in a tight loop.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
|
|
|
| |
This means we can put an Unknown node in RHS of an assignment operations, which will be useful for brain related transforms.
|