
This is somewhat inspired by the "Tagged strings in python" thread, but from a different approach. Specifically, rather than messing with runtime python, using static type analysis to help the usability of specific kinds of string literals. It would be useful to take advantage of the `LiteralString` or `Literal` type hints to add structural validation to literals. For *example*, if these could be subclassed to add a validation method: class MyLiteral(LiteralString): def __validate__(self): ... or extended to allow something like regex in there generic type parameter: Literal[r"\w+"] LiteralString[r"\w+"] then specific kinds of literal string can be "enforced" by static type checkers. Then IDEs could at the very least highlight that a string literal is not valid. I stress these are just examples, the goal is to have a way to tell a static type checker what the structure of a string literal has to be.