Annotate Python 3.8 removals (#3359)

* macpath
* time.clock()
* Some cgi functions
* XMLParser(html) and doctype()
* unicode_internal
* Two sqlite3 classes hidden
* fileinput bufsize arg
* Treeview.selection no longer takes arguments
This commit is contained in:
Sebastian Rittau
2019-10-14 09:51:39 +02:00
committed by GitHub
parent 950f391704
commit 6507875f28
10 changed files with 216 additions and 193 deletions

View File

@@ -43,8 +43,9 @@ def raw_unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[
def readbuffer_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def unicode_escape_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_escape_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info < (3, 8):
def unicode_internal_decode(data: _String, errors: _Errors = ...) -> Tuple[Text, int]: ...
def unicode_internal_encode(data: _String, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_16_be_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ...
def utf_16_be_encode(data: _Encodable, errors: _Errors = ...) -> Tuple[bytes, int]: ...
def utf_16_decode(data: _Decodable, errors: _Errors = ..., final: int = ...) -> Tuple[Text, int]: ...

View File

@@ -5,8 +5,9 @@ _T = TypeVar('_T', bound=FieldStorage)
def parse(fp: IO[Any] = ..., environ: Mapping[str, str] = ...,
keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
if sys.version_info < (3, 8):
def parse_qs(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
def parse_qsl(qs: str, keep_blank_values: bool = ..., strict_parsing: bool = ...) -> Dict[str, List[str]]: ...
if sys.version_info >= (3, 7):
def parse_multipart(fp: IO[Any], pdict: Mapping[str, bytes], encoding: str = ..., errors: str = ...) -> Dict[str, List[Any]]: ...
else:
@@ -17,11 +18,10 @@ def print_environ(environ: Mapping[str, str] = ...) -> None: ...
def print_form(form: Dict[str, Any]) -> None: ...
def print_directory() -> None: ...
def print_environ_usage() -> None: ...
if sys.version_info >= (3, 0):
def escape(s: str, quote: bool = ...) -> str: ...
else:
if sys.version_info < (3,):
def escape(s: AnyStr, quote: bool = ...) -> AnyStr: ...
elif sys.version_info < (3, 8):
def escape(s: str, quote: bool = ...) -> str: ...
class MiniFieldStorage:
# The first five "Any" attributes here are always None, but mypy doesn't support that

View File

@@ -8,15 +8,24 @@ if sys.version_info >= (3, 6):
else:
_Path = Union[Text, bytes]
def input(
files: Union[_Path, Iterable[_Path], None] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...) -> FileInput[AnyStr]: ...
if sys.version_info >= (3, 8):
def input(
files: Union[_Path, Iterable[_Path], None] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...,
) -> FileInput[AnyStr]: ...
else:
def input(
files: Union[_Path, Iterable[_Path], None] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...,
) -> FileInput[AnyStr]: ...
def close() -> None: ...
def nextfile() -> None: ...
@@ -28,15 +37,26 @@ def isfirstline() -> bool: ...
def isstdin() -> bool: ...
class FileInput(Iterable[AnyStr], Generic[AnyStr]):
def __init__(
self,
files: Union[None, _Path, Iterable[_Path]] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...
) -> None: ...
if sys.version_info >= (3, 8):
def __init__(
self,
files: Union[None, _Path, Iterable[_Path]] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...
) -> None: ...
else:
def __init__(
self,
files: Union[None, _Path, Iterable[_Path]] = ...,
inplace: bool = ...,
backup: str = ...,
bufsize: int = ...,
mode: str = ...,
openhook: Callable[[_Path, str], IO[AnyStr]] = ...
) -> None: ...
def __del__(self) -> None: ...
def close(self) -> None: ...

View File

@@ -1,4 +1,3 @@
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
# Stubs for os.path
# Ron Murawski <ron@horizonchess.com>
@@ -6,172 +5,167 @@ import os
import sys
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Union, Text, Callable, Optional
_T = TypeVar('_T')
if sys.version_info < (3, 8):
_T = TypeVar('_T')
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
_StrPath = Union[Text, _PathLike[Text]]
_BytesPath = Union[bytes, _PathLike[bytes]]
else:
_PathType = Union[bytes, Text]
_StrPath = Text
_BytesPath = bytes
if sys.version_info >= (3, 6):
from builtins import _PathLike
_PathType = Union[bytes, Text, _PathLike]
_StrPath = Union[Text, _PathLike[Text]]
_BytesPath = Union[bytes, _PathLike[bytes]]
else:
_PathType = Union[bytes, Text]
_StrPath = Text
_BytesPath = bytes
# ----- os.path variables -----
supports_unicode_filenames: bool
# aliases (also in os)
curdir: str
pardir: str
sep: str
if sys.platform == 'win32':
altsep: str
else:
# ----- os.path variables -----
supports_unicode_filenames: bool
# aliases (also in os)
curdir: str
pardir: str
sep: str
altsep: Optional[str]
extsep: str
pathsep: str
defpath: str
devnull: str
extsep: str
pathsep: str
defpath: str
devnull: str
# ----- os.path function stubs -----
if sys.version_info >= (3, 6):
# Overloads are necessary to work around python/mypy#3644.
@overload
def abspath(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def abspath(path: AnyStr) -> AnyStr: ...
@overload
def basename(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def basename(path: AnyStr) -> AnyStr: ...
@overload
def dirname(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def dirname(path: AnyStr) -> AnyStr: ...
@overload
def expanduser(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def expanduser(path: AnyStr) -> AnyStr: ...
@overload
def expandvars(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def expandvars(path: AnyStr) -> AnyStr: ...
@overload
def normcase(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def normcase(path: AnyStr) -> AnyStr: ...
@overload
def normpath(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def normpath(path: AnyStr) -> AnyStr: ...
if sys.platform == 'win32':
# ----- os.path function stubs -----
if sys.version_info >= (3, 6):
# Overloads are necessary to work around python/mypy#3644.
@overload
def realpath(path: _PathLike[AnyStr]) -> AnyStr: ...
def abspath(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def realpath(path: AnyStr) -> AnyStr: ...
def abspath(path: AnyStr) -> AnyStr: ...
@overload
def basename(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def basename(path: AnyStr) -> AnyStr: ...
@overload
def dirname(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def dirname(path: AnyStr) -> AnyStr: ...
@overload
def expanduser(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def expanduser(path: AnyStr) -> AnyStr: ...
@overload
def expandvars(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def expandvars(path: AnyStr) -> AnyStr: ...
@overload
def normcase(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def normcase(path: AnyStr) -> AnyStr: ...
@overload
def normpath(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def normpath(path: AnyStr) -> AnyStr: ...
if sys.platform == 'win32':
@overload
def realpath(path: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def realpath(path: AnyStr) -> AnyStr: ...
else:
@overload
def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def realpath(filename: AnyStr) -> AnyStr: ...
else:
@overload
def realpath(filename: _PathLike[AnyStr]) -> AnyStr: ...
@overload
def realpath(filename: AnyStr) -> AnyStr: ...
def abspath(path: AnyStr) -> AnyStr: ...
def basename(path: AnyStr) -> AnyStr: ...
def dirname(path: AnyStr) -> AnyStr: ...
def expanduser(path: AnyStr) -> AnyStr: ...
def expandvars(path: AnyStr) -> AnyStr: ...
def normcase(path: AnyStr) -> AnyStr: ...
def normpath(path: AnyStr) -> AnyStr: ...
if sys.platform == 'win32':
def realpath(path: AnyStr) -> AnyStr: ...
else:
def realpath(filename: AnyStr) -> AnyStr: ...
else:
def abspath(path: AnyStr) -> AnyStr: ...
def basename(path: AnyStr) -> AnyStr: ...
def dirname(path: AnyStr) -> AnyStr: ...
def expanduser(path: AnyStr) -> AnyStr: ...
def expandvars(path: AnyStr) -> AnyStr: ...
def normcase(path: AnyStr) -> AnyStr: ...
def normpath(path: AnyStr) -> AnyStr: ...
if sys.platform == 'win32':
def realpath(path: AnyStr) -> AnyStr: ...
if sys.version_info >= (3, 6):
# In reality it returns str for sequences of _StrPath and bytes for sequences
# of _BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[_PathType]) -> Any: ...
elif sys.version_info >= (3, 5):
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
# NOTE: Empty lists results in '' (str) regardless of contained type.
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
# So, fall back to Any
def commonprefix(list: Sequence[_PathType]) -> Any: ...
if sys.version_info >= (3, 3):
def exists(path: Union[_PathType, int]) -> bool: ...
else:
def realpath(filename: AnyStr) -> AnyStr: ...
def exists(path: _PathType) -> bool: ...
def lexists(path: _PathType) -> bool: ...
if sys.version_info >= (3, 6):
# In reality it returns str for sequences of _StrPath and bytes for sequences
# of _BytesPath, but mypy does not accept such a signature.
def commonpath(paths: Sequence[_PathType]) -> Any: ...
elif sys.version_info >= (3, 5):
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(path: _PathType) -> float: ...
def getmtime(path: _PathType) -> float: ...
def getctime(path: _PathType) -> float: ...
# NOTE: Empty lists results in '' (str) regardless of contained type.
# Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes
# So, fall back to Any
def commonprefix(list: Sequence[_PathType]) -> Any: ...
def getsize(path: _PathType) -> int: ...
def isabs(path: _PathType) -> bool: ...
def isfile(path: _PathType) -> bool: ...
def isdir(path: _PathType) -> bool: ...
def islink(path: _PathType) -> bool: ...
def ismount(path: _PathType) -> bool: ...
if sys.version_info >= (3, 3):
def exists(path: Union[_PathType, int]) -> bool: ...
else:
def exists(path: _PathType) -> bool: ...
def lexists(path: _PathType) -> bool: ...
if sys.version_info < (3, 0):
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
# (Since Python 2 allows that, too)
# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in
# a type error.
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: Text, *p: _PathType) -> Text: ...
elif sys.version_info >= (3, 6):
# Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway.
@overload
def join(path: _StrPath, *paths: _StrPath) -> Text: ...
@overload
def join(path: _BytesPath, *paths: _BytesPath) -> bytes: ...
else:
def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ...
# These return float if os.stat_float_times() == True,
# but int is a subclass of float.
def getatime(path: _PathType) -> float: ...
def getmtime(path: _PathType) -> float: ...
def getctime(path: _PathType) -> float: ...
@overload
def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ...
@overload
def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ...
def getsize(path: _PathType) -> int: ...
def isabs(path: _PathType) -> bool: ...
def isfile(path: _PathType) -> bool: ...
def isdir(path: _PathType) -> bool: ...
def islink(path: _PathType) -> bool: ...
def ismount(path: _PathType) -> bool: ...
def samefile(path1: _PathType, path2: _PathType) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
def samestat(stat1: os.stat_result, stat2: os.stat_result) -> bool: ...
if sys.version_info < (3, 0):
# Make sure signatures are disjunct, and allow combinations of bytes and unicode.
# (Since Python 2 allows that, too)
# Note that e.g. os.path.join("a", "b", "c", "d", u"e") will still result in
# a type error.
@overload
def join(__p1: bytes, *p: bytes) -> bytes: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: bytes, __p2: bytes, __p3: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: bytes, __p2: Text, *p: _PathType) -> Text: ...
@overload
def join(__p1: Text, *p: _PathType) -> Text: ...
elif sys.version_info >= (3, 6):
# Mypy complains that the signatures overlap (same for relpath below), but things seem to behave correctly anyway.
@overload
def join(path: _StrPath, *paths: _StrPath) -> Text: ...
@overload
def join(path: _BytesPath, *paths: _BytesPath) -> bytes: ...
else:
def join(path: AnyStr, *paths: AnyStr) -> AnyStr: ...
if sys.version_info >= (3, 6):
@overload
def split(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitdrive(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitext(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
else:
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
@overload
def relpath(path: _BytesPath, start: Optional[_BytesPath] = ...) -> bytes: ...
@overload
def relpath(path: _StrPath, start: Optional[_StrPath] = ...) -> Text: ...
def samefile(path1: _PathType, path2: _PathType) -> bool: ...
def sameopenfile(fp1: int, fp2: int) -> bool: ...
def samestat(stat1: os.stat_result, stat2: os.stat_result) -> bool: ...
if sys.version_info >= (3, 6):
@overload
def split(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitdrive(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitext(path: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
@overload
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
else:
def split(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
if sys.platform == 'win32':
def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated
if sys.version_info < (3,):
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...
if sys.version_info < (3,):
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...

View File

@@ -102,10 +102,11 @@ def enable_shared_cache(do_enable: int) -> None: ...
def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ...
class Cache(object):
def __init__(self, *args, **kwargs) -> None: ...
def display(self, *args, **kwargs) -> None: ...
def get(self, *args, **kwargs) -> None: ...
if sys.version_info < (3, 8):
class Cache(object):
def __init__(self, *args, **kwargs) -> None: ...
def display(self, *args, **kwargs) -> None: ...
def get(self, *args, **kwargs) -> None: ...
class Connection(object):
DataError: Any
@@ -283,7 +284,8 @@ class Row(object):
def __lt__(self, other): ...
def __ne__(self, other): ...
class Statement(object):
def __init__(self, *args, **kwargs): ...
if sys.version_info < (3, 8):
class Statement(object):
def __init__(self, *args, **kwargs): ...
class Warning(Exception): ...

View File

@@ -70,7 +70,8 @@ else:
def __new__(cls, o: _TimeTuple, _arg: Any = ...) -> struct_time: ...
def asctime(t: Union[_TimeTuple, struct_time] = ...) -> str: ...
def clock() -> float: ...
if sys.version_info < (3, 8):
def clock() -> float: ...
def ctime(secs: Optional[float] = ...) -> str: ...
def gmtime(secs: Optional[float] = ...) -> struct_time: ...
def localtime(secs: Optional[float] = ...) -> struct_time: ...

View File

@@ -182,7 +182,10 @@ class XMLParser:
# TODO-what is entity used for???
entity: Any
version: str
def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ...
def doctype(self, name: str, pubid: str, system: str) -> None: ...
if sys.version_info >= (3, 8):
def __init__(self, *, target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ...
else:
def __init__(self, html: int = ..., target: Optional[TreeBuilder] = ..., encoding: Optional[str] = ...) -> None: ...
def doctype(self, name: str, pubid: str, system: str) -> None: ...
def close(self) -> Element: ...
def feed(self, data: _parser_input_type) -> None: ...

View File

@@ -1,7 +1,6 @@
# Stubs for platform (Python 3.5)
from os import devnull as DEV_NULL
from os import popen
from typing import Tuple, NamedTuple
def libc_ver(executable: str = ..., lib: str = ..., version: str = ..., chunksize: int = ...) -> Tuple[str, str]: ...

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Optional
from typing import Any, List, Optional
import tkinter
def tclobjs_to_py(adict): ...
@@ -136,7 +136,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
def parent(self, item): ...
def prev(self, item): ...
def see(self, item): ...
def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...): ...
if sys.version_info >= (3, 8):
def selection(self) -> List[Any]: ...
else:
def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...) -> List[Any]: ...
def selection_set(self, items): ...
def selection_add(self, items): ...
def selection_remove(self, items): ...

View File

@@ -14,7 +14,7 @@ consistent_files = [
{'stdlib/2and3/builtins.pyi', 'stdlib/2/__builtin__.pyi'},
{'stdlib/2/SocketServer.pyi', 'stdlib/3/socketserver.pyi'},
{'stdlib/2/os2emxpath.pyi', 'stdlib/2and3/posixpath.pyi',
'stdlib/2and3/ntpath.pyi', 'stdlib/2and3/macpath.pyi',
'stdlib/2and3/ntpath.pyi',
'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'},
{'stdlib/3/enum.pyi', 'third_party/2/enum.pyi'},
{'stdlib/3/unittest/mock.pyi', 'third_party/2and3/mock.pyi'},