Add LiteralString support to string module (#8268)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Graham Bleaney
2022-07-18 22:34:27 -04:00
committed by GitHub
parent 89154bf4c8
commit 9519e3652b
2 changed files with 28 additions and 12 deletions

View File

@@ -266,6 +266,10 @@ class structseq(Generic[_T_co]):
# Superset of typing.AnyStr that also inclues LiteralString
AnyOrLiteralStr = TypeVar("AnyOrLiteralStr", str, bytes, LiteralString) # noqa: Y001
# Represents when str or LiteralStr is acceptable. Useful for string processing
# APIs where literalness of return value depends on literalness of inputs
StrOrLiteralStr = TypeVar("StrOrLiteralStr", LiteralString, str) # noqa: Y001
# Objects suitable to be passed to sys.setprofile, threading.setprofile, and similar
ProfileFunction: TypeAlias = Callable[[FrameType, str, Any], object]