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

`sphinx_toolbox.more_autodoc.typehints' breaks when using 'attrs' default decorator #146

Open
AVHopp opened this issue Nov 3, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@AVHopp
Copy link

AVHopp commented Nov 3, 2023

Description

When using attrs to define a class, using the @default decorator is not possible.

Steps to Reproduce

test.py:

from attrs import define, field

@define
class X_decorator:
    value: int = field()

    @value.default
    def _value_default(self) -> int:
        return 3

@define
class X_no_decorator:
    value: int = field(default=3)

conf.py:

extensions = [
    "sphinx_toolbox.more_autodoc.typehints",
    "sphinx.ext.autodoc",
]
master_doc = "index"
autodoc_preserve_defaults = False

index.rst:

.. automodule:: test
    :members:
    :undoc-members:

Actual result:

Performing pip-run sphinx -- -m sphinx . build then creates the correct documentation for the class X_no_decorator, but fails to do so for the X_decorator one due to an error:
image

image

Expected result:

I would have expected that one gets the same result for both classes.

Version

  • Operating System: MacOS
  • Python: 3.9.18
  • sphinx-toolbox: 3.5.0

Installation source

pip

@AVHopp AVHopp added the bug Something isn't working label Nov 3, 2023
AdrianSosic pushed a commit to emdgroup/baybe that referenced this issue Nov 28, 2023
This PR introduces a more elaborate, HTML based documentation. It uses `sphinx` and the `read-the-docs` theme and is automatically created when calling `convert_code_to_documentation`.

The following changes are made by this PR:
- Add explicit `CONTRIBUTORS.md` file.
- Change links in `README.md` such that they work in the html version
- Add `concepts` folder and stub files for introducing general concepts of BayBE.
- Adjust the docstrings of attributes: These now need to be in the line below the attribute, NOT in the class docstring!
- Debug functionality for code conversion via `--debug` flag
- Simplification of conversion script
- Fix inheritance, thus implementing #18775
- Functionality to include examples when creating the documentation
- Making the script fail when errors are encountered during the building of the documentation
- General fixing of broken links, typos and so on

The following aspects still need to be done and will be part of an upcoming PR:
- Fill concept pages with actual content
- Adjust the CONTRIBUTION.md and CONTRIBUTORS.md file

Note that there are some issues that we should still discuss about:
- What do we do with the defaults? This is bugged (sphinx-toolbox/sphinx-toolbox#146) and might require some workaround.

Related work items: #18775, #19312
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants