Closed jayaddison closed 1 month ago
Why LiteralString
over Literal[...]
?
Ah; to be honest, I'd forgotten about Literal
and didn't notice it despite double-checking some usage details for LiteralString
(which is what I misread your suggestion to be..).
Assuming that I had opened a PR with the intended change instead, using Literal[...]
: that would be a nice low-overhead type safety mechanism, but wouldn't provide much runtime assurance, if I understand it correctly. Additionally, the diff from here to StrEnum
introduction might be slightly unusual -- it would involve complete replacement of the Literal
-based type alias approach with a StrEnum
alternative (that does provide runtime safety).
Note: from a readability point of view, I do find the dotted-attribute format (for example, LinkStatus.WORKING
) an improvement, so I would like to migrate to StrEnum
.
(the reason I mention this is because Literal[...]
almost seems like it could solve my refactoring goals entirely, without using StrEnum
at all.. except that I don't think standalone constants are ideal; grouping them logically within a parent container is helpful, I think)
Superseded by #13040.
Feature or Bugfix
Purpose
status
codes in thelinkcheck
builder.StrEnum
(Py3.11+) to declare the available status codes.Detail
LiteralString
typing tostatus
code variables.Relates