A literal string type for Python
A literal string type for Python
Posted Apr 19, 2022 15:23 UTC (Tue) by gbleaney (guest, #158077)In reply to: A literal string type for Python by mathstuf
Parent article: A literal string type for Python
PEP author here. Appendix B provides a trivial function for turning any regular external string into a 'LiteralString':
https://peps.python.org/pep-0675/#appendix-b-limitations
https://peps.python.org/pep-0675/#appendix-b-limitations
If a developer want to circumvent the protections of 'LiteralString', they can easily do it. They don't even need fancy functions like the example we gave, they can just add a '# pyre-ignore' (or equivalent lint suppression comment for their typechecker of choice). The goal is to protect against accidental mistakes, not malicious or implausible behaviour by developers.
