mitmproxy / pdoc

API Documentation for Python Projects

Home Page:https://pdoc.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError in /pdoc/extract.py

pnjun opened this issue · comments

commented

Problem Description

When running pdoc, i get a TypeError. I cannot figure out if this is a bug in pdoc or if it is a problem with my project, since the traceback is completely internal to pdoc files and does not show any file from my module, so i would not even know where to start looking for errors.

If the problem is with my package and not pdoc itself, i suppose a better error message would be appropriate.
Does anyone have insights in what could cause the issue?

Thanks

Traceback (most recent call last):
  File "/home/leverfab/.conda/envs/fabdev/bin//pdoc", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/__main__.py", line 199, in cli
    pdoc.pdoc(
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/__init__.py", line 509, in pdoc
    for module_name in extract.walk_specs(modules):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/extract.py", line 74, in walk_specs
    for m in walk_packages2([mod_info]):
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/extract.py", line 306, in walk_packages2
    yield from walk_packages2(submodules.values())
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/extract.py", line 305, in walk_packages2
    submodules = iter_modules2(module)
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/leverfab/.conda/envs/fabdev/lib/python3.11/site-packages/pdoc/extract.py", line 257, in iter_modules2
    member = getattr(module, name, None)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: attribute name must be string, not 'type'

Steps to reproduce the behavior:

run PDOC_ALLOW_EXEC=1 pdoc ./mypackage docformat google -o ./somefolder

System Information

pdoc: 14.4.0
Python: 3.11.0
Platform: Linux-3.10.0-1160.80.1.el7.x86_64-x86_64-with-glibc2.17

The problem here is that dir(module) returns a non-str object in your module. We should catch that in pdoc and ignore it.

commented

Thanks a lot! I will try to figure out where i return that object and see how to deal with it on my end. I have never contributed to an open source project before, but if I manage to get on to it i will try to make a pull request and fix in pdoc if it's alright with you