Add *args and **kwargs in generic_visit and visit_* in ast module

I guess this must be requested earlier, but I didn’t find it on the internet, how do people get the status of the current path being traversed, relating it to a basic tree problem (finding the good node, max-path sum, etc) I am solving a weird problem(statically analyzing the code base to find out if it can be ported to async).

I guess for this we need to add *args and **kwargs in generic_visit( and visit_*( methods

my issue got resolved by popping while backtracking.

    def visit_ClassDef(self, node):
        if self.file_list:

but adding *args, and **kwargs can open visit_* for new usecases

(Moved topic to Python Help.)

There is a request as well to add *args and **kwargs in generic_visit and visit_* in ast module, @jeanas I guess this comes under ideas as I am proposing a change in Python

Ok… I’ve moved it back, but I must say I am not able to understand what you are trying to do and why you need *args and **kwargs in NodeVisitor for that. Please try to elaborate and explain why this would be useful, ideally with examples.

added an example in the question description, Btw, Mod has moved it back to python-help after I moved it to ideas, I guess this is not going to be entertained as my use-case can be implemented without adding *args and **kwargs.

Figure out how to clearly describe your issue and proposed fix, and if it is actually needed vs fixing your code. Then make an actual proposal to the Ideas category if needed. As it’s worded now, this is not a viable proposal.


sure things, Actually, I rushed into proposing it without thinking about my wording, will keep this in mind in the future. But I don’t think I will be able to make a good proposal for this considering my experience.

This is not required, we have ast.iter_child_nodes, and we can use it in dfs to traverse over the tree and can store info on the paths.