Skip to content

Commit

Permalink
Move check_anchors test first; combine two if-statements
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 1, 2023
1 parent 1c34aef commit 6f17899
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sphinx/builders/linkcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ def _check_uri(self, uri: str, hyperlink: Hyperlink) -> tuple[str, str, int]:
_user_agent=self.user_agent,
_tls_info=(self.tls_verify, self.tls_cacerts),
) as response:
if response.ok and self.check_anchors:
if anchor and not contains_anchor(response, anchor):
if (self.check_anchors and response.ok and anchor
and not contains_anchor(response, anchor)):
raise Exception(__(f'Anchor {anchor!r} not found'))

# Copy data we need from the (closed) response
Expand Down

0 comments on commit 6f17899

Please sign in to comment.