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

Type hint parsing with ParamSpec complains about that ParamSpec has no attribute '__origin__' #12058

Open
wldhg opened this issue Mar 10, 2024 · 1 comment

Comments

@wldhg
Copy link

wldhg commented Mar 10, 2024

Describe the bug

below error occurs while buliding documentation

WARNING: error while formatting arguments for example.ex1.ExampleClass: 'typing.ParamSpec' object has no attribute '__origin__'
WARNING: error while formatting signature for example.ex1.ExampleClass: Handler <function record_typehints at 0x7f8baa513c40> for event 'autodoc-process-signature' threw an exception (exception: 'typing.ParamSpec' object has no attribute '__origin__')

How to Reproduce

I prepared a minimal example for this.

https://github.com/wldhg/sphinx-paramspec

conf.py

project = "Example"
copyright = "example"
author = "example"

extensions = [
    "sphinx.ext.autodoc"
]

index.rst

.. automodule:: example.ex1
  :members:

ex1.py

class ExampleClass[**P]:
    """
    example class
    """
    def __init__(self, *args: P.args, **kwargs: P.kwargs):
        ...


def example_function[**P](cls: type[ExampleClass[P]]) -> type[ExampleClass[P]]:
    """
    example function
    """
    return cls

Environment Information

- Python 3.12.2 on Linux x86-64 machine
- sphinx 7.2.6

Sphinx extensions

[
    "sphinx.ext.autodoc"
]

Additional context

No response

@wldhg wldhg added the type:bug label Mar 10, 2024
@wldhg
Copy link
Author

wldhg commented Mar 10, 2024

Also the error seems to occur in here:

if _name:
qualname = _name
elif annotation_qualname:
qualname = annotation_qualname
else:
qualname = stringify_annotation(
annotation.__origin__, 'fully-qualified-except-typing',
).replace('typing.', '') # ex. Union

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants