Skip to content

Commit 8fa523e

Browse files
authored
use LiteralString for sentinel name
type checkers enforce that the first argument to a sentinel is a string literal matching its name, which is enforced by the PEP: see https://peps.python.org/pep-0661/#typing currently the type checkers contain logic to enforce that the argument is a string literal, but some of this special-casing can be removed if we use `LiteralString` in the stubs
1 parent 41308b8 commit 8fa523e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

stdlib/builtins.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ if sys.version_info >= (3, 15):
21962196
class sentinel:
21972197
__name__: str
21982198
__module__: str
2199-
def __new__(cls, name: str, /, *, repr: str | None = None) -> sentinel: ...
2199+
def __new__(cls, name: LiteralString, /, *, repr: str | None = None) -> sentinel: ...
22002200
def __copy__(self, /) -> sentinel: ...
22012201
def __deepcopy__(self, memo: Any, /) -> sentinel: ...
22022202
# `other` can be any legal form for unions.

0 commit comments

Comments
 (0)