Skip to content

Commit 11350ed

Browse files
JelleZijlstragvanrossum
authored andcommitted
Fix missing argument types in py3 stdlib (#995)
Still missing a few in _subprocess (a Windows-only private module) and decimal (I gave up).
1 parent 01b3915 commit 11350ed

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

stdlib/2and3/fractions.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class Fraction(Rational):
3030
*,
3131
_normalize: bool = True) -> None: ...
3232
@overload
33-
def __init__(self, value: float, *, _normalize=True) -> None: ...
33+
def __init__(self, value: float, *, _normalize: bool = True) -> None: ...
3434
@overload
35-
def __init__(self, value: Decimal, *, _normalize=True) -> None: ...
35+
def __init__(self, value: Decimal, *, _normalize: bool = True) -> None: ...
3636
@overload
37-
def __init__(self, value: str, *, _normalize=True) -> None: ...
37+
def __init__(self, value: str, *, _normalize: bool = True) -> None: ...
3838

3939
@classmethod
4040
def from_float(cls, f: float) -> 'Fraction': ...

stdlib/3.4/asyncio/locks.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Generator, Iterable, Iterator, TypeVar, Union
1+
from typing import Any, Callable, Generator, Iterable, Iterator, TypeVar, Union, Optional
22

33
from .coroutines import coroutine
44
from .events import AbstractEventLoop
@@ -49,11 +49,11 @@ class Condition(_ContextManagerMixin):
4949
def notify_all(self) -> None: ...
5050

5151
class Semaphore(_ContextManagerMixin):
52-
def __init__(self, value: int = 1, *, loop: AbstractEventLoop = None) -> None: ...
52+
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
5353
def locked(self) -> bool: ...
5454
@coroutine
5555
def acquire(self) -> Generator[Any, None, bool]: ...
5656
def release(self) -> None: ...
5757

5858
class BoundedSemaphore(Semaphore):
59-
def __init__(self, value=1, *, loop: AbstractEventLoop = None) -> None: ...
59+
def __init__(self, value: int = ..., *, loop: Optional[AbstractEventLoop] = ...) -> None: ...

stdlib/3.4/asyncio/tasks.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ FIRST_COMPLETED = 'FIRST_COMPLETED'
1515
ALL_COMPLETED = 'ALL_COMPLETED'
1616

1717
def as_completed(fs: Sequence[_FutureT[_T]], *, loop: AbstractEventLoop = ...,
18-
timeout=None) -> Iterator[Generator[Any, None, _T]]: ...
18+
timeout: Optional[float] = ...) -> Iterator[Generator[Any, None, _T]]: ...
1919
def ensure_future(coro_or_future: _FutureT[_T],
2020
*, loop: AbstractEventLoop = ...) -> Future[_T]: ...
2121
# TODO: gather() should use variadic type vars instead of _TAny.

stdlib/3/_posixsubprocess.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
# NOTE: These are incomplete!
44

5-
from typing import Tuple, Sequence
5+
from typing import Tuple, Sequence, Callable
66

77
def cloexec_pipe() -> Tuple[int, int]: ...
88
def fork_exec(args: Sequence[str],
9-
executable_list, close_fds, fds_to_keep, cwd: str, env_list,
9+
executable_list: Sequence[bytes], close_fds: bool, fds_to_keep: Sequence[int],
10+
cwd: str, env_list: Sequence[bytes],
1011
p2cread: int, p2cwrite: int, c2pred: int, c2pwrite: int,
1112
errread: int, errwrite: int, errpipe_read: int,
12-
errpipe_write: int, restore_signals, start_new_session,
13-
preexec_fn) -> int: ...
13+
errpipe_write: int, restore_signals: int, start_new_session: int,
14+
preexec_fn: Callable[[], None]) -> int: ...

stdlib/3/http/client.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ from typing import (
77
)
88
import email.message
99
import io
10+
from socket import socket
1011
import sys
1112
import ssl
1213
import types
@@ -87,7 +88,7 @@ if sys.version_info >= (3, 5):
8788
closed = ... # type: bool
8889
status = ... # type: int
8990
reason = ... # type: str
90-
def __init__(self, sock, debuglevel: int = ...,
91+
def __init__(self, sock: socket, debuglevel: int = ...,
9192
method: Optional[str] = ..., url: Optional[str] = ...) -> None: ...
9293
def read(self, amt: Optional[int] = ...) -> bytes: ...
9394
def readinto(self, b: bytearray) -> int: ...

stdlib/3/shlex.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Based on http://docs.python.org/3.2/library/shlex.html
44

5-
from typing import List, Tuple, Any, TextIO
5+
from typing import List, Tuple, Any, TextIO, Union, Optional
66

77
def split(s: str, comments: bool = ...,
88
posix: bool = ...) -> List[str]: ...
@@ -26,7 +26,7 @@ class shlex:
2626
token = ... # type: str
2727
eof = ... # type: str
2828

29-
def __init__(self, instream=..., infile=...,
29+
def __init__(self, instream: Union[str, TextIO] = ..., infile: Optional[str] = ...,
3030
posix: bool = ...) -> None: ...
3131
def get_token(self) -> str: ...
3232
def push_token(self, tok: str) -> None: ...

0 commit comments

Comments
 (0)