Skip to content

keyword: Improve types of kwlist and softkwlist #9680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions stdlib/keyword.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
from collections.abc import Sequence
from typing_extensions import Final

if sys.version_info >= (3, 9):
__all__ = ["iskeyword", "issoftkeyword", "kwlist", "softkwlist"]
Expand All @@ -8,8 +9,13 @@ else:

def iskeyword(s: str) -> bool: ...

kwlist: Sequence[str]
# a list at runtime, but you're not meant to mutate it;
# type it as a sequence
kwlist: Final[Sequence[str]]

if sys.version_info >= (3, 9):
def issoftkeyword(s: str) -> bool: ...
softkwlist: Sequence[str]

# a list at runtime, but you're not meant to mutate it;
# type it as a sequence
softkwlist: Final[Sequence[str]]