Skip to content

Commit 1ceb486

Browse files
authored
Replace Union with union operator (#7596)
1 parent 8ae6781 commit 1ceb486

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed

stdlib/tkinter/__init__.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ _CanvasItemId = int
178178
_Color = str # typically '#rrggbb', '#rgb' or color names.
179179
_Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options'
180180
_Cursor = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]] # manual page: Tk_GetCursor
181-
_EntryValidateCommand = Union[
182-
Callable[[], bool], str, list[str], tuple[str, ...]
183-
] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
181+
_EntryValidateCommand = (
182+
str | list[str] | tuple[str, ...] | Callable[[], bool]
183+
) # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
184184
_GridIndex = int | str | Literal["all"]
185185
_ImageSpec = _Image | str # str can be from e.g. tkinter.image_names()
186186
_Padding = Union[

stdlib/typing.pyi

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,21 +1138,19 @@ class Pattern(Generic[AnyStr]):
11381138
# Functions
11391139

11401140
if sys.version_info >= (3, 7):
1141-
_get_type_hints_obj_allowed_types = Union[
1142-
object,
1143-
Callable[..., Any],
1144-
FunctionType,
1145-
BuiltinFunctionType,
1146-
MethodType,
1147-
ModuleType,
1148-
WrapperDescriptorType,
1149-
MethodWrapperType,
1150-
MethodDescriptorType,
1151-
]
1141+
_get_type_hints_obj_allowed_types = (
1142+
object
1143+
| Callable[..., Any]
1144+
| FunctionType
1145+
| BuiltinFunctionType
1146+
| MethodType
1147+
| ModuleType
1148+
| WrapperDescriptorType
1149+
| MethodWrapperType
1150+
| MethodDescriptorType
1151+
)
11521152
else:
1153-
_get_type_hints_obj_allowed_types = Union[
1154-
object, Callable[..., Any], FunctionType, BuiltinFunctionType, MethodType, ModuleType,
1155-
]
1153+
_get_type_hints_obj_allowed_types = object | Callable[..., Any] | FunctionType | BuiltinFunctionType | MethodType | ModuleType
11561154

11571155
if sys.version_info >= (3, 9):
11581156
def get_type_hints(

stubs/Pillow/PIL/ImageDraw.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from collections.abc import Container
2-
from typing import Any, Sequence, Union, overload
2+
from typing import Any, Sequence, overload
33
from typing_extensions import Literal
44

55
from .Image import Image
66
from .ImageColor import _Ink
77
from .ImageFont import _Font
88

9-
_XY = Sequence[Union[float, tuple[float, float]]]
9+
_XY = Sequence[float | tuple[float, float]]
1010
_Outline = Any
1111

1212
class ImageDraw:

stubs/beautifulsoup4/bs4/element.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
2727
def encode(self, encoding: str) -> str: ... # type: ignore[override] # incompatible with str
2828

2929
_PageElementT = TypeVar("_PageElementT", bound=PageElement)
30-
# The wrapping Union[] can be removed once mypy fully supports | in type aliases.
3130
_SimpleStrainable = str | bool | None | bytes | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]
3231
_Strainable = _SimpleStrainable | Iterable[_SimpleStrainable]
3332
_SimpleNormalizedStrainable = str | bool | None | Pattern[str] | Callable[[str], bool] | Callable[[Tag], bool]

stubs/colorama/colorama/ansitowin32.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
from _typeshed import SupportsWrite
33
from types import TracebackType
4-
from typing import Any, Callable, Pattern, Sequence, TextIO, Union
4+
from typing import Any, Callable, Pattern, Sequence, TextIO
55

66
if sys.platform == "win32":
77
from .winterm import WinTerm
@@ -23,7 +23,7 @@ class StreamWrapper:
2323
def closed(self) -> bool: ...
2424

2525
_WinTermCall = Callable[[int | None, bool, bool], None]
26-
_WinTermCallDict = dict[int, Union[tuple[_WinTermCall], tuple[_WinTermCall, int], tuple[_WinTermCall, int, bool]]]
26+
_WinTermCallDict = dict[int, tuple[_WinTermCall] | tuple[_WinTermCall, int] | tuple[_WinTermCall, int, bool]]
2727

2828
class AnsiToWin32:
2929
ANSI_CSI_RE: Pattern[str] = ...

0 commit comments

Comments
 (0)