-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use structural pattern matching to handle linkcheck result statuses #13049
Use structural pattern matching to handle linkcheck result statuses #13049
Conversation
This anticipates an additional level of indendation to be added for the relevant code during the introduction of Structural Pattern Matching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we integrate the UNCHECKED
and WORKING
(old) checks above into the match
? Ideally, as we use an enum, we shouldn't need to use case _
-- we just check every valid state.
A
Relates-to commit 4351721. URLs are de-duplicated by ``CheckExternalLinksBuilder.hyperlinks``.
if result.status == _Status.WORKING and result.message == 'old': | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting for future historians: the old
message tag here was a way that the linkcheck
component would communicate to itself that a hyperlink had already been checked and confirmed as working ('good').
That code was removed in 4351721, and I believe that the URI deduplication that was removed there is no longer necessary, because linkcheck
nowadays collects hyperlinks in a Python dict
, CheckExternalLinksBuilder.hyperlinks
, keyed by the URI; so duplicates should not occur anyway.
@AA-Turner changelog entry required, do you think? |
There's no visible behaviour change to users so I shouldn't think one is required. |
Thank you @jayaddison! A |
Brilliant! Thank you for the code reviews! |
It seems 'local' is currently unused, by the way. |
Mmm. As is the For |
Feature or Bugfix
Purpose
[el]if...result.status == <status>
conditions in part of thelinkcheck
code expose an intended behaviour: each status code implies that the code should follow one particular code path to handle the result. This seems like a good fit for amatch
clause, available from Python3.11+.Detail
linkcheck
status codes using amatch
statement.w=1
query-string parameter, if using the GitHub web comparison interface).Relates
StrEnum
to record linkcheck status codes #13043.