-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Fix environment variables documentation generation (#362
)"" This reverts commit 7fa4683.
- Loading branch information
Showing
9 changed files
with
318 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,27 @@ | ||
"""Documentation generation.""" | ||
|
||
from collections.abc import Generator | ||
from collections.abc import Iterator | ||
from enum import Enum | ||
from typing import Any, Generic, TypeVar | ||
|
||
_T = TypeVar("_T") | ||
|
||
class IterableStrEnum(str, Enum): | ||
"""Polyfill that also introduces dict-like behavior | ||
class SuperEnum(Generic[_T], Enum): | ||
"""Adds constructors that return all items in a ``Generator``. | ||
Introduces constructors that return a ``Generator`` object | ||
Introduces constructors that return a ``Iterator`` object | ||
either containing all items, only their names or their values. | ||
""" | ||
|
||
@classmethod | ||
def items(cls) -> Generator[tuple[_T, Any], None, None]: | ||
def items(cls) -> Iterator[tuple[str, str]]: | ||
"""Return all item names and values in tuples.""" | ||
return ((e.name, e.value) for e in cls) | ||
|
||
@classmethod | ||
def keys(cls) -> Generator[_T, None, None]: | ||
def keys(cls) -> Iterator[str]: | ||
"""Return all item names.""" | ||
return (e.name for e in cls) | ||
|
||
@classmethod | ||
def values(cls) -> Generator[Any, None, None]: | ||
def values(cls) -> Iterator[str]: | ||
"""Return all item values.""" | ||
return (e.value for e in cls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from pydantic import BaseSettings, Field | ||
|
||
|
||
class NestedSettings(BaseSettings): | ||
attr: str = Field("attr") | ||
|
||
|
||
class ParentSettings(BaseSettings): | ||
not_nested_field: str = Field("not_nested_field") | ||
nested_field: NestedSettings = Field(...) | ||
field_with_env_defined: str = Field( | ||
default=..., | ||
env="FIELD_WITH_ENV_DEFINED", | ||
) |
Oops, something went wrong.