Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: no attribute 'signature_without_self' #519

Closed
ekwan opened this issue Mar 7, 2023 · 5 comments
Closed

Error: no attribute 'signature_without_self' #519

ekwan opened this issue Mar 7, 2023 · 5 comments
Labels

Comments

@ekwan
Copy link

ekwan commented Mar 7, 2023

Problem Description

Hi! I'm getting an error:

jinja2.exceptions.UndefinedError: 'pdoc.doc.Module object' has no attribute 'signature_without_self'

Any idea what it could be?

Here's the full trace:

Traceback (most recent call last):
File "/Users/kwaneu/miniconda3/envs/obsidian/bin/pdoc", line 8, in
sys.exit(cli())
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/main.py", line 185, in cli
pdoc.pdoc(
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/init.py", line 513, in pdoc
search = render.search_index(all_modules)
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/render.py", line 147, in search_index
index = make_index(
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/search.py", line 116, in make_index
documents.extend(make_index(module))
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/search.py", line 86, in make_index
if not is_public(mod):
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/render.py", line 145, in is_public
return bool(ctx"is_public".strip())
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/jinja2/runtime.py", line 763, in call
return self._invoke(arguments, autoescape)
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/jinja2/runtime.py", line 777, in _invoke
rv = self._func(*arguments)
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/pdoc/templates/default/module.html.jinja2", line 783, in macro
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/jinja2/environment.py", line 485, in getattr
return getattr(obj, attribute)
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/jinja2/runtime.py", line 859, in getattr
return self._fail_with_undefined_error()
File "/Users/kwaneu/miniconda3/envs/obsidian/lib/python3.10/site-packages/jinja2/runtime.py", line 852, in _fail_with_undefined_error
raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'pdoc.doc.Module object' has no attribute 'signature_without_self'

Steps to reproduce the behavior:

pdoc -o docs obsidian/*.py obsidian/benchmarks/*.py obsidian/models/*.py

System Information

pdoc: 13.0.0
Python: 3.10.9
Platform: macOS-10.16-x86_64-i386-64bit

@ekwan ekwan added the bug label Mar 7, 2023
@mhils
Copy link
Member

mhils commented Mar 7, 2023

Can you please provide self-contained steps to reproduce this? Where can I find obsidian?

@mhils mhils closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
@lorenzoconti
Copy link

I had the same issue with version 13.0.0. I downgraded to 12.3.1 and now it works fine.

I'm running the following command
pdoc -o ./docs -d google <package-name>

Unfortunately I can't share the package, but maybe can help @ekwan

@mhils
Copy link
Member

mhils commented Mar 21, 2023

I've tried quite a bit to reproduce this, but no dice - we need some reproducer here to understand what's going on. I'm happy to handle examples confidentially if you can send them by email.

@mhils mhils reopened this Mar 21, 2023
mhils added a commit to mhils/pdoc that referenced this issue Mar 21, 2023
@mhils
Copy link
Member

mhils commented Mar 21, 2023

Someone volunteered their codebase, this will be fixed with #522! :)

@mhils
Copy link
Member

mhils commented Mar 21, 2023

From email:

Cool, would you mind sharing what the problem was on the Issue page so we can all learn? Thanks!

The root cause here was that an invocation like pdoc ./foo/__init__.py would cause pdoc to treat foo.__init__ as the module to document, as opposed to just foo. That's fixed here.

This bug also exists in previous releases, but came to light in 13.0.0 because there we incorrectly assumed that something named __init__ is a function (which would have a signature_without_self attribute). That's wrong as well, so I've also added a guard to that here and a test here.

@mhils mhils closed this as completed in 84195d7 Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants