Replace Union with union operator (#7596)

This commit is contained in:
Alex Waygood
2022-04-05 22:07:31 +01:00
committed by GitHub
parent 8ae678129e
commit 1ceb486b75
5 changed files with 19 additions and 22 deletions

View File

@@ -178,9 +178,9 @@ _CanvasItemId = int
_Color = str # typically '#rrggbb', '#rgb' or color names.
_Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options'
_Cursor = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]] # manual page: Tk_GetCursor
_EntryValidateCommand = Union[
Callable[[], bool], str, list[str], tuple[str, ...]
] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
_EntryValidateCommand = (
str | list[str] | tuple[str, ...] | Callable[[], bool]
) # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
_GridIndex = int | str | Literal["all"]
_ImageSpec = _Image | str # str can be from e.g. tkinter.image_names()
_Padding = Union[

View File

@@ -1138,21 +1138,19 @@ class Pattern(Generic[AnyStr]):
# Functions
if sys.version_info >= (3, 7):
_get_type_hints_obj_allowed_types = Union[
object,
Callable[..., Any],
FunctionType,
BuiltinFunctionType,
MethodType,
ModuleType,
WrapperDescriptorType,
MethodWrapperType,
MethodDescriptorType,
]
_get_type_hints_obj_allowed_types = (
object
| Callable[..., Any]
| FunctionType
| BuiltinFunctionType
| MethodType
| ModuleType
| WrapperDescriptorType
| MethodWrapperType
| MethodDescriptorType
)
else:
_get_type_hints_obj_allowed_types = Union[
object, Callable[..., Any], FunctionType, BuiltinFunctionType, MethodType, ModuleType,
]
_get_type_hints_obj_allowed_types = object | Callable[..., Any] | FunctionType | BuiltinFunctionType | MethodType | ModuleType
if sys.version_info >= (3, 9):
def get_type_hints(