Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Unified Diff: third_party/logilab/astroid/__init__.py

Issue 753543006: pylint: upgrade to 1.4.0 (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/logilab/astroid/README.chromium ('k') | third_party/logilab/astroid/__pkginfo__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/logilab/astroid/__init__.py
diff --git a/third_party/logilab/astroid/__init__.py b/third_party/logilab/astroid/__init__.py
index 19c809028a51c6acb5b881f1047adf7a92cc343f..d4fd12c577a57f5674bbe7324be7e80722959bba 100644
--- a/third_party/logilab/astroid/__init__.py
+++ b/third_party/logilab/astroid/__init__.py
@@ -79,6 +79,9 @@ class AsStringRegexpPredicate(object):
If specified, the second argument is an `attrgetter` expression that will be
applied on the node first to get the actual node on which `as_string` should
be called.
+
+ WARNING: This can be fairly slow, as it has to convert every AST node back
+ to Python code; you should consider examining the AST directly instead.
"""
def __init__(self, regexp, expression=None):
self.regexp = re.compile(regexp)
@@ -98,13 +101,23 @@ def inference_tip(infer_function):
.. sourcecode:: python
MANAGER.register_transform(CallFunc, inference_tip(infer_named_tuple),
- AsStringRegexpPredicate('namedtuple', 'func'))
+ predicate)
"""
def transform(node, infer_function=infer_function):
node._explicit_inference = infer_function
return node
return transform
+
+def register_module_extender(manager, module_name, get_extension_mod):
+ def transform(node):
+ extension_module = get_extension_mod()
+ for name, obj in extension_module.locals.items():
+ node.locals[name] = obj
+
+ manager.register_transform(Module, transform, lambda n: n.name == module_name)
+
+
# load brain plugins
from os import listdir
from os.path import join, dirname
« no previous file with comments | « third_party/logilab/astroid/README.chromium ('k') | third_party/logilab/astroid/__pkginfo__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698