Hi, On Wed, Jul 1, 2015 at 12:40 PM, Ahirnish Pareek <ahirnish@arista.com> wrote:
Hi all,
I was going through the checkers/typecheck.py for reference but could not understand it concretely.
I am basically unable to find how to retrieve arguments from Astng Function node.
I am using visit_function() inside a checker class to visit all function nodes but not able to get list of arguments(and varargs and kwargs too).
You should access node.args (an Arguments) node, as seen below: from astroid.test_utils import extract_node n = extract_node(''' def test(a, *args, b=None, **kwargs): pass ''') print(n.args.args, n.args.kwonlyargs, n.args.vararg, n.args.kwarg)
Also, is there a function which returns <type function> if we pass Astng Function node to it?
Do you mean the equivalent of type(function) from Python? You can try the new astroid.helpers.object_type from soon-to-be astroid 1.4: https://bitbucket.org/logilab/astroid/src/3d3cb4d45368bc80b0e80d24d758d884a1... /Claudiu