Skip to content
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

Avoid using _typeshed.StrEnum #13062

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
40 changes: 29 additions & 11 deletions stdlib/pstats.pyi
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
import sys
from _typeshed import StrEnum, StrOrBytesPath
from _typeshed import StrOrBytesPath
from collections.abc import Iterable
from cProfile import Profile as _cProfile
from profile import Profile
from typing import IO, Any, Literal, overload
from typing_extensions import Self, TypeAlias

if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from enum import Enum

if sys.version_info >= (3, 9):
__all__ = ["Stats", "SortKey", "FunctionProfile", "StatsProfile"]
else:
__all__ = ["Stats", "SortKey"]

_Selector: TypeAlias = str | float | int

class SortKey(StrEnum):
CALLS = "calls"
CUMULATIVE = "cumulative"
FILENAME = "filename"
LINE = "line"
NAME = "name"
NFL = "nfl"
PCALLS = "pcalls"
STDNAME = "stdname"
TIME = "time"
if sys.version_info >= (3, 11):
class SortKey(StrEnum):
CALLS = "calls"
CUMULATIVE = "cumulative"
FILENAME = "filename"
LINE = "line"
NAME = "name"
NFL = "nfl"
PCALLS = "pcalls"
STDNAME = "stdname"
TIME = "time"

else:
class SortKey(str, Enum):
CALLS = "calls"
CUMULATIVE = "cumulative"
FILENAME = "filename"
LINE = "line"
NAME = "name"
NFL = "nfl"
PCALLS = "pcalls"
STDNAME = "stdname"
TIME = "time"

if sys.version_info >= (3, 9):
from dataclasses import dataclass
Expand Down
130 changes: 89 additions & 41 deletions stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import _tkinter
import sys
from _typeshed import Incomplete, MaybeNone, StrEnum, StrOrBytesPath
from _typeshed import Incomplete, MaybeNone, StrOrBytesPath
from collections.abc import Callable, Iterable, Mapping, Sequence
from tkinter.constants import *
from tkinter.font import _FontDescription
from types import TracebackType
from typing import Any, Generic, Literal, NamedTuple, TypedDict, TypeVar, overload, type_check_only
from typing_extensions import TypeAlias, TypeVarTuple, Unpack, deprecated

if sys.version_info >= (3, 11):
from enum import StrEnum
else:
from enum import Enum

if sys.version_info >= (3, 9):
__all__ = [
"TclError",
Expand Down Expand Up @@ -196,46 +201,89 @@ if sys.version_info >= (3, 11):

class _VersionInfoType(_VersionInfoTypeBase): ...

class EventType(StrEnum):
Activate = "36"
ButtonPress = "4"
Button = ButtonPress
ButtonRelease = "5"
Circulate = "26"
CirculateRequest = "27"
ClientMessage = "33"
Colormap = "32"
Configure = "22"
ConfigureRequest = "23"
Create = "16"
Deactivate = "37"
Destroy = "17"
Enter = "7"
Expose = "12"
FocusIn = "9"
FocusOut = "10"
GraphicsExpose = "13"
Gravity = "24"
KeyPress = "2"
Key = "2"
KeyRelease = "3"
Keymap = "11"
Leave = "8"
Map = "19"
MapRequest = "20"
Mapping = "34"
Motion = "6"
MouseWheel = "38"
NoExpose = "14"
Property = "28"
Reparent = "21"
ResizeRequest = "25"
Selection = "31"
SelectionClear = "29"
SelectionRequest = "30"
Unmap = "18"
VirtualEvent = "35"
Visibility = "15"
if sys.version_info >= (3, 11):
class EventType(StrEnum):
Activate = "36"
ButtonPress = "4"
Button = ButtonPress
ButtonRelease = "5"
Circulate = "26"
CirculateRequest = "27"
ClientMessage = "33"
Colormap = "32"
Configure = "22"
ConfigureRequest = "23"
Create = "16"
Deactivate = "37"
Destroy = "17"
Enter = "7"
Expose = "12"
FocusIn = "9"
FocusOut = "10"
GraphicsExpose = "13"
Gravity = "24"
KeyPress = "2"
Key = "2"
KeyRelease = "3"
Keymap = "11"
Leave = "8"
Map = "19"
MapRequest = "20"
Mapping = "34"
Motion = "6"
MouseWheel = "38"
NoExpose = "14"
Property = "28"
Reparent = "21"
ResizeRequest = "25"
Selection = "31"
SelectionClear = "29"
SelectionRequest = "30"
Unmap = "18"
VirtualEvent = "35"
Visibility = "15"

else:
class EventType(str, Enum):
Activate = "36"
ButtonPress = "4"
Button = ButtonPress
ButtonRelease = "5"
Circulate = "26"
CirculateRequest = "27"
ClientMessage = "33"
Colormap = "32"
Configure = "22"
ConfigureRequest = "23"
Create = "16"
Deactivate = "37"
Destroy = "17"
Enter = "7"
Expose = "12"
FocusIn = "9"
FocusOut = "10"
GraphicsExpose = "13"
Gravity = "24"
KeyPress = "2"
Key = "2"
KeyRelease = "3"
Keymap = "11"
Leave = "8"
Map = "19"
MapRequest = "20"
Mapping = "34"
Motion = "6"
MouseWheel = "38"
NoExpose = "14"
Property = "28"
Reparent = "21"
ResizeRequest = "25"
Selection = "31"
SelectionClear = "29"
SelectionRequest = "30"
Unmap = "18"
VirtualEvent = "35"
Visibility = "15"

_W = TypeVar("_W", bound=Misc)
# Events considered covariant because you should never assign to event.widget.
Expand Down