- Omit a variable that is unused aside from a ``return`` statement on the subsequent line.
- Extract a variable for readability, and to reduce the complexity of a line.
Re-organise and re-structure the ``linkcheck`` builder:
- All functions defined within functions are factored out into top-level functions or class methods
- Classes and methods have been re-arranged (Builder, PostTransform, Checker, Worker)
- TLS verification on ``sphinx.util.requests`` has been changed to not pass the ``Config`` object all the way down
- The ``Hyperlink`` object now stores the document path
- ``BuildEnvironment`` and ``Config`` objects are used to extract properties and are not stored as class attributes
TLS operates at a lower layer than HTTP, and so if there is a TLS-related error from a host,
it seems unlikely that retrying with a different higher-layer protocol request
(HTTP GET instead of HTTP HEAD) could succeed.
We should not make additional HTTP requests that we do not believe will succeed.
Python 3.12 has deprecated ``datetime.utcfromtimestamp``.
Resolve the warning by working out ``tzdelta`` via explicit timezone calculations.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
The "font" top-level media type was formalised via :rfc:`8081` in 2017.
Standard MIME types for OTF and TTF fonts have been
`registered with IANA`_ as ``font/otf`` and ``font/ttf``.
These are also listed in the EPUB 3 `core media types`_ specification.
Sphinx-generated EPUB documents including custom OTF or TTF fonts
specify a MIME type for those fonts in ``content.opf`` of
``application/x-font-otf`` or ``application/x-font-ttf`` respectively.
The ``epubcheck`` application presents informational warnings that
these MIME types are non-standard when checking such a generated
EPUB document.
Adding the correct MIME type will prevent those messages
and will also result in a valid EPUB.
.. _core media types: https://www.w3.org/TR/epub/#sec-core-media-types
.. _registered with IANA: https://www.iana.org/assignments/media-types/media-types.xhtml#font
This closes HTTP responses when no content reads are required, as
when requests are made in streaming mode, ``requests`` doesn't know
whether the caller may intend to later read content from a streamed
HTTP response object and holds the socket open.
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>