diff --git a/sphinx/builders/linkcheck.py b/sphinx/builders/linkcheck.py index 0ed109ab91d..cb43df14440 100644 --- a/sphinx/builders/linkcheck.py +++ b/sphinx/builders/linkcheck.py @@ -28,6 +28,18 @@ from sphinx.util.http_date import rfc1123_to_epoch from sphinx.util.nodes import get_node_line + +class LinkStatus(StrEnum): + BROKEN = 'broken' + IGNORED = 'ignored' + TIMEOUT = 'timeout' + RATE_LIMITED = 'rate-limited' + REDIRECTED = 'redirected' + UNCHECKED = 'unchecked' + UNKNOWN = 'unknown' + WORKING = 'working' + + if TYPE_CHECKING: from collections.abc import Callable, Iterator from typing import Any, Literal, TypeAlias @@ -40,14 +52,14 @@ from sphinx.util.typing import ExtensionMetadata _Status: TypeAlias = Literal[ - 'broken', - 'ignored', - 'local', - 'rate-limited', - 'redirected', - 'timeout', - 'unchecked', - 'working', + LinkStatus.BROKEN, + LinkStatus.IGNORED, + LinkStatus.TIMEOUT, + LinkStatus.RATE_LIMITED, + LinkStatus.REDIRECTED, + LinkStatus.UNCHECKED, + LinkStatus.UNKNOWN, + LinkStatus.WORKING, ] _StatusUnknown: TypeAlias = _Status | Literal[''] _URIProperties: TypeAlias = tuple[_Status, str, int] @@ -66,17 +78,6 @@ DEFAULT_DELAY = 60.0 -class LinkStatus(StrEnum): - BROKEN = 'broken' - IGNORED = 'ignored' - TIMEOUT = 'timeout' - RATE_LIMITED = 'rate-limited' - REDIRECTED = 'redirected' - UNCHECKED = 'unchecked' - UNKNOWN = 'unknown' - WORKING = 'working' - - class CheckExternalLinksBuilder(DummyBuilder): """ Checks for broken external links.