Skip to content

Commit 9d616a2

Browse files
committed
Merge branch 'python/master'
* python/master: Added stub for toaiff module (python#1455) Added stub for user module (python#1454) Add more multiprocessing function stubs (python#1435) PyYaml: uncomment commented out imports and add missing classmethod decorators (python#1439) Allow `os.readlink` to accept path-like objects (python#1441) Support named attributes in `os.uname()` result (python#1445) Fix signature for slite3.fetchmany (python#1444) Add __name__ field to MethodType (python#1442) Add TypedDict total argument (python#1443)
2 parents 4b9e317 + 83d5ba1 commit 9d616a2

File tree

15 files changed

+70
-15
lines changed

15 files changed

+70
-15
lines changed

stdlib/2/sqlite3/dbapi2.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Filip Hron <[email protected]>
22
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
33

4-
from typing import Any, Union, List, Iterator
5-
from numbers import Integral
4+
from typing import Any, Union, List, Iterator, Optional
65
from datetime import time, datetime
76
from collections import Iterable
87

@@ -141,7 +140,7 @@ class Cursor(Iterator[Any]):
141140
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
142141
def executescript(self, sql_script: Union[bytes, unicode]) -> Cursor: ...
143142
def fetchall(self) -> List[Any]: ...
144-
def fetchmany(self, size: Integral = ...) -> List[Any]: ...
143+
def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
145144
def fetchone(self) -> Any: ...
146145
def setinputsizes(self, *args, **kwargs): ...
147146
def setoutputsize(self, *args, **kwargs): ...

stdlib/2/toaiff.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Stubs for toaiff (Python 2)
2+
3+
# Source: https://hg.python.org/cpython/file/2.7/Lib/toaiff.py
4+
from pipes import Template
5+
from typing import Dict, List
6+
7+
8+
__all__: List[str]
9+
table: Dict[str, Template]
10+
t: Template
11+
uncompress: Template
12+
13+
class error(Exception): ...
14+
15+
def toaiff(filename: str) -> str: ...
16+
def _toaiff(filename: str, temps: List[str]) -> str: ...

stdlib/2/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class UnboundMethodType:
8282
im_class = ... # type: type
8383
im_func = ... # type: FunctionType
8484
im_self = ... # type: Optional[object]
85+
__name__ = ... # type: str
8586
__func__ = im_func
8687
__self__ = im_self
8788
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...

stdlib/2/user.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Stubs for user (Python 2)
2+
3+
# Docs: https://docs.python.org/2/library/user.html
4+
# Source: https://hg.python.org/cpython/file/2.7/Lib/user.py
5+
from typing import Any
6+
7+
def __getattr__(name) -> Any: ... # type: ignore
8+
home: str
9+
pythonrc: str

stdlib/3/multiprocessing/__init__.pyi

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Stubs for multiprocessing
22

3-
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List
3+
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List, Union
44

5+
from logging import Logger
56
from multiprocessing.context import BaseContext
67
from multiprocessing.managers import SyncManager
78
from multiprocessing.pool import AsyncResult
89
from multiprocessing.process import current_process as current_process
10+
import sys
911

1012
class Lock():
1113
def acquire(self, block: bool = ..., timeout: int = ...) -> None: ...
@@ -101,6 +103,18 @@ class Value():
101103
def __init__(self, typecode_or_type: str, *args: Any, lock: bool = ...) -> None: ...
102104

103105
# ----- multiprocessing function stubs -----
106+
def active_children() -> List[Process]: ...
107+
def allow_connection_pickling() -> None: ...
104108
def cpu_count() -> int: ...
105109
def freeze_support() -> None: ...
110+
def get_logger() -> Logger: ...
111+
def log_to_stderr(level: Optional[Union[str, int]] = ...) -> Logger: ...
106112
def Manager() -> SyncManager: ...
113+
def set_forkserver_preload(module_names: List[str]) -> None: ...
114+
if sys.platform == 'win32' or sys.version_info >= (3, 4):
115+
def set_executable(executable: str) -> None: ...
116+
if sys.version_info >= (3, 4):
117+
def get_all_start_methods() -> List[str]: ...
118+
def get_context(method: Optional[str] = ...) -> BaseContext: ...
119+
def get_start_method(allow_none: Optional[bool]) -> Optional[str]: ...
120+
def set_start_method(method: str, force: Optional[bool] = ...) -> None: ...

stdlib/3/os/__init__.pyi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ def setsid() -> None: ... # Unix only
254254
def setuid(uid: int) -> None: ... # Unix only
255255
def strerror(code: int) -> str: ...
256256
def umask(mask: int) -> int: ...
257-
def uname() -> Tuple[str, str, str, str, str]: ... # Unix only
257+
if sys.version_info >= (3, 3):
258+
from posix import uname_result
259+
def uname() -> uname_result: ... # Unix only
260+
else:
261+
def uname() -> Tuple[str, str, str, str, str]: ... # Unix only
258262

259263
@overload
260264
def getenv(key: Text) -> Optional[str]: ...

stdlib/3/posix.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,11 @@
22

33
# NOTE: These are incomplete!
44

5+
import sys
56
import typing
67
from os import stat_result
8+
from typing import NamedTuple
9+
10+
if sys.version_info >= (3, 3):
11+
uname_result = NamedTuple('uname_result', [('sysname', str), ('nodename', str),
12+
('release', str), ('version', str), ('machine', str)])

stdlib/3/sqlite3/dbapi2.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import sys
55
from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable
6-
from numbers import Integral
76
from datetime import time, datetime
87
from collections import Iterable
98

@@ -141,7 +140,7 @@ class Cursor(Iterator[Any]):
141140
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
142141
def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ...
143142
def fetchall(self) -> List[Any]: ...
144-
def fetchmany(self, size: Integral = ...) -> List[Any]: ...
143+
def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
145144
def fetchone(self) -> Any: ...
146145
def setinputsizes(self, *args, **kwargs): ...
147146
def setoutputsize(self, *args, **kwargs): ...

stdlib/3/types.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class _StaticFunctionType:
139139
class MethodType:
140140
__func__ = ... # type: _StaticFunctionType
141141
__self__ = ... # type: object
142+
__name__ = ... # type: str
142143
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
143144
class BuiltinFunctionType:
144145
__self__ = ... # type: Union[object, ModuleType]

third_party/2/pymssql.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Cursor(object):
2626
def executemany(self, stmt: str,
2727
params: Optional[Sequence[Tuple[Scalar, ...]]]) -> None: ...
2828
def fetchall(self) -> List[Result]: ...
29-
def fetchmany(self, size: Optional[Union[int, None]]) -> List[Result]: ...
29+
def fetchmany(self, size: Optional[int]) -> List[Result]: ...
3030
def fetchone(self) -> Result: ...
3131

3232
def connect(server: Optional[str],

0 commit comments

Comments
 (0)