mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Remove symlinks! (#2132)
This commit is contained in:
committed by
Jelle Zijlstra
parent
537b97ed39
commit
e9600db2ec
@@ -9,6 +9,8 @@ matrix:
|
||||
env: TEST_CMD="./tests/mypy_selftest.py"
|
||||
- python: "3.5"
|
||||
env: TEST_CMD="./tests/mypy_test.py --no-implicit-optional"
|
||||
- python: "3.4"
|
||||
env: TEST_CMD="./tests/check_consistent.py"
|
||||
- python: "2.7"
|
||||
env: TEST_CMD="./tests/pytype_test.py --num-parallel=4"
|
||||
sudo: true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../3/socketserver.pyi
|
||||
99
stdlib/2/SocketServer.pyi
Normal file
99
stdlib/2/SocketServer.pyi
Normal file
@@ -0,0 +1,99 @@
|
||||
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
|
||||
# Stubs for socketserver
|
||||
|
||||
from typing import Any, BinaryIO, Optional, Tuple, Type
|
||||
from socket import SocketType
|
||||
import sys
|
||||
import types
|
||||
|
||||
class BaseServer:
|
||||
address_family = ... # type: int
|
||||
RequestHandlerClass = ... # type: type
|
||||
server_address = ... # type: Tuple[str, int]
|
||||
socket = ... # type: SocketType
|
||||
allow_reuse_address = ... # type: bool
|
||||
request_queue_size = ... # type: int
|
||||
socket_type = ... # type: int
|
||||
timeout = ... # type: Optional[float]
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: type) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def handle_request(self) -> None: ...
|
||||
def serve_forever(self, poll_interval: float = ...) -> None: ...
|
||||
def shutdown(self) -> None: ...
|
||||
def server_close(self) -> None: ...
|
||||
def finish_request(self, request: bytes,
|
||||
client_address: Tuple[str, int]) -> None: ...
|
||||
def get_request(self) -> None: ...
|
||||
def handle_error(self, request: bytes,
|
||||
client_address: Tuple[str, int]) -> None: ...
|
||||
def handle_timeout(self) -> None: ...
|
||||
def process_request(self, request: bytes,
|
||||
client_address: Tuple[str, int]) -> None: ...
|
||||
def server_activate(self) -> None: ...
|
||||
def server_bind(self) -> None: ...
|
||||
def verify_request(self, request: bytes,
|
||||
client_address: Tuple[str, int]) -> bool: ...
|
||||
if sys.version_info >= (3, 6):
|
||||
def __enter__(self) -> 'BaseServer': ...
|
||||
def __exit__(self, exc_type: Optional[Type[BaseException]],
|
||||
exc_val: Optional[BaseException],
|
||||
exc_tb: Optional[types.TracebackType]) -> bool: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
def service_actions(self) -> None: ...
|
||||
|
||||
class TCPServer(BaseServer):
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: type,
|
||||
bind_and_activate: bool = ...) -> None: ...
|
||||
|
||||
class UDPServer(BaseServer):
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: type,
|
||||
bind_and_activate: bool = ...) -> None: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
class UnixStreamServer(BaseServer):
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: type,
|
||||
bind_and_activate: bool = ...) -> None: ...
|
||||
|
||||
class UnixDatagramServer(BaseServer):
|
||||
def __init__(self, server_address: Tuple[str, int],
|
||||
RequestHandlerClass: type,
|
||||
bind_and_activate: bool = ...) -> None: ...
|
||||
|
||||
class ForkingMixIn: ...
|
||||
class ThreadingMixIn: ...
|
||||
|
||||
class ForkingTCPServer(ForkingMixIn, TCPServer): ...
|
||||
class ForkingUDPServer(ForkingMixIn, UDPServer): ...
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer): ...
|
||||
class ThreadingUDPServer(ThreadingMixIn, UDPServer): ...
|
||||
if sys.platform != 'win32':
|
||||
class ThreadingUnixStreamServer(ThreadingMixIn, UnixStreamServer): ...
|
||||
class ThreadingUnixDatagramServer(ThreadingMixIn, UnixDatagramServer): ...
|
||||
|
||||
|
||||
class BaseRequestHandler:
|
||||
# Those are technically of types, respectively:
|
||||
# * Union[SocketType, Tuple[bytes, SocketType]]
|
||||
# * Union[Tuple[str, int], str]
|
||||
# But there are some concerns that having unions here would cause
|
||||
# too much inconvenience to people using it (see
|
||||
# https://github.com/python/typeshed/pull/384#issuecomment-234649696)
|
||||
request = ... # type: Any
|
||||
client_address = ... # type: Any
|
||||
|
||||
server = ... # type: BaseServer
|
||||
def setup(self) -> None: ...
|
||||
def handle(self) -> None: ...
|
||||
def finish(self) -> None: ...
|
||||
|
||||
class StreamRequestHandler(BaseRequestHandler):
|
||||
rfile = ... # type: BinaryIO
|
||||
wfile = ... # type: BinaryIO
|
||||
|
||||
class DatagramRequestHandler(BaseRequestHandler):
|
||||
rfile = ... # type: BinaryIO
|
||||
wfile = ... # type: BinaryIO
|
||||
@@ -1,3 +1,4 @@
|
||||
# NB: __builtin__.pyi and builtins.pyi must remain consistent!
|
||||
# Stubs for builtins (Python 2.7)
|
||||
|
||||
# True and False are deliberately omitted because they are keywords in
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
__builtin__.pyi
|
||||
1085
stdlib/2/builtins.pyi
Normal file
1085
stdlib/2/builtins.pyi
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
posixpath.pyi
|
||||
37
stdlib/2/macpath.pyi
Normal file
37
stdlib/2/macpath.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
# NB: os2emxpath.pyi, posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
from typing import Any
|
||||
from genericpath import * # noqa: F403
|
||||
|
||||
curdir = ... # type: Any
|
||||
pardir = ... # type: Any
|
||||
extsep = ... # type: Any
|
||||
sep = ... # type: Any
|
||||
pathsep = ... # type: Any
|
||||
defpath = ... # type: Any
|
||||
altsep = ... # type: Any
|
||||
devnull = ... # type: Any
|
||||
|
||||
def normcase(s): ...
|
||||
def isabs(s): ...
|
||||
def join(a, *p): ...
|
||||
def split(p): ...
|
||||
def splitext(p): ...
|
||||
def splitdrive(p): ...
|
||||
def basename(p): ...
|
||||
def dirname(p): ...
|
||||
def islink(path): ...
|
||||
def lexists(path): ...
|
||||
def samefile(f1, f2): ...
|
||||
def sameopenfile(fp1, fp2): ...
|
||||
def samestat(s1, s2): ...
|
||||
def ismount(path): ...
|
||||
def walk(top, func, arg): ...
|
||||
def expanduser(path): ...
|
||||
def expandvars(path): ...
|
||||
def normpath(path): ...
|
||||
def abspath(path): ...
|
||||
def realpath(filename): ...
|
||||
|
||||
supports_unicode_filenames = ... # type: Any
|
||||
|
||||
def relpath(path, start=...): ...
|
||||
@@ -1 +0,0 @@
|
||||
posixpath.pyi
|
||||
37
stdlib/2/ntpath.pyi
Normal file
37
stdlib/2/ntpath.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
# NB: os2emxpath.pyi, posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
from typing import Any
|
||||
from genericpath import * # noqa: F403
|
||||
|
||||
curdir = ... # type: Any
|
||||
pardir = ... # type: Any
|
||||
extsep = ... # type: Any
|
||||
sep = ... # type: Any
|
||||
pathsep = ... # type: Any
|
||||
defpath = ... # type: Any
|
||||
altsep = ... # type: Any
|
||||
devnull = ... # type: Any
|
||||
|
||||
def normcase(s): ...
|
||||
def isabs(s): ...
|
||||
def join(a, *p): ...
|
||||
def split(p): ...
|
||||
def splitext(p): ...
|
||||
def splitdrive(p): ...
|
||||
def basename(p): ...
|
||||
def dirname(p): ...
|
||||
def islink(path): ...
|
||||
def lexists(path): ...
|
||||
def samefile(f1, f2): ...
|
||||
def sameopenfile(fp1, fp2): ...
|
||||
def samestat(s1, s2): ...
|
||||
def ismount(path): ...
|
||||
def walk(top, func, arg): ...
|
||||
def expanduser(path): ...
|
||||
def expandvars(path): ...
|
||||
def normpath(path): ...
|
||||
def abspath(path): ...
|
||||
def realpath(filename): ...
|
||||
|
||||
supports_unicode_filenames = ... # type: Any
|
||||
|
||||
def relpath(path, start=...): ...
|
||||
@@ -1 +0,0 @@
|
||||
posixpath.pyi
|
||||
37
stdlib/2/os2emxpath.pyi
Normal file
37
stdlib/2/os2emxpath.pyi
Normal file
@@ -0,0 +1,37 @@
|
||||
# NB: os2emxpath.pyi, posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
from typing import Any
|
||||
from genericpath import * # noqa: F403
|
||||
|
||||
curdir = ... # type: Any
|
||||
pardir = ... # type: Any
|
||||
extsep = ... # type: Any
|
||||
sep = ... # type: Any
|
||||
pathsep = ... # type: Any
|
||||
defpath = ... # type: Any
|
||||
altsep = ... # type: Any
|
||||
devnull = ... # type: Any
|
||||
|
||||
def normcase(s): ...
|
||||
def isabs(s): ...
|
||||
def join(a, *p): ...
|
||||
def split(p): ...
|
||||
def splitext(p): ...
|
||||
def splitdrive(p): ...
|
||||
def basename(p): ...
|
||||
def dirname(p): ...
|
||||
def islink(path): ...
|
||||
def lexists(path): ...
|
||||
def samefile(f1, f2): ...
|
||||
def sameopenfile(fp1, fp2): ...
|
||||
def samestat(s1, s2): ...
|
||||
def ismount(path): ...
|
||||
def walk(top, func, arg): ...
|
||||
def expanduser(path): ...
|
||||
def expandvars(path): ...
|
||||
def normpath(path): ...
|
||||
def abspath(path): ...
|
||||
def realpath(filename): ...
|
||||
|
||||
supports_unicode_filenames = ... # type: Any
|
||||
|
||||
def relpath(path, start=...): ...
|
||||
@@ -1,3 +1,4 @@
|
||||
# NB: os2emxpath.pyi, posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
from typing import Any
|
||||
from genericpath import * # noqa: F403
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# NB: third_party/3/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
|
||||
import sys
|
||||
from typing import List, Any, TypeVar, Union, Iterator, TypeVar, Generic, Type, Sized, Mapping
|
||||
from abc import ABCMeta
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
posixpath.pyi
|
||||
48
stdlib/3/macpath.pyi
Normal file
48
stdlib/3/macpath.pyi
Normal file
@@ -0,0 +1,48 @@
|
||||
# NB: posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
# Stubs for os.path
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
# based on http://docs.python.org/3.2/library/os.path.html
|
||||
import sys
|
||||
from typing import Any, List, Tuple, IO
|
||||
|
||||
# ----- os.path variables -----
|
||||
supports_unicode_filenames = False
|
||||
|
||||
# ----- os.path function stubs -----
|
||||
def abspath(path: str) -> str: ...
|
||||
def basename(path) -> str: ...
|
||||
def commonprefix(list: List[str]) -> str: ...
|
||||
def dirname(path: str) -> str: ...
|
||||
def exists(path: str) -> bool: ...
|
||||
def lexists(path: str) -> bool: ...
|
||||
def expanduser(path: str) -> str: ...
|
||||
def expandvars(path: str) -> str: ...
|
||||
def getatime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getmtime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getctime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getsize(path: str) -> int: ...
|
||||
def isabs(path: str) -> bool: ...
|
||||
def isfile(path: str) -> bool: ...
|
||||
def isdir(path: str) -> bool: ...
|
||||
def islink(path: str) -> bool: ...
|
||||
def ismount(path: str) -> bool: ...
|
||||
def join(path: str, *paths: str) -> str: ...
|
||||
def normcase(path: str) -> str: ...
|
||||
def normpath(path: str) -> str: ...
|
||||
def realpath(path: str) -> str: ...
|
||||
def relpath(path: str, start: str = ...) -> str: ...
|
||||
def samefile(path1: str, path2: str) -> bool: ...
|
||||
|
||||
def sameopenfile(fp1: IO[Any], fp2: IO[Any]) -> bool: ...
|
||||
|
||||
# def samestat(stat1: stat_result, stat2: stat_result) -> bool:
|
||||
# ... # Unix only
|
||||
def split(path: str) -> Tuple[str, str]: ...
|
||||
def splitdrive(path: str) -> Tuple[str, str]: ...
|
||||
def splitext(path: str) -> Tuple[str, str]: ...
|
||||
if sys.version_info < (3, 7) and sys.platform == 'win32':
|
||||
def splitunc(path: str) -> Tuple[str, str]: ...
|
||||
@@ -1 +0,0 @@
|
||||
posixpath.pyi
|
||||
48
stdlib/3/ntpath.pyi
Normal file
48
stdlib/3/ntpath.pyi
Normal file
@@ -0,0 +1,48 @@
|
||||
# NB: posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
# Stubs for os.path
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
# based on http://docs.python.org/3.2/library/os.path.html
|
||||
import sys
|
||||
from typing import Any, List, Tuple, IO
|
||||
|
||||
# ----- os.path variables -----
|
||||
supports_unicode_filenames = False
|
||||
|
||||
# ----- os.path function stubs -----
|
||||
def abspath(path: str) -> str: ...
|
||||
def basename(path) -> str: ...
|
||||
def commonprefix(list: List[str]) -> str: ...
|
||||
def dirname(path: str) -> str: ...
|
||||
def exists(path: str) -> bool: ...
|
||||
def lexists(path: str) -> bool: ...
|
||||
def expanduser(path: str) -> str: ...
|
||||
def expandvars(path: str) -> str: ...
|
||||
def getatime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getmtime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getctime(path: str) -> int:
|
||||
... # return float if os.stat_float_times() returns True
|
||||
def getsize(path: str) -> int: ...
|
||||
def isabs(path: str) -> bool: ...
|
||||
def isfile(path: str) -> bool: ...
|
||||
def isdir(path: str) -> bool: ...
|
||||
def islink(path: str) -> bool: ...
|
||||
def ismount(path: str) -> bool: ...
|
||||
def join(path: str, *paths: str) -> str: ...
|
||||
def normcase(path: str) -> str: ...
|
||||
def normpath(path: str) -> str: ...
|
||||
def realpath(path: str) -> str: ...
|
||||
def relpath(path: str, start: str = ...) -> str: ...
|
||||
def samefile(path1: str, path2: str) -> bool: ...
|
||||
|
||||
def sameopenfile(fp1: IO[Any], fp2: IO[Any]) -> bool: ...
|
||||
|
||||
# def samestat(stat1: stat_result, stat2: stat_result) -> bool:
|
||||
# ... # Unix only
|
||||
def split(path: str) -> Tuple[str, str]: ...
|
||||
def splitdrive(path: str) -> Tuple[str, str]: ...
|
||||
def splitext(path: str) -> Tuple[str, str]: ...
|
||||
if sys.version_info < (3, 7) and sys.platform == 'win32':
|
||||
def splitunc(path: str) -> Tuple[str, str]: ...
|
||||
@@ -1,3 +1,4 @@
|
||||
# NB: posixpath.pyi, ntpath.pyi, and macpath.pyi must remain consistent!
|
||||
# Stubs for os.path
|
||||
# Ron Murawski <ron@horizonchess.com>
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# NB: SocketServer.pyi and socketserver.pyi must remain consistent!
|
||||
# Stubs for socketserver
|
||||
|
||||
from typing import Any, BinaryIO, Optional, Tuple, Type
|
||||
|
||||
32
tests/check_consistent.py
Executable file
32
tests/check_consistent.py
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Symlinks are bad on Windows, so we cannot use them in typeshed.
|
||||
# This checks that certain files are duplicated exactly.
|
||||
|
||||
import os
|
||||
import filecmp
|
||||
from os import path
|
||||
|
||||
consistent_files = [
|
||||
{'stdlib/2/builtins.pyi', 'stdlib/2/__builtin__.pyi'},
|
||||
{'stdlib/2/SocketServer.pyi', 'stdlib/3/socketserver.pyi'},
|
||||
{'stdlib/2/os2emxpath.pyi', 'stdlib/2/posixpath.pyi', 'stdlib/2/ntpath.pyi', 'stdlib/2/macpath.pyi'},
|
||||
{'stdlib/3/ntpath.pyi', 'stdlib/3/posixpath.pyi', 'stdlib/3/macpath.pyi', 'stdlib/3/posixpath.pyi'},
|
||||
{'stdlib/3.4/enum.pyi', 'third_party/3/enum.pyi'},
|
||||
]
|
||||
|
||||
def main():
|
||||
files = [path.join(root, file) for root, dir, files in os.walk('.') for file in files]
|
||||
no_symlink = 'You cannot use symlinks in typeshed, please copy the file to its link.'
|
||||
for file in files:
|
||||
if path.islink(file):
|
||||
raise ValueError(no_symlink.format(file))
|
||||
for file1, *others in consistent_files:
|
||||
f1 = path.join(os.getcwd(), file1)
|
||||
for file2 in others:
|
||||
f2 = path.join(os.getcwd(), file2)
|
||||
if not filecmp.cmp(f1, f2):
|
||||
raise ValueError('File {f1} does not match file {f2}. Please copy it to {f2}'.format(f1=file1, f2=file2))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
1
third_party/3/enum.pyi
vendored
1
third_party/3/enum.pyi
vendored
@@ -1 +0,0 @@
|
||||
../../stdlib/3.4/enum.pyi
|
||||
64
third_party/3/enum.pyi
vendored
Normal file
64
third_party/3/enum.pyi
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# NB: third_party/3/enum.pyi and stdlib/3.4/enum.pyi must remain consistent!
|
||||
import sys
|
||||
from typing import List, Any, TypeVar, Union, Iterator, TypeVar, Generic, Type, Sized, Mapping
|
||||
from abc import ABCMeta
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_S = TypeVar('_S', bound=Type[Enum])
|
||||
|
||||
# Note: EnumMeta actually subclasses type directly, not ABCMeta.
|
||||
# This is a temporary workaround to allow multiple creation of enums with builtins
|
||||
# such as str as mixins, which due to the handling of ABCs of builtin types, cause
|
||||
# spurious inconsistent metaclass structure. See #1595.
|
||||
# Structurally: Iterable[T], Reversible[T], Container[T] where T is the enum itself
|
||||
class EnumMeta(ABCMeta, Sized):
|
||||
def __iter__(self: Type[_T]) -> Iterator[_T]: ...
|
||||
def __reversed__(self: Type[_T]) -> Iterator[_T]: ...
|
||||
def __contains__(self: Type[_T], member: Any) -> bool: ...
|
||||
def __getitem__(self: Type[_T], name: str) -> _T: ...
|
||||
@property
|
||||
def __members__(self: Type[_T]) -> Mapping[str, _T]: ...
|
||||
|
||||
class Enum(metaclass=EnumMeta):
|
||||
def __new__(cls: Type[_T], value: Any) -> _T: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __dir__(self) -> List[str]: ...
|
||||
def __format__(self, format_spec: str) -> str: ...
|
||||
def __hash__(self) -> Any: ...
|
||||
def __reduce_ex__(self, proto: Any) -> Any: ...
|
||||
|
||||
name = ... # type: str
|
||||
value = ... # type: Any
|
||||
|
||||
class IntEnum(int, Enum):
|
||||
value = ... # type: int
|
||||
|
||||
def unique(enumeration: _S) -> _S: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
_auto_null = ... # type: Any
|
||||
|
||||
# subclassing IntFlag so it picks up all implemented base functions, best modeling behavior of enum.auto()
|
||||
class auto(IntFlag):
|
||||
value = ... # type: Any
|
||||
|
||||
class Flag(Enum):
|
||||
def __contains__(self: _T, other: _T) -> bool: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def __str__(self) -> str: ...
|
||||
def __bool__(self) -> bool: ...
|
||||
def __or__(self: _T, other: _T) -> _T: ...
|
||||
def __and__(self: _T, other: _T) -> _T: ...
|
||||
def __xor__(self: _T, other: _T) -> _T: ...
|
||||
def __invert__(self: _T) -> _T: ...
|
||||
|
||||
# The `type: ignore` comment is needed because mypy considers the type
|
||||
# signatures of several methods defined in int and Flag to be incompatible.
|
||||
class IntFlag(int, Flag): # type: ignore
|
||||
def __or__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
def __and__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
def __xor__(self: _T, other: Union[int, _T]) -> _T: ...
|
||||
__ror__ = __or__
|
||||
__rand__ = __and__
|
||||
__rxor__ = __xor__
|
||||
Reference in New Issue
Block a user