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

Fix for issue 137 - cannot compare between <type> and None when sorting fields #190

Merged
merged 27 commits into from
Mar 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2e74e8f
Fix for issue 137
Dec 18, 2023
98f68f5
Merge branch 'mansenfranzen:main' into issue_137
j-carson Dec 27, 2023
ea97fe9
Add reproducible test case.
mansenfranzen Dec 28, 2023
dc647a3
Merge branch 'mansenfranzen:main' into issue_137
j-carson Dec 30, 2023
32cc4b3
Work on edge cases
Dec 31, 2023
b13c174
lint
Dec 31, 2023
6d51607
Fix some edgecases in sorting, change test case answer where inherite…
Jan 19, 2024
571f4fc
use backward compatible List type hint
Jan 19, 2024
e85cf2c
lint
Jan 19, 2024
f3b8e4f
fix applehelp build issue
Jan 19, 2024
2348152
try applehelp again
Jan 19, 2024
94f4ad8
reverting applehelp stuff
Jan 19, 2024
23a1a4d
another attempt at sphinx4 ci failure
Jan 19, 2024
dd69791
tolerate inherited validator showing up if its python 3.9 or older
Jan 22, 2024
f55e320
accidentally removed erdantic from base testenv
Jan 22, 2024
32f657a
Update to main - Merge branch 'main' into issue_137
mansenfranzen Mar 12, 2024
6514384
Introduce `options.exists` for better consistency.
mansenfranzen Mar 12, 2024
8e9857d
Do not hide model config in any case.
mansenfranzen Mar 12, 2024
c333d6a
Remove obsolete `hide-config-member`
mansenfranzen Mar 12, 2024
13026a0
Add explicit tests for inheritance w/o overwrite.
mansenfranzen Mar 14, 2024
50275f0
Minor simplification and readability improvements.
mansenfranzen Mar 14, 2024
631d312
Add test with field on child class. Streamline compat.
mansenfranzen Mar 14, 2024
e90e350
Improve naming `get_non_inherited_members`
mansenfranzen Mar 14, 2024
9899691
Flake 8
mansenfranzen Mar 14, 2024
b13eab8
Remove obsolete config options.
mansenfranzen Mar 14, 2024
9f4b124
Update changelog.
mansenfranzen Mar 14, 2024
05bf661
Fix incorrect rst syntax.
mansenfranzen Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduce options.exists for better consistency.
  • Loading branch information
mansenfranzen committed Mar 12, 2024
commit 65143842ccdf0868b39b1ff5dd24460c2c55c668
Original file line number Diff line number Diff line change
@@ -240,7 +240,7 @@ def document_members(self, *args, **kwargs):
if self.pydantic.options.is_true("hide-reused-validator", True):
self.hide_reused_validators()

if "inherited-members" in self.pydantic._documenter.options:
if self.pydantic.options.exists("inherited-members"):
self.hide_inherited_members()

super().document_members(*args, **kwargs)
25 changes: 23 additions & 2 deletions sphinxcontrib/autodoc_pydantic/directives/options/composites.py
Original file line number Diff line number Diff line change
@@ -112,9 +112,11 @@ def get_value(self, name: str,
return self.parent.options[name]
elif force_availability or self.is_available(name):
return self.get_app_cfg_by_name(name)
else:
return NONE

def is_false(self, name: str, prefix: bool = False) -> bool:
"""Get option value for given `name`. First, looks for explicit
"""Check if option with `name` is False. First, looks for explicit
directive option values (e.g. :member-order:) which have highest
priority. Second, if no directive option is given, get the default
option value provided via the app environment configuration.
@@ -133,7 +135,7 @@ def is_false(self, name: str, prefix: bool = False) -> bool:
return self.get_value(name=name, prefix=prefix) is False

def is_true(self, name: str, prefix: bool = False) -> bool:
"""Get option value for given `name`. First, looks for explicit
"""Check if option with `name` is True. First, looks for explicit
directive option values (e.g. :member-order:) which have highest
priority. Second, if no directive option is given, get the default
option value provided via the app environment configuration.
@@ -150,6 +152,25 @@ def is_true(self, name: str, prefix: bool = False) -> bool:
"""

return self.get_value(name=name, prefix=prefix) is True

def exists(self, name: str, prefix: bool = False) -> bool:
"""Check if option with `name` is set. First, looks for explicit
directive option values (e.g. :member-order:) which have highest
priority. Second, if no directive option is given, get the default
option value provided via the app environment configuration.

Enforces result to be either True or False.

Parameters
----------
name: str
Name of the option.
prefix: bool
If True, add `pyautodoc_prefix` to name.

"""

return self.get_value(name=name, prefix=prefix) is not NONE

def set_default_option(self, name: str):
"""Set default option value for given `name` from app environment