From d2491fc57aa6ae7c906889ebfa015d47899f3d79 Mon Sep 17 00:00:00 2001 From: James Addison Date: Sat, 19 Oct 2024 21:10:22 +0100 Subject: [PATCH] Fixup: re-declare `_Status` type in terms of `LinkStatus` values --- sphinx/builders/linkcheck.py | 39 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 19 deletions(-) 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.