Skip to content
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 a StrEnum to record linkcheck status codes #13043

Conversation

jayaddison
Copy link
Contributor

Feature or Bugfix

  • Refactoring

Purpose

  • Add some code-symbol safety to the linkcheck builder.

Detail

  • Use a StrEnum to declare the available hyperlink result status codes.

Relates

@@ -158,14 +172,14 @@ def process_result(self, result: CheckResult) -> None:
red('broken ') + result.uri + red(' - ' + result.message)
)
self.write_entry(
'broken',
result.status,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result.status,
LinkStatus.BROKEN.value,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a specific symbol/status-code per write_entry call makes sense to me; I'm less sure about the .value access though. What's the thinking there?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'broken' is a literal, the closest semantic replacement is the LinkStatus.BROKEN.value constant, rather than the result.status variable.

@AA-Turner AA-Turner changed the title linkcheck: use py311 StrEnum for status codes linkcheck: Use a StrEnum to record status codes Oct 20, 2024
@AA-Turner AA-Turner changed the title linkcheck: Use a StrEnum to record status codes linkcheck: Use a StrEnum to record status codes Oct 20, 2024
@AA-Turner AA-Turner changed the title linkcheck: Use a StrEnum to record status codes Use a StrEnum to record linkcheck status codes Oct 20, 2024
@AA-Turner AA-Turner merged commit 88f560c into sphinx-doc:master Oct 20, 2024
23 checks passed
@jayaddison
Copy link
Contributor Author

Thanks @AA-Turner!

@jayaddison jayaddison deleted the refactor/2-of-3/linkcheck-status-code-enums branch October 20, 2024 18:25
@AA-Turner AA-Turner added this to the 8.2.0 milestone Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants