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

Config subclass is shown when explicitly set otherwise #291

Closed
Ecaloota opened this issue Jun 13, 2024 · 4 comments
Closed

Config subclass is shown when explicitly set otherwise #291

Ecaloota opened this issue Jun 13, 2024 · 4 comments

Comments

@Ecaloota
Copy link

Ecaloota commented Jun 13, 2024

Given the following relevant conf.py options:

autodoc_pydantic_model_show_config_summary = False
autodoc_pydantic_model_show_config_member = False
autodoc_pydantic_config_members = False

And a Pydantic model such as the following:

class MyClass(BaseModel):
    job: str
    
    class Config:
        foo = 'bar'

And a rst file containing an .. automodule:: directive pointing the module which contains that model, I obtain rendered output which contains an empty field containing class Config. Also, the docstring for the Config subclass is rendered if present, and excluded if given an explicit :meta private: directive.

screencap

I would expect that at least the autodoc_pydantic_model_show_config_member might prevent the Config subclass from being rendered -- am I missing something?

Using version 2.2.0

@mansenfranzen
Copy link
Owner

Hi @Ecaloota,

thanks for raising this issue here!

I think you've might have mixed up the different versions of autodoc_pydantic regarding the documention.

autodoc_pydantic_model_show_config_member does only exist in v1 (see here) but was removed in v2 (see here). In v2, you can hide model configs via autodoc_pydantic_model_show_config_summary.

Please be aware, the nested Config class is deprecated in pydantic v2. Instead, you should use model_config.

I hope this helps.

Feel free to reopen this issue.

@mansenfranzen
Copy link
Owner

@allcontributors please add @Ecaloota for question

Copy link
Contributor

@mansenfranzen

I've put up a pull request to add @Ecaloota! 🎉

@Ecaloota
Copy link
Author

Thanks for clarifying!

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

No branches or pull requests

2 participants