Literal: always import from typing_extensions for simplicity (#4219)

This commit is contained in:
Jelle Zijlstra
2020-06-10 21:23:58 -07:00
committed by GitHub
parent 43e93f803f
commit 44a852dff5
22 changed files with 31 additions and 139 deletions

View File

@@ -3,11 +3,7 @@ from typing import Any, BinaryIO, Callable, Generator, IO, Iterable, Iterator, L
from abc import abstractmethod
import types
if sys.version_info < (3,) or sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
# TODO: this only satisfies the most common interface, where
# bytes (py2 str) is the raw form and str (py2 unicode) is the cooked form.

View File

@@ -1,15 +1,10 @@
import imaplib
import subprocess
import sys
import time
from socket import socket as _socket
from ssl import SSLSocket, SSLContext
from typing import Any, Callable, Dict, IO, List, Optional, Pattern, Text, Tuple, Type, Union
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
# TODO: Commands should use their actual return types, not this type alias.
# E.g. Tuple[Literal["OK"], List[bytes]]

View File

@@ -1,12 +1,7 @@
import sys
from typing import List, Tuple, Union, Set, Optional, Dict, Container, Any, Type, Iterable, Sequence
from types import ModuleType
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
if sys.platform == 'win32':
from _msi import _Database

View File

@@ -16,11 +16,7 @@ CPython C source: https://github.com/python/cpython/blob/master/Modules/socketmo
# adapted for Python 2.7 by Michal Pokorny
import sys
from typing import Any, BinaryIO, Iterable, List, Optional, Text, TextIO, Tuple, TypeVar, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
# ----- Constants -----

View File

@@ -1,10 +1,6 @@
import sys
from typing import Optional, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
if sys.platform == "win32":
SND_FILENAME: int

View File

@@ -1,5 +1,3 @@
# Stubs for xml.etree.ElementTree
from typing import (
Any,
Callable,
@@ -21,13 +19,8 @@ from typing import (
Union,
overload,
)
import io
import sys
if sys.version_info < (3,) or sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
from typing_extensions import Literal
VERSION: str