Skip to content

Commit 7409bb1

Browse files
committed
Move check_anchors test first; combine two if-statements
1 parent 7c68091 commit 7409bb1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sphinx/builders/linkcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ def _check_uri(self, uri: str, hyperlink: Hyperlink) -> tuple[str, str, int]:
406406
_user_agent=self.user_agent,
407407
_tls_info=(self.tls_verify, self.tls_cacerts),
408408
) as response:
409-
if response.ok and self.check_anchors:
410-
if anchor and not contains_anchor(response, anchor):
409+
if (self.check_anchors and response.ok and anchor
410+
and not contains_anchor(response, anchor)):
411411
raise Exception(__(f'Anchor {anchor!r} not found'))
412412

413413
# Copy data we need from the (closed) response

0 commit comments

Comments
 (0)