diff options
author | root <none@none> | 2006-04-26 10:48:09 +0000 |
---|---|---|
committer | root <none@none> | 2006-04-26 10:48:09 +0000 |
commit | 4becf6f9e596b45401680c4947e2d92c953d5e08 (patch) | |
tree | 3bb03a16daa8c780bf60c622dc288eb01cfca145 /examples/custom.py | |
download | pylint-git-4becf6f9e596b45401680c4947e2d92c953d5e08.tar.gz |
forget the past.
forget the past.
Diffstat (limited to 'examples/custom.py')
-rw-r--r-- | examples/custom.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/custom.py b/examples/custom.py new file mode 100644 index 000000000..73b64e149 --- /dev/null +++ b/examples/custom.py @@ -0,0 +1,38 @@ +from logilab import astng + +from pylint.interfaces import IASTNGChecker +from pylint.checkers import BaseChecker + +class MyASTNGChecker(BaseChecker): + """add member attributes defined using my own "properties" function + to the class locals dictionary + """ + + __implements__ = IASTNGChecker + + name = 'custom' + msgs = {} + options = () + # this is important so that your checker is executed before others + priority = -1 + + def visit_callfunc(self, node): + """called when a CallFunc node is encountered. See compiler.ast + documentation for a description of available nodes: + http://www.python.org/doc/current/lib/module-compiler.ast.html + ) + """ + if not (isinstance(node.node, astng.Getattr) + and isinstance(node.node.expr, astng.Name) + and node.node.expr.name == 'properties' + and node.node.attrname == 'create'): + return + in_class = node.frame() + for param in node.args: + in_class.locals[param.name] = node + + +def register(linter): + """required method to auto register this checker""" + linter.register_checker(MyASTNGChecker(linter)) + |