Skip to content

Commit

Permalink
update sphinx
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasertl committed Dec 22, 2024
1 parent 938b8b8 commit 3a25bfb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
10 changes: 10 additions & 0 deletions ca/django_ca/management/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ class BinaryOutputWrapper(OutputWrapper):
def __init__(self, out: typing.BinaryIO, ending: bytes = b"\n") -> None:
super().__init__(out, ending=ending) # type: ignore[arg-type]

def flush(self) -> None:
"""Overwritten from base class so we don't try to flush when the stream is already closed.
Starting with Python 3.13, we see some untraceable teardown code call flush() despite the stream
already being closed.
"""
if self._out.closed is True: # pragma: only py>=3.13
return
super().flush()

def write( # type: ignore[override]
self,
msg: Union[str, bytes] = b"",
Expand Down
3 changes: 3 additions & 0 deletions ca/django_ca/pydantic/type_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def str_loader(value: str) -> T:

NonEmptyOrderedSetTypeVar = TypeVar("NonEmptyOrderedSetTypeVar", bound=list[Any])

#: A string that will convert :py:class:`~cg:cryptography.x509.ObjectIdentifier` objects.
#:
#: This type alias will also validate the x509 dotted string format.
OIDType = Annotated[str, BeforeValidator(oid_parser), AfterValidator(oid_validator)]

UniqueTupleTypeVar = TypeVar("UniqueTupleTypeVar", bound=tuple[Hashable, ...])
Expand Down
4 changes: 2 additions & 2 deletions ca/django_ca/pydantic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ def serial_validator(value: str) -> str:


def timedelta_as_number_parser(unit: Literal["seconds", "hours", "days"] = "seconds") -> Callable[[Any], Any]:
"""Validator for timedeltas.
"""Validator for ``timedelta``.
.. WARNING:: This validator differs in that it has to be called with a unit for timedeltas.
.. WARNING:: This validator differs in that it has to be called with a unit for ``timedeltas``.
"""

def validator(value: Any) -> Any:
Expand Down
8 changes: 8 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,11 @@
"basename": os.path.basename,
}

# Warnings
suppress_warnings = [
"config.cache", # jinja_filters has unpickable objects
]

qualname_overrides = {
"_io.BytesIO": "python:io.BytesIO",
"_io.StringIO": "python:io.StringIO",
Expand Down Expand Up @@ -500,7 +505,10 @@
# Ignore (not so important) classes where the documented name does not match the documented name.
nitpick_ignore = [
("py:class", "NoneType"),
("py:class", "lambda"),
("py:class", "locals>.<lambda"),
# TypeVars for classes that make no sense in documenting.
("py:class", "django_ca.pydantic.validators.T"),
("py:class", "django_ca.key_backends.base.CreatePrivateKeyOptionsTypeVar"),
("py:class", "django_ca.key_backends.base.StorePrivateKeyOptionsTypeVar"),
("py:class", "django_ca.key_backends.base.UsePrivateKeyOptionsTypeVar"),
Expand Down
7 changes: 7 additions & 0 deletions docs/source/python/pydantic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,10 @@ Models for CRL extensions are not currently used within the project itself.
.. autoclass:: django_ca.pydantic.CRLNumberModel

.. autoclass:: django_ca.pydantic.DeltaCRLIndicatorModel

**********
Validators
**********

.. automodule:: django_ca.pydantic.validators
:members:
2 changes: 1 addition & 1 deletion requirements/requirements-dev-common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
GitPython==3.1.43
Jinja2==3.1.4
PyYAML==6.0.2
Sphinx==7.2.6
Sphinx==7.3.7
coverage[toml]==7.6.9
django-test-migrations==1.4.0
pytest==8.3.4
Expand Down

0 comments on commit 3a25bfb

Please sign in to comment.