From 87d7dd3d957a7571f8628ec381c44a4e77c770f5 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Mon, 28 Oct 2019 14:59:28 +0100 Subject: [PATCH] Fix annotations with literal values (#3411) --- stdlib/2/hashlib.pyi | 6 +- stdlib/2/md5.pyi | 4 +- stdlib/2/re.pyi | 30 +++++----- stdlib/2/sha.pyi | 4 +- stdlib/2/stat.pyi | 96 +++++++++++++++--------------- stdlib/2/subprocess.pyi | 6 +- stdlib/2/sys.pyi | 8 +-- stdlib/2/urlparse.pyi | 2 +- stdlib/3/_subprocess.pyi | 22 +++---- stdlib/3/asyncio/windows_utils.pyi | 6 +- stdlib/3/multiprocessing/spawn.pyi | 2 +- stdlib/3/shlex.pyi | 4 +- stdlib/3/subprocess.pyi | 6 +- stdlib/3/typing.pyi | 10 ++-- stdlib/3/urllib/parse.pyi | 2 +- 15 files changed, 104 insertions(+), 104 deletions(-) diff --git a/stdlib/2/hashlib.pyi b/stdlib/2/hashlib.pyi index 22288203a..70423742e 100644 --- a/stdlib/2/hashlib.pyi +++ b/stdlib/2/hashlib.pyi @@ -6,9 +6,9 @@ _DataType = Union[str, unicode, bytearray, buffer, memoryview] class _hash(object): # This is not actually in the module namespace. name: str - block_size = 0 - digest_size = 0 - digestsize = 0 + block_size: int + digest_size: int + digestsize: int def __init__(self, arg: _DataType = ...) -> None: ... def update(self, arg: _DataType) -> None: ... def digest(self) -> str: ... diff --git a/stdlib/2/md5.pyi b/stdlib/2/md5.pyi index fe6ad719d..96eabd146 100644 --- a/stdlib/2/md5.pyi +++ b/stdlib/2/md5.pyi @@ -2,5 +2,5 @@ from hashlib import md5 as md5, md5 as new -blocksize = 0 -digest_size = 0 +blocksize: int +digest_size: int diff --git a/stdlib/2/re.pyi b/stdlib/2/re.pyi index 2a2c2cb03..71486692f 100644 --- a/stdlib/2/re.pyi +++ b/stdlib/2/re.pyi @@ -10,21 +10,21 @@ from typing import ( ) # ----- re variables and constants ----- -DEBUG = 0 -I = 0 -IGNORECASE = 0 -L = 0 -LOCALE = 0 -M = 0 -MULTILINE = 0 -S = 0 -DOTALL = 0 -X = 0 -VERBOSE = 0 -U = 0 -UNICODE = 0 -T = 0 -TEMPLATE = 0 +DEBUG: int +I: int +IGNORECASE: int +L: int +LOCALE: int +M: int +MULTILINE: int +S: int +DOTALL: int +X: int +VERBOSE: int +U: int +UNICODE: int +T: int +TEMPLATE: int class error(Exception): ... diff --git a/stdlib/2/sha.pyi b/stdlib/2/sha.pyi index f1606fa8d..00ad4d9f4 100644 --- a/stdlib/2/sha.pyi +++ b/stdlib/2/sha.pyi @@ -7,5 +7,5 @@ class sha(object): def copy(self) -> sha: ... def new(string: str = ...) -> sha: ... -blocksize = 0 -digest_size = 0 +blocksize: int +digest_size: int diff --git a/stdlib/2/stat.pyi b/stdlib/2/stat.pyi index dd3418db9..5230d670f 100644 --- a/stdlib/2/stat.pyi +++ b/stdlib/2/stat.pyi @@ -9,51 +9,51 @@ def S_ISSOCK(mode: int) -> bool: ... def S_IMODE(mode: int) -> int: ... def S_IFMT(mode: int) -> int: ... -ST_MODE = 0 -ST_INO = 0 -ST_DEV = 0 -ST_NLINK = 0 -ST_UID = 0 -ST_GID = 0 -ST_SIZE = 0 -ST_ATIME = 0 -ST_MTIME = 0 -ST_CTIME = 0 -S_IFSOCK = 0 -S_IFLNK = 0 -S_IFREG = 0 -S_IFBLK = 0 -S_IFDIR = 0 -S_IFCHR = 0 -S_IFIFO = 0 -S_ISUID = 0 -S_ISGID = 0 -S_ISVTX = 0 -S_IRWXU = 0 -S_IRUSR = 0 -S_IWUSR = 0 -S_IXUSR = 0 -S_IRWXG = 0 -S_IRGRP = 0 -S_IWGRP = 0 -S_IXGRP = 0 -S_IRWXO = 0 -S_IROTH = 0 -S_IWOTH = 0 -S_IXOTH = 0 -S_ENFMT = 0 -S_IREAD = 0 -S_IWRITE = 0 -S_IEXEC = 0 -UF_NODUMP = 0 -UF_IMMUTABLE = 0 -UF_APPEND = 0 -UF_OPAQUE = 0 -UF_NOUNLINK = 0 -UF_COMPRESSED = 0 -UF_HIDDEN = 0 -SF_ARCHIVED = 0 -SF_IMMUTABLE = 0 -SF_APPEND = 0 -SF_NOUNLINK = 0 -SF_SNAPSHOT = 0 +ST_MODE: int +ST_INO: int +ST_DEV: int +ST_NLINK: int +ST_UID: int +ST_GID: int +ST_SIZE: int +ST_ATIME: int +ST_MTIME: int +ST_CTIME: int +S_IFSOCK: int +S_IFLNK: int +S_IFREG: int +S_IFBLK: int +S_IFDIR: int +S_IFCHR: int +S_IFIFO: int +S_ISUID: int +S_ISGID: int +S_ISVTX: int +S_IRWXU: int +S_IRUSR: int +S_IWUSR: int +S_IXUSR: int +S_IRWXG: int +S_IRGRP: int +S_IWGRP: int +S_IXGRP: int +S_IRWXO: int +S_IROTH: int +S_IWOTH: int +S_IXOTH: int +S_ENFMT: int +S_IREAD: int +S_IWRITE: int +S_IEXEC: int +UF_NODUMP: int +UF_IMMUTABLE: int +UF_APPEND: int +UF_OPAQUE: int +UF_NOUNLINK: int +UF_COMPRESSED: int +UF_HIDDEN: int +SF_ARCHIVED: int +SF_IMMUTABLE: int +SF_APPEND: int +SF_NOUNLINK: int +SF_SNAPSHOT: int diff --git a/stdlib/2/subprocess.pyi b/stdlib/2/subprocess.pyi index 54dd0dbd3..b603e42c0 100644 --- a/stdlib/2/subprocess.pyi +++ b/stdlib/2/subprocess.pyi @@ -61,7 +61,7 @@ PIPE: int STDOUT: int class CalledProcessError(Exception): - returncode = 0 + returncode: int # morally: _CMD cmd: Any # morally: Optional[bytes] @@ -79,8 +79,8 @@ class Popen(Generic[_T]): stdin: Optional[IO[bytes]] stdout: Optional[IO[bytes]] stderr: Optional[IO[bytes]] - pid = 0 - returncode = 0 + pid: int + returncode: int def __new__(cls, args: _CMD, diff --git a/stdlib/2/sys.pyi b/stdlib/2/sys.pyi index 1f5a68fca..be688f5b4 100644 --- a/stdlib/2/sys.pyi +++ b/stdlib/2/sys.pyi @@ -42,11 +42,11 @@ class _float_info: rounds: int class _version_info(Tuple[int, int, int, str, int]): - major = 0 - minor = 0 - micro = 0 + major: int + minor: int + micro: int releaselevel: str - serial = 0 + serial: int _mercurial: Tuple[str, str, str] api_version: int diff --git a/stdlib/2/urlparse.pyi b/stdlib/2/urlparse.pyi index 4f54dde15..2ab28a7ec 100644 --- a/stdlib/2/urlparse.pyi +++ b/stdlib/2/urlparse.pyi @@ -11,7 +11,7 @@ non_hierarchical: List[str] uses_query: List[str] uses_fragment: List[str] scheme_chars: str -MAX_CACHE_SIZE = 0 +MAX_CACHE_SIZE: int def clear_cache() -> None: ... diff --git a/stdlib/3/_subprocess.pyi b/stdlib/3/_subprocess.pyi index 76967b94b..555a8d792 100644 --- a/stdlib/3/_subprocess.pyi +++ b/stdlib/3/_subprocess.pyi @@ -4,17 +4,17 @@ from typing import Mapping, Any, Tuple -CREATE_NEW_CONSOLE = 0 -CREATE_NEW_PROCESS_GROUP = 0 -STD_INPUT_HANDLE = 0 -STD_OUTPUT_HANDLE = 0 -STD_ERROR_HANDLE = 0 -SW_HIDE = 0 -STARTF_USESTDHANDLES = 0 -STARTF_USESHOWWINDOW = 0 -INFINITE = 0 -DUPLICATE_SAME_ACCESS = 0 -WAIT_OBJECT_0 = 0 +CREATE_NEW_CONSOLE: int +CREATE_NEW_PROCESS_GROUP: int +STD_INPUT_HANDLE: int +STD_OUTPUT_HANDLE: int +STD_ERROR_HANDLE: int +SW_HIDE: int +STARTF_USESTDHANDLES: int +STARTF_USESHOWWINDOW: int +INFINITE: int +DUPLICATE_SAME_ACCESS: int +WAIT_OBJECT_0: int # TODO not exported by the Python module class Handle: diff --git a/stdlib/3/asyncio/windows_utils.pyi b/stdlib/3/asyncio/windows_utils.pyi index 5ba6bfbb2..f29703f09 100644 --- a/stdlib/3/asyncio/windows_utils.pyi +++ b/stdlib/3/asyncio/windows_utils.pyi @@ -2,9 +2,9 @@ from typing import Tuple, Callable, Optional from types import TracebackType -BUFSIZE: int = ... -PIPE: int = ... -STDOUT: int = ... +BUFSIZE: int +PIPE: int +STDOUT: int def pipe(*, duplex: bool = ..., overlapped: Tuple[bool, bool] = ..., bufsize: int = ...) -> Tuple[int, int]: ... diff --git a/stdlib/3/multiprocessing/spawn.pyi b/stdlib/3/multiprocessing/spawn.pyi index 659253c48..9d170f6f2 100644 --- a/stdlib/3/multiprocessing/spawn.pyi +++ b/stdlib/3/multiprocessing/spawn.pyi @@ -13,6 +13,6 @@ def spawn_main(pipe_handle: int, parent_pid: Optional[int] = ..., tracker_fd: Op # undocumented def _main(fd: int) -> Any: ... def get_preparation_data(name: str) -> Dict[str, Any]: ... -old_main_modules: List[ModuleType] = ... +old_main_modules: List[ModuleType] def prepare(data: Mapping[str, Any]) -> None: ... def import_main_path(main_path: str) -> None: ... diff --git a/stdlib/3/shlex.pyi b/stdlib/3/shlex.pyi index 2afc6d714..51ed42d94 100644 --- a/stdlib/3/shlex.pyi +++ b/stdlib/3/shlex.pyi @@ -19,8 +19,8 @@ class shlex(Iterable[str]): infile: str instream: TextIO source: str - debug = 0 - lineno = 0 + debug: int + lineno: int token: str eof: str if sys.version_info >= (3, 6): diff --git a/stdlib/3/subprocess.pyi b/stdlib/3/subprocess.pyi index e3a97bd91..2fd8b5ba7 100644 --- a/stdlib/3/subprocess.pyi +++ b/stdlib/3/subprocess.pyi @@ -814,7 +814,7 @@ class TimeoutExpired(SubprocessError): class CalledProcessError(Exception): - returncode = 0 + returncode: int # morally: _CMD cmd: Any # morally: Optional[_TXT] @@ -835,8 +835,8 @@ class Popen(Generic[AnyStr]): stdin: IO[AnyStr] stdout: IO[AnyStr] stderr: IO[AnyStr] - pid = 0 - returncode = 0 + pid: int + returncode: int # Technically it is wrong that Popen provides __new__ instead of __init__ # but this shouldn't come up hopefully? diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index bc39caeaf..6e11f3621 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -29,7 +29,7 @@ if sys.version_info >= (3, 8): def final(f: _F) -> _F: ... Literal: _SpecialForm = ... # TypedDict is a (non-subscriptable) special form. - TypedDict: object = ... + TypedDict: object class GenericMeta(type): ... @@ -525,8 +525,8 @@ class TextIO(IO[str]): class ByteString(Sequence[int], metaclass=ABCMeta): ... class Match(Generic[AnyStr]): - pos = 0 - endpos = 0 + pos: int + endpos: int lastindex: Optional[int] lastgroup: Optional[AnyStr] string: AnyStr @@ -559,9 +559,9 @@ class Match(Generic[AnyStr]): def __getitem__(self, g: Union[int, str]) -> AnyStr: ... class Pattern(Generic[AnyStr]): - flags = 0 + flags: int groupindex: Mapping[str, int] - groups = 0 + groups: int pattern: AnyStr def search(self, string: AnyStr, pos: int = ..., diff --git a/stdlib/3/urllib/parse.pyi b/stdlib/3/urllib/parse.pyi index fb303e5de..0564a8257 100644 --- a/stdlib/3/urllib/parse.pyi +++ b/stdlib/3/urllib/parse.pyi @@ -11,7 +11,7 @@ non_hierarchical: List[str] uses_query: List[str] uses_fragment: List[str] scheme_chars: str -MAX_CACHE_SIZE = 0 +MAX_CACHE_SIZE: int class _ResultMixinBase(Generic[AnyStr]): def geturl(self) -> AnyStr: ...