Feneric / doxypypy

A more Pythonic version of doxypy, a Doxygen filter for Python.
GNU General Public License v2.0
149 stars 49 forks source link

unexpected keyword argument #80

Closed BeastyBlacksmith closed 2 years ago

BeastyBlacksmith commented 3 years ago

Trying doxypypy on this file got me the following error

Traceback (most recent call last):
  File "/home/schrist/projects/pyama/env/bin/doxypypy", line 11, in <module>
    load_entry_point('doxypypy==0.8.8.6', 'console_scripts', 'doxypypy')()
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 830, in main
    astWalker.parseLines()
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 743, in parseLines
    self.visit(inAst)
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 569, in visit
    return visitor(node, containingNodes=containingNodes)
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 594, in visit_Module
    self.generic_visit(node, containingNodes=kwargs.get('containingNodes',
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 553, in generic_visit
    self.visit(item, containingNodes=kwargs['containingNodes'])
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 569, in visit
    return visitor(node, containingNodes=containingNodes)
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 735, in visit_ClassDef
    self.generic_visit(node, containingNodes=containingNodes)
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 553, in generic_visit
    self.visit(item, containingNodes=kwargs['containingNodes'])
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 569, in visit
    return visitor(node, containingNodes=containingNodes)
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 555, in generic_visit
    self.visit(value, containingNodes=kwargs['containingNodes'])
  File "/home/schrist/projects/pyama/env/lib/python3.8/site-packages/doxypypy/doxypypy.py", line 569, in visit
    return visitor(node, containingNodes=containingNodes)
TypeError: visit_Constant() got an unexpected keyword argument 'containingNodes'
FreshMax9000 commented 3 years ago

I got this error too and I dont know why. NodeVisitor method visit_Constant() of ast.py of CPython assumes that a constant has no containing Nodes. Therefore an error is raised when trying to call it with containing Nodes. Heres a quick workaround for the visit() method of doxypypys AstWalker:

  def visit(self, node, **kwargs):
        """
        Visit a node and extract useful information from it.

        This is virtually identical to the standard version contained in
        NodeVisitor.  It is only overridden because we're tracking extra
        information (the hierarchy of containing nodes) not preserved in
        the original.
        """
        containingNodes = kwargs.get('containingNodes', [])        
        method = 'visit_' + node.__class__.__name__
        visitor = getattr(self, method, self.generic_visit)
        if node.__class__.__name__ == "Constant":
            return visitor(node)
        return visitor(node, containingNodes=containingNodes)
rynkk commented 3 years ago

This was already fixed in c0e95e4c3ecec10da9de00adae0d77bc52f3933f , 4 months ago. The doxypypy version on PyPi seems to be outdated. If you install the package via pip install git+"thisrepo" it works fine.

Feneric commented 2 years ago

Yeah, a few of the listed bugs here are fixed in the current version. I'm hoping to get a new version ready for PyPi in the near future, but am trying to get a few things resolved first.