Skip to content

Commit

Permalink
docs: Mention Choice's Enum support in published docs, publish __init…
Browse files Browse the repository at this point in the history
…__ docs

The fact that Choice/as_choice() support working with Enums
was not visible in built/published documentation - fix this.

Signed-off-by: Ievgen Popovych <[email protected]>
  • Loading branch information
Jmennius committed Nov 9, 2023
1 parent d8c649e commit ff68ea7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions confuse/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ def as_path(self):
def as_choice(self, choices):
"""Get the value from a list of choices. Equivalent to
`get(Choice(choices))`.
Sequences, dictionaries and :class:`Enum` types are supported,
see :class:`confuse.templates.Choice` for more details.
"""
return self.get(templates.Choice(choices))

Expand Down
3 changes: 3 additions & 0 deletions confuse/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ def convert(self, value, view):

class Choice(Template):
"""A template that permits values from a sequence of choices.
Sequences, dictionaries and :class:`Enum` types are supported,
see :meth:`__init__` for usage.
"""
def __init__(self, choices, default=REQUIRED):
"""Create a template that validates any of the values from the
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Templates
.. automodule:: confuse.templates
:members:
:private-members:
:special-members: __init__
:show-inheritance:

Utility
Expand Down

0 comments on commit ff68ea7

Please sign in to comment.