Skip to content

Commit

Permalink
Fixup: re-declare _Status type in terms of LinkStatus values
Browse files Browse the repository at this point in the history
  • Loading branch information
jayaddison committed Oct 19, 2024
1 parent f35a605 commit d2491fc
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions sphinx/builders/linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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.
Expand Down

0 comments on commit d2491fc

Please sign in to comment.