PEP 604: Remove some more uses of Union/Optional (#7515)

The following patterns still break mypy:

1. `type[]` at top level fails
2. `tuple[T1, T2]` at top level fails (but `tuple[T1, ...]` is fine)
3. `T1 | Callable[..., T2 | T3]` fails, but only <=3.9

This PR cleans up usage of `Union` and `Optional` outside these patterns.
This commit is contained in:
Jelle Zijlstra
2022-03-19 08:23:00 -07:00
committed by GitHub
parent 1acc8f3bd6
commit b7d129f727
7 changed files with 24 additions and 23 deletions

View File

@@ -2,10 +2,10 @@ import socket
import sys
from builtins import type as Type # alias to avoid name clashes with property named "type"
from types import TracebackType
from typing import Any, BinaryIO, Iterable, NoReturn, Union, overload
from typing import Any, BinaryIO, Iterable, NoReturn, overload
# These are based in socket, maybe move them out into _typeshed.pyi or such
_Address = Union[tuple[Any, ...], str]
_Address = tuple[Any, ...] | str
_RetAddress = Any
_WriteBuffer = bytearray | memoryview
_CMSG = tuple[int, int, bytes]