Skip to content

Commit 0149ef8

Browse files
JelleZijlstraDaniel Li
authored andcommitted
Replace a number of default argument values with "..." (python#1280)
pytype apparently doesn't like default values that aren't ints or None/True/False.
1 parent cb7d190 commit 0149ef8

File tree

6 files changed

+47
-52
lines changed

6 files changed

+47
-52
lines changed

stdlib/3/calendar.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import datetime
22

33
from time import struct_time
4-
from typing import Any, Iterable, List, Optional, Tuple, Sequence, Union
4+
from typing import Any, Iterable, List, Optional, Sequence, Tuple, Union
55

66

77
LocaleType = Tuple[Optional[str], Optional[str]]
@@ -20,7 +20,7 @@ def weekday(year: int, month: int, day: int) -> int: ...
2020
def monthrange(year: int, month: int) -> Tuple[int, int]: ...
2121

2222
class Calendar:
23-
def __init__(self, firstweekday: int = 0) -> None: ...
23+
def __init__(self, firstweekday: int = ...) -> None: ...
2424
def getfirstweekday(self) -> int: ...
2525
def setfirstweekday(self, firstweekday: int) -> None: ...
2626
def iterweekdays(self) -> Iterable[int]: ...
@@ -30,9 +30,9 @@ class Calendar:
3030
def monthdatescalendar(self, year: int, month: int) -> List[List[datetime.date]]: ...
3131
def monthdays2calendar(self, year: int, month: int) -> List[List[Tuple[int, int]]]: ...
3232
def monthdayscalendar(self, year: int, month: int) -> List[List[int]]: ...
33-
def yeardatescalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
34-
def yeardays2calendar(self, year: int, width: int = 3) -> List[List[Tuple[int, int]]]: ...
35-
def yeardayscalendar(self, year: int, width: int = 3) -> List[List[int]]: ...
33+
def yeardatescalendar(self, year: int, width: int = ...) -> List[List[int]]: ...
34+
def yeardays2calendar(self, year: int, width: int = ...) -> List[List[Tuple[int, int]]]: ...
35+
def yeardayscalendar(self, year: int, width: int = ...) -> List[List[int]]: ...
3636

3737
class TextCalendar(Calendar):
3838
def prweek(self, theweek: int, width: int) -> None: ...
@@ -42,8 +42,8 @@ class TextCalendar(Calendar):
4242
def formatweekheader(self, width: int) -> str: ...
4343
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
4444
def prmonth(self, theyear: int, themonth: int, w: Any=0, l: Any = 0) -> None: ...
45-
def formatmonth(self, theyear: int, themonth: int, w: int = 0, l: int = 0) -> str: ...
46-
def formatyear(self, theyear: int, w: int = 2, l: int = 1, c: int = 6, m: int = 3) -> str: ...
45+
def formatmonth(self, theyear: int, themonth: int, w: int = ..., l: int = ...) -> str: ...
46+
def formatyear(self, theyear: int, w: int = ..., l: int = ..., c: int = ..., m: int = ...) -> str: ...
4747
def pryear(self, theyear: int, w: Any = 0, l: Any = 0, c: Any = 6, m: Any = 3) -> None: ...
4848

4949
class HTMLCalendar(Calendar):
@@ -53,21 +53,21 @@ class HTMLCalendar(Calendar):
5353
def formatweekheader(self) -> str: ...
5454
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
5555
def formatmonth(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
56-
def formatyear(self, theyear: int, width: int = 3) -> str: ...
57-
def formatyearpage(self, theyear: int, width: int = 3, css: Optional[str] = 'calendar.css', encoding: Optional[str] = ...) -> str: ...
56+
def formatyear(self, theyear: int, width: int = ...) -> str: ...
57+
def formatyearpage(self, theyear: int, width: int = ..., css: Optional[str] = ..., encoding: Optional[str] = ...) -> str: ...
5858

5959
class different_locale:
6060
def __init__(self, locale: LocaleType) -> None: ...
6161
def __enter__(self) -> LocaleType: ...
6262
def __exit__(self, *args) -> None: ...
6363

6464
class LocaleTextCalendar(TextCalendar):
65-
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
65+
def __init__(self, firstweekday: int = ..., locale: Optional[LocaleType] = ...) -> None: ...
6666
def formatweekday(self, day: int, width: int) -> str: ...
6767
def formatmonthname(self, theyear: int, themonth: int, width: int, withyear: bool = ...) -> str: ...
6868

6969
class LocaleHTMLCalendar(HTMLCalendar):
70-
def __init__(self, firstweekday: int = 0, locale: Optional[LocaleType] = ...) -> None: ...
70+
def __init__(self, firstweekday: int = ..., locale: Optional[LocaleType] = ...) -> None: ...
7171
def formatweekday(self, day: int) -> str: ...
7272
def formatmonthname(self, theyear: int, themonth: int, withyear: bool = ...) -> str: ...
7373

stdlib/3/importlib/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import types
44
from typing import Any, Mapping, Optional, Sequence
55

66
def __import__(name: str, globals: Mapping[str, Any] = None,
7-
locals: Mapping[str, Any] = None, fromlist: Sequence[str] = (),
8-
level: int = 0) -> types.ModuleType: ...
7+
locals: Mapping[str, Any] = None, fromlist: Sequence[str] = ...,
8+
level: int = ...) -> types.ModuleType: ...
99

1010
def import_module(name: str, package: str = None) -> types.ModuleType: ...
1111

stdlib/3/importlib/abc.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ class InspectLoader(Loader):
3535
def exec_module(self, module: types.ModuleType) -> None: ...
3636
if sys.version_info[:2] == (3, 4):
3737
def source_to_code(self, data: Union[bytes, str],
38-
path: str = '<string>') -> types.CodeType: ...
38+
path: str = ...) -> types.CodeType: ...
3939
elif sys.version_info >= (3, 5):
4040
@staticmethod
4141
def source_to_code(data: Union[bytes, str],
42-
path: str = '<string>') -> types.CodeType: ...
42+
path: str = ...) -> types.CodeType: ...
4343

4444
class ExecutionLoader(InspectLoader):
4545
@abstractmethod

stdlib/3/multiprocessing/__init__.pyi

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ class Lock():
1010
def release(self) -> None: ...
1111

1212
class AsyncResult():
13-
def get(self, timeout: float = -1) -> Any: ...
14-
def wait(self, timeout: float = -1) -> None: ...
13+
def get(self, timeout: float = ...) -> Any: ...
14+
def wait(self, timeout: float = ...) -> None: ...
1515
def ready(self) -> bool: ...
1616
def successful(self) -> bool: ...
1717

@@ -20,49 +20,49 @@ class Event(object):
2020
def is_set(self) -> bool: ...
2121
def set(self) -> None: ...
2222
def clear(self) -> None: ...
23-
def wait(self, timeout: Optional[int] = None) -> bool: ...
23+
def wait(self, timeout: Optional[int] = ...) -> bool: ...
2424

2525
class Pool():
26-
def __init__(self, processes: Optional[int] = None,
27-
initializer: Optional[Callable[..., None]] = None,
28-
initargs: Iterable[Any] = (),
29-
maxtasksperchild: Optional[int] = None,
26+
def __init__(self, processes: Optional[int] = ...,
27+
initializer: Optional[Callable[..., None]] = ...,
28+
initargs: Iterable[Any] = ...,
29+
maxtasksperchild: Optional[int] = ...,
3030
context: Any = None) -> None: ...
3131
def apply(self,
3232
func: Callable[..., Any],
33-
args: Iterable[Any]=(),
33+
args: Iterable[Any] = ...,
3434
kwds: Dict[str, Any]=...) -> Any: ...
3535
def apply_async(self,
3636
func: Callable[..., Any],
37-
args: Iterable[Any]=(),
38-
kwds: Dict[str, Any]=...,
37+
args: Iterable[Any] = ...,
38+
kwds: Dict[str, Any] = ...,
3939
callback: Callable[..., None] = None,
4040
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...
4141
def map(self,
4242
func: Callable[..., Any],
43-
iterable: Iterable[Any]=(),
44-
chunksize: Optional[int] = None) -> List[Any]: ...
43+
iterable: Iterable[Any] = ...,
44+
chunksize: Optional[int] = ...) -> List[Any]: ...
4545
def map_async(self, func: Callable[..., Any],
46-
iterable: Iterable[Any] = (),
47-
chunksize: Optional[int] = None,
46+
iterable: Iterable[Any] = ...,
47+
chunksize: Optional[int] = ...,
4848
callback: Callable[..., None] = None,
4949
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...
5050
def imap(self,
5151
func: Callable[..., Any],
52-
iterable: Iterable[Any]=(),
52+
iterable: Iterable[Any] = ...,
5353
chunksize: Optional[int] = None) -> Iterable[Any]: ...
5454
def imap_unordered(self,
5555
func: Callable[..., Any],
56-
iterable: Iterable[Any]=(),
56+
iterable: Iterable[Any] = ...,
5757
chunksize: Optional[int] = None) -> Iterable[Any]: ...
5858
def starmap(self,
5959
func: Callable[..., Any],
60-
iterable: Iterable[Iterable[Any]]=(),
60+
iterable: Iterable[Iterable[Any]] = ...,
6161
chunksize: Optional[int] = None) -> List[Any]: ...
6262
def starmap_async(self,
6363
func: Callable[..., Any],
64-
iterable: Iterable[Iterable[Any]] = (),
65-
chunksize: Optional[int] = None,
64+
iterable: Iterable[Iterable[Any]] = ...,
65+
chunksize: Optional[int] = ...,
6666
callback: Callable[..., None] = None,
6767
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...
6868
def close(self) -> None: ...

stdlib/3/multiprocessing/pool.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,49 @@
55
from typing import Any, Callable, Iterable, Mapping, Optional, Dict, List
66

77
class AsyncResult():
8-
def get(self, timeout: float = -1) -> Any: ...
9-
def wait(self, timeout: float = -1) -> None: ...
8+
def get(self, timeout: float = ...) -> Any: ...
9+
def wait(self, timeout: float = ...) -> None: ...
1010
def ready(self) -> bool: ...
1111
def successful(self) -> bool: ...
1212

1313
class ThreadPool():
1414
def __init__(self, processes: Optional[int] = None,
1515
initializer: Optional[Callable[..., None]] = None,
16-
initargs: Iterable[Any] = ()) -> None: ...
16+
initargs: Iterable[Any] = ...) -> None: ...
1717
def apply(self,
1818
func: Callable[..., Any],
19-
args: Iterable[Any]=(),
20-
kwds: Dict[str, Any]=...) -> Any: ...
19+
args: Iterable[Any] = ...,
20+
kwds: Dict[str, Any] = ...) -> Any: ...
2121
def apply_async(self,
2222
func: Callable[..., Any],
23-
args: Iterable[Any]=(),
24-
kwds: Dict[str, Any]=...,
23+
args: Iterable[Any] = ...,
24+
kwds: Dict[str, Any] = ...,
2525
callback: Callable[..., None] = None,
2626
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...
2727
def map(self,
2828
func: Callable[..., Any],
29-
iterable: Iterable[Any]=(),
29+
iterable: Iterable[Any] = ...,
3030
chunksize: Optional[int] = None) -> List[Any]: ...
3131
def map_async(self, func: Callable[..., Any],
32-
iterable: Iterable[Any] = (),
32+
iterable: Iterable[Any] = ...,
3333
chunksize: Optional[int] = None,
3434
callback: Callable[..., None] = None,
3535
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...
3636
def imap(self,
3737
func: Callable[..., Any],
38-
iterable: Iterable[Any]=(),
38+
iterable: Iterable[Any] = ...,
3939
chunksize: Optional[int] = None) -> Iterable[Any]: ...
4040
def imap_unordered(self,
4141
func: Callable[..., Any],
42-
iterable: Iterable[Any]=(),
42+
iterable: Iterable[Any] = ...,
4343
chunksize: Optional[int] = None) -> Iterable[Any]: ...
4444
def starmap(self,
4545
func: Callable[..., Any],
46-
iterable: Iterable[Iterable[Any]]=(),
46+
iterable: Iterable[Iterable[Any]] = ...,
4747
chunksize: Optional[int] = None) -> List[Any]: ...
4848
def starmap_async(self,
4949
func: Callable[..., Any],
50-
iterable: Iterable[Iterable[Any]] = (),
50+
iterable: Iterable[Iterable[Any]] = ...,
5151
chunksize: Optional[int] = None,
5252
callback: Callable[..., None] = None,
5353
error_callback: Callable[[BaseException], None] = None) -> AsyncResult: ...

tests/pytype_blacklist.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ stdlib/3/os/__init__.pyi
1717

1818
# We've not been running the pytype tests under Python 3, for quite a while.
1919
# The below are files that have regressed and need fixing:
20-
stdlib/3/calendar.pyi
2120
stdlib/3/collections/__init__.pyi
2221
stdlib/3/collections/abc.pyi
2322
stdlib/3/concurrent/futures/__init__.pyi
@@ -31,14 +30,10 @@ stdlib/3/fileinput.pyi
3130
stdlib/3/gzip.pyi
3231
stdlib/3/http/__init__.pyi
3332
stdlib/3/http/cookiejar.pyi
34-
stdlib/3/importlib/__init__.pyi
35-
stdlib/3/importlib/abc.pyi
3633
stdlib/3/inspect.pyi
3734
stdlib/3/json/__init__.pyi
3835
stdlib/3/json/decoder.pyi
3936
stdlib/3/json/encoder.pyi
40-
stdlib/3/multiprocessing/__init__.pyi
41-
stdlib/3/multiprocessing/pool.pyi
4237
stdlib/3/ssl.pyi
4338
stdlib/3/subprocess.pyi
4439
stdlib/3/sys.pyi

0 commit comments

Comments
 (0)