mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-02 17:43:25 +08:00
future first: switch the order of some if statements (#5206)
Since we're adding this to our contribution guidelines in https://github.com/python/typeshed/pull/5205
This commit is contained in:
@@ -6,12 +6,12 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
|
||||
_Handler = Callable[[Exception], Tuple[Text, int]]
|
||||
_String = Union[bytes, str]
|
||||
_Errors = Union[str, Text, None]
|
||||
if sys.version_info < (3, 0):
|
||||
_Decodable = Union[bytes, Text]
|
||||
_Encodable = Union[bytes, Text]
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
_Decodable = bytes
|
||||
_Encodable = str
|
||||
else:
|
||||
_Decodable = Union[bytes, Text]
|
||||
_Encodable = Union[bytes, Text]
|
||||
|
||||
# This type is not exposed; it is defined in unicodeobject.c
|
||||
class _EncodingMap(object):
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import sys
|
||||
from typing import IO, Optional, Union
|
||||
|
||||
if sys.version_info < (3,):
|
||||
_encodable = Union[bytes, unicode]
|
||||
_decodable = Union[bytes, unicode]
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
_encodable = bytes
|
||||
_decodable = Union[bytes, str]
|
||||
else:
|
||||
_encodable = Union[bytes, unicode]
|
||||
_decodable = Union[bytes, unicode]
|
||||
|
||||
def b64encode(s: _encodable, altchars: Optional[bytes] = ...) -> bytes: ...
|
||||
def b64decode(s: _decodable, altchars: Optional[bytes] = ..., validate: bool = ...) -> bytes: ...
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import sys
|
||||
from typing import Text, Union
|
||||
|
||||
if sys.version_info < (3,):
|
||||
# Python 2 accepts unicode ascii pretty much everywhere.
|
||||
_Bytes = Text
|
||||
_Ascii = Text
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
# But since Python 3.3 ASCII-only unicode strings are accepted by the
|
||||
# a2b_* functions.
|
||||
_Bytes = bytes
|
||||
_Ascii = Union[bytes, str]
|
||||
else:
|
||||
# Python 2 accepts unicode ascii pretty much everywhere.
|
||||
_Bytes = Text
|
||||
_Ascii = Text
|
||||
|
||||
def a2b_uu(__data: _Ascii) -> bytes: ...
|
||||
|
||||
|
||||
@@ -76,14 +76,14 @@ class HTMLCalendar(Calendar):
|
||||
cssclass_year: str
|
||||
cssclass_year_head: str
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
class TimeEncoding:
|
||||
if sys.version_info >= (3, 0):
|
||||
class different_locale:
|
||||
def __init__(self, locale: _LocaleType) -> None: ...
|
||||
def __enter__(self) -> _LocaleType: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
else:
|
||||
class different_locale:
|
||||
class TimeEncoding:
|
||||
def __init__(self, locale: _LocaleType) -> None: ...
|
||||
def __enter__(self) -> _LocaleType: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import sys
|
||||
from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
if sys.version_info < (3, 10):
|
||||
from _collections_abc import *
|
||||
else:
|
||||
if sys.version_info >= (3, 10):
|
||||
from typing import (
|
||||
Callable,
|
||||
ItemsView,
|
||||
@@ -17,6 +15,8 @@ else:
|
||||
Sequence,
|
||||
ValuesView,
|
||||
)
|
||||
else:
|
||||
from _collections_abc import *
|
||||
|
||||
_S = TypeVar("_S")
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@@ -3,10 +3,10 @@ from decimal import Decimal
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple, Union
|
||||
|
||||
# workaround for mypy#2010
|
||||
if sys.version_info < (3,):
|
||||
from __builtin__ import str as _str
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
from builtins import str as _str
|
||||
else:
|
||||
from __builtin__ import str as _str
|
||||
|
||||
CODESET: int
|
||||
D_T_FMT: int
|
||||
|
||||
@@ -228,16 +228,16 @@ class _ASN1Object(NamedTuple):
|
||||
longname: str
|
||||
oid: str
|
||||
|
||||
if sys.version_info < (3,):
|
||||
class Purpose(_ASN1Object):
|
||||
SERVER_AUTH: ClassVar[Purpose]
|
||||
CLIENT_AUTH: ClassVar[Purpose]
|
||||
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
class Purpose(_ASN1Object, enum.Enum):
|
||||
SERVER_AUTH: _ASN1Object
|
||||
CLIENT_AUTH: _ASN1Object
|
||||
|
||||
else:
|
||||
class Purpose(_ASN1Object):
|
||||
SERVER_AUTH: ClassVar[Purpose]
|
||||
CLIENT_AUTH: ClassVar[Purpose]
|
||||
|
||||
class SSLSocket(socket.socket):
|
||||
context: SSLContext
|
||||
server_side: bool
|
||||
|
||||
@@ -23,12 +23,12 @@ if sys.version_info >= (3, 9):
|
||||
# reveal_type(e.cmd) # Any, but morally is _CMD
|
||||
_FILE = Union[None, int, IO[Any]]
|
||||
_TXT = Union[bytes, str]
|
||||
if sys.version_info < (3, 8):
|
||||
if sys.version_info >= (3, 8):
|
||||
_CMD = Union[AnyPath, Sequence[AnyPath]]
|
||||
else:
|
||||
# Python 3.6 doesn't support _CMD being a single PathLike.
|
||||
# See: https://bugs.python.org/issue31961
|
||||
_CMD = Union[_TXT, Sequence[AnyPath]]
|
||||
else:
|
||||
_CMD = Union[AnyPath, Sequence[AnyPath]]
|
||||
if sys.platform == "win32":
|
||||
_ENV = Mapping[str, str]
|
||||
else:
|
||||
|
||||
@@ -20,9 +20,7 @@ AUDIO_FILE_ENCODING_ADPCM_G723_5: int
|
||||
AUDIO_FILE_ENCODING_ALAW_8: int
|
||||
AUDIO_UNKNOWN_SIZE: int
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
_sunau_params = Tuple[int, int, int, int, str, str]
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
class _sunau_params(NamedTuple):
|
||||
nchannels: int
|
||||
sampwidth: int
|
||||
@@ -31,6 +29,9 @@ else:
|
||||
comptype: str
|
||||
compname: str
|
||||
|
||||
else:
|
||||
_sunau_params = Tuple[int, int, int, int, str, str]
|
||||
|
||||
class Au_read:
|
||||
def __init__(self, f: _File) -> None: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
|
||||
@@ -7,9 +7,7 @@ class Error(Exception): ...
|
||||
|
||||
WAVE_FORMAT_PCM: int
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
_wave_params = Tuple[int, int, int, int, str, str]
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
class _wave_params(NamedTuple):
|
||||
nchannels: int
|
||||
sampwidth: int
|
||||
@@ -18,6 +16,9 @@ else:
|
||||
comptype: str
|
||||
compname: str
|
||||
|
||||
else:
|
||||
_wave_params = Tuple[int, int, int, int, str, str]
|
||||
|
||||
class Wave_read:
|
||||
def __init__(self, f: _File) -> None: ...
|
||||
if sys.version_info >= (3, 0):
|
||||
|
||||
@@ -59,18 +59,18 @@ class WeakValueDictionary(MutableMapping[_KT, _VT]):
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __str__(self) -> str: ...
|
||||
def copy(self) -> WeakValueDictionary[_KT, _VT]: ...
|
||||
if sys.version_info < (3, 0):
|
||||
if sys.version_info >= (3, 0):
|
||||
# These are incompatible with Mapping
|
||||
def keys(self) -> Iterator[_KT]: ... # type: ignore
|
||||
def values(self) -> Iterator[_VT]: ... # type: ignore
|
||||
def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore
|
||||
else:
|
||||
def keys(self) -> List[_KT]: ...
|
||||
def values(self) -> List[_VT]: ...
|
||||
def items(self) -> List[Tuple[_KT, _VT]]: ...
|
||||
def iterkeys(self) -> Iterator[_KT]: ...
|
||||
def itervalues(self) -> Iterator[_VT]: ...
|
||||
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
|
||||
else:
|
||||
# These are incompatible with Mapping
|
||||
def keys(self) -> Iterator[_KT]: ... # type: ignore
|
||||
def values(self) -> Iterator[_VT]: ... # type: ignore
|
||||
def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore
|
||||
def itervaluerefs(self) -> Iterator[KeyedRef[_KT, _VT]]: ...
|
||||
def valuerefs(self) -> List[KeyedRef[_KT, _VT]]: ...
|
||||
|
||||
@@ -95,7 +95,12 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]):
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __str__(self) -> str: ...
|
||||
def copy(self) -> WeakKeyDictionary[_KT, _VT]: ...
|
||||
if sys.version_info < (3, 0):
|
||||
if sys.version_info >= (3, 0):
|
||||
# These are incompatible with Mapping
|
||||
def keys(self) -> Iterator[_KT]: ... # type: ignore
|
||||
def values(self) -> Iterator[_VT]: ... # type: ignore
|
||||
def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore
|
||||
else:
|
||||
def keys(self) -> List[_KT]: ...
|
||||
def values(self) -> List[_VT]: ...
|
||||
def items(self) -> List[Tuple[_KT, _VT]]: ...
|
||||
@@ -103,11 +108,6 @@ class WeakKeyDictionary(MutableMapping[_KT, _VT]):
|
||||
def itervalues(self) -> Iterator[_VT]: ...
|
||||
def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ...
|
||||
def iterkeyrefs(self) -> Iterator[ref[_KT]]: ...
|
||||
else:
|
||||
# These are incompatible with Mapping
|
||||
def keys(self) -> Iterator[_KT]: ... # type: ignore
|
||||
def values(self) -> Iterator[_VT]: ... # type: ignore
|
||||
def items(self) -> Iterator[Tuple[_KT, _VT]]: ... # type: ignore
|
||||
def keyrefs(self) -> List[ref[_KT]]: ...
|
||||
|
||||
if sys.version_info >= (3, 4):
|
||||
|
||||
@@ -4,10 +4,10 @@ from typing import List, Optional, Type, TypeVar, overload
|
||||
from .handlers import SimpleHandler
|
||||
from .types import ErrorStream, StartResponse, WSGIApplication, WSGIEnvironment
|
||||
|
||||
if sys.version_info < (3,):
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
else:
|
||||
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
server_version: str # undocumented
|
||||
sys_version: str # undocumented
|
||||
|
||||
@@ -10,10 +10,10 @@ class FileWrapper:
|
||||
def __init__(self, filelike: IO[bytes], blksize: int = ...) -> None: ...
|
||||
def __getitem__(self, key: Any) -> bytes: ...
|
||||
def __iter__(self) -> FileWrapper: ...
|
||||
if sys.version_info < (3,):
|
||||
def next(self) -> bytes: ...
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
def __next__(self) -> bytes: ...
|
||||
else:
|
||||
def next(self) -> bytes: ...
|
||||
|
||||
def guess_scheme(environ: WSGIEnvironment) -> str: ...
|
||||
def application_uri(environ: WSGIEnvironment) -> str: ...
|
||||
|
||||
@@ -9,12 +9,12 @@ def validator(application: WSGIApplication) -> WSGIApplication: ...
|
||||
class InputWrapper:
|
||||
input: InputStream
|
||||
def __init__(self, wsgi_input: InputStream) -> None: ...
|
||||
if sys.version_info < (3,):
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self, size: int = ...) -> bytes: ...
|
||||
else:
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def readlines(self, hint: int = ...) -> bytes: ...
|
||||
def __iter__(self) -> Iterable[bytes]: ...
|
||||
def close(self) -> NoReturn: ...
|
||||
@@ -44,9 +44,9 @@ class IteratorWrapper:
|
||||
check_start_response: Optional[bool]
|
||||
def __init__(self, wsgi_iterator: Iterator[bytes], check_start_response: Optional[bool]) -> None: ...
|
||||
def __iter__(self) -> IteratorWrapper: ...
|
||||
if sys.version_info < (3,):
|
||||
def next(self) -> bytes: ...
|
||||
else:
|
||||
if sys.version_info >= (3, 0):
|
||||
def __next__(self) -> bytes: ...
|
||||
else:
|
||||
def next(self) -> bytes: ...
|
||||
def close(self) -> None: ...
|
||||
def __del__(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user