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 hints are missing in constructors when autodoc_typehints = 'description' #8689

Closed
xuhdev opened this issue Jan 15, 2021 · 2 comments
Closed

Comments

@xuhdev
Copy link
Contributor

xuhdev commented Jan 15, 2021

Describe the bug
Type hints are missing in constructors when autodoc_typehints = 'description'.

To Reproduce

  1. Download bug.tar.gz and unarchive.
  2. Run PYTHONPATH=. sphinx-build -d "./_build" docs "_build/html" -b html -W --color
├── docs
│   ├── conf.py
│   └── index.rst
└── myproject
    └── __init__.py

conf.py:

project = 'myproject'
copyright = '2020, someone'
author = 'someone'
autodoc_typehints = 'description'
extensions = [
    'sphinx.ext.autodoc',
]
html_theme = 'alabaster'

myproject/__init__.py:

class A:
    """
    :param boolean: I'm a boolean.
    """
    def __init__(self, boolean: bool):
        pass

index.rst is minimal:

Welcome to myproject's documentation!
=====================================

.. automodule:: myproject
   :members:
   :imported-members:

Expected behavior
Constructor parameter type hints should be documented.

Screenshots

With autodoc_typehints = 'description':

Screenshot_2021-01-15_15-54-22

The type hint of bool should be in the description but it's missing.

Without autodoc_typehints = 'description', bool is shown on the function prototype line as expected:

Screenshot_2021-01-15_15-55-14

Environment info

  • OS: Debian 10
  • Python version: 3.7.6
  • Sphinx version: 3.4.3
  • Sphinx extensions: autodoc
@tk0miya
Copy link
Member

tk0miya commented Jan 16, 2021

Thank you for reporting. This will be fixed by #8539.

@tk0miya tk0miya modified the milestones: 3.5.0, 4.0.0 Feb 14, 2021
@tk0miya
Copy link
Member

tk0miya commented Apr 4, 2021

Now #8539 is merged. It will be released as 4.0 soon.
Thanks,

@tk0miya tk0miya closed this as completed Apr 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants