Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy (#1421)

* Add flags to pass on --warn-unused-ignores and --no-implicit-optional to mypy
* Make implicit Optional explicit in arg types (2and3 part)
* Convert {stdlib,third_party}/2 to explicit Optional
This commit is contained in:
Guido van Rossum
2017-06-20 22:18:49 -07:00
committed by Jelle Zijlstra
parent 30256097ea
commit 04fe184dcf
23 changed files with 257 additions and 237 deletions

View File

@@ -485,7 +485,7 @@ class slice(object):
@overload
def __init__(self, stop: Optional[int]) -> None: ...
@overload
def __init__(self, start: Optional[int], stop: Optional[int], step: int = None) -> None: ...
def __init__(self, start: Optional[int], stop: Optional[int], step: Optional[int] = None) -> None: ...
def indices(self, len: int) -> Tuple[int, int, int]: ...
class tuple(Sequence[_T_co], Generic[_T_co]):
@@ -676,13 +676,13 @@ class xrange(Sized, Iterable[int], Reversible[int]):
def __reversed__(self) -> Iterator[int]: ...
class property(object):
def __init__(self, fget: Callable[[Any], Any] = None,
fset: Callable[[Any, Any], None] = None,
fdel: Callable[[Any], None] = None, doc: str = None) -> None: ...
def __init__(self, fget: Optional[Callable[[Any], Any]] = None,
fset: Optional[Callable[[Any, Any], None]] = None,
fdel: Optional[Callable[[Any], None]] = None, doc: Optional[str] = None) -> None: ...
def getter(self, fget: Callable[[Any], Any]) -> property: ...
def setter(self, fset: Callable[[Any, Any], None]) -> property: ...
def deleter(self, fdel: Callable[[Any], None]) -> property: ...
def __get__(self, obj: Any, type: type=None) -> Any: ...
def __get__(self, obj: Any, type: Optional[type] = None) -> Any: ...
def __set__(self, obj: Any, value: Any) -> None: ...
def __delete__(self, obj: Any) -> None: ...
def fget(self) -> Any: ...
@@ -716,7 +716,7 @@ def filter(function: Callable[[_T], Any],
def filter(function: None,
iterable: Iterable[Optional[_T]]) -> List[_T]: ...
def format(o: object, format_spec: str = '') -> str: ... # TODO unicode
def getattr(o: Any, name: unicode, default: Any = None) -> Any: ...
def getattr(o: Any, name: unicode, default: Optional[Any] = None) -> Any: ...
def hasattr(o: Any, name: unicode) -> bool: ...
def hash(o: object) -> int: ...
def hex(i: int) -> str: ... # TODO __index__
@@ -941,12 +941,12 @@ class ResourceWarning(Warning): ...
def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ...
def exec(object: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> Any: ... # TODO code object as source
globals: Optional[Dict[str, Any]] = None,
locals: Optional[Dict[str, Any]] = None) -> Any: ... # TODO code object as source
def cmp(x: Any, y: Any) -> int: ...
def execfile(filename: str, globals: Dict[str, Any] = None, locals: Dict[str, Any] = None) -> None: ...
def execfile(filename: str, globals: Optional[Dict[str, Any]] = None, locals: Optional[Dict[str, Any]] = None) -> None: ...
class file(BinaryIO):
@overload
@@ -958,7 +958,7 @@ class file(BinaryIO):
def __iter__(self) -> Iterator[str]: ...
def read(self, n: int = ...) -> str: ...
def __enter__(self) -> BinaryIO: ...
def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ...
def __exit__(self, t: Optional[type] = None, exc: Optional[BaseException] = None, tb: Optional[Any] = None) -> bool: ...
def flush(self) -> None: ...
def fileno(self) -> int: ...
def isatty(self) -> bool: ...
@@ -976,6 +976,6 @@ class file(BinaryIO):
def truncate(self, pos: Optional[int] = ...) -> int: ...
# Very old builtins
def apply(func: Callable[..., _T], args: Sequence[Any] = None, kwds: Mapping[str, Any] = None) -> _T: ...
def apply(func: Callable[..., _T], args: Optional[Sequence[Any]] = None, kwds: Optional[Mapping[str, Any]] = None) -> _T: ...
_N = TypeVar('_N', bool, int, float, complex)
def coerce(x: _N, y: _N) -> Tuple[_N, _N]: ...

View File

@@ -41,7 +41,7 @@ class Request(object):
def add_header(self, key: str, val: str) -> None: ...
def add_unredirected_header(self, key: str, val: str) -> None: ...
def has_header(self, header_name: str) -> bool: ...
def get_header(self, header_name: str, default: str = None) -> str: ...
def get_header(self, header_name: str, default: Optional[str] = None) -> str: ...
def header_items(self): ...
class OpenerDirector(object):

View File

@@ -2,7 +2,7 @@ from abc import abstractmethod
import asyncore
import socket
import sys
from typing import Union, Tuple, Sequence
from typing import Optional, Sequence, Tuple, Union
class simple_producer:
@@ -12,7 +12,7 @@ class simple_producer:
class async_chat(asyncore.dispatcher):
ac_in_buffer_size = ... # type: int
ac_out_buffer_size = ... # type: int
def __init__(self, sock: socket.socket = None, map: asyncore._maptype = None) -> None: ...
def __init__(self, sock: Optional[socket.socket] = None, map: Optional[asyncore._maptype] = None) -> None: ...
@abstractmethod
def collect_incoming_data(self, data: bytes) -> None: ...

View File

@@ -25,7 +25,7 @@ def poll2(timeout: float = ..., map: _maptype = ...) -> None: ...
poll3 = poll2
def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: int = None) -> None: ...
def loop(timeout: float = ..., use_poll: bool = ..., map: _maptype = ..., count: Optional[int] = None) -> None: ...
# Not really subclass of socket.socket; it's only delegation.
@@ -39,7 +39,7 @@ class dispatcher:
closing = ... # type: bool
ignore_log_types = ... # type: frozenset[str]
def __init__(self, sock: socket.socket = None, map: _maptype = ...) -> None: ...
def __init__(self, sock: Optional[socket.socket] = None, map: _maptype = ...) -> None: ...
def add_channel(self, map: _maptype = ...) -> None: ...
def del_channel(self, map: _maptype = ...) -> None: ...
def create_socket(self, family: int, type: int) -> None: ...

View File

@@ -1,21 +1,21 @@
# Stubs for bz2
from typing import Any, BinaryIO, TextIO, IO, Union
from typing import Any, BinaryIO, TextIO, IO, Optional, Union
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...
def open(filename: Union[str, bytes, IO[Any]],
mode: str = 'rb',
encoding: str = None,
errors: str = None,
newline: str = None) -> IO[Any]: ...
encoding: Optional[str] = None,
errors: Optional[str] = None,
newline: Optional[str] = None) -> IO[Any]: ...
class BZ2File(BinaryIO):
def __init__(self,
filename: Union[str, bytes, IO[Any]],
mode: str = "r",
buffering: Any = None,
buffering: Optional[Any] = None,
compresslevel: int = 9) -> None: ...
class BZ2Compressor(object):

View File

@@ -1,15 +1,15 @@
# NOTE: This stub is incomplete - only contains some global functions
from typing import Any, Dict
from typing import Any, Dict, Optional
def run(statement: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> None:
globals: Optional[Dict[str, Any]] = None,
locals: Optional[Dict[str, Any]] = None) -> None:
...
def runeval(expression: str,
globals: Dict[str, Any] = None,
locals: Dict[str, Any] = None) -> Any:
globals: Optional[Dict[str, Any]] = None,
locals: Optional[Dict[str, Any]] = None) -> Any:
...
def runctx(statement: str,
@@ -23,7 +23,7 @@ def runcall(*args: Any, **kwds: Any) -> Any:
def set_trace() -> None:
...
def post_mortem(t: Any = None) -> None:
def post_mortem(t: Optional[Any] = None) -> None:
...
def pm() -> None:

View File

@@ -24,6 +24,13 @@ parser.add_argument('-n', '--dry-run', action='store_true', help="Don't actually
parser.add_argument('-x', '--exclude', type=str, nargs='*', help="Exclude pattern")
parser.add_argument('-p', '--python-version', type=str, nargs='*',
help="These versions only (major[.minor])")
parser.add_argument('--no-implicit-optional', action='store_true',
help="Run mypy with --no-implicit-optional (causes lots of errors)")
parser.add_argument('--warn-unused-ignores', action='store_true',
help="Run mypy with --warn-unused-ignores "
"(hint: only git rid of warnings that are "
"unused for all platforms and Python versions)")
parser.add_argument('filter', type=str, nargs='*', help="Include pattern (default all)")
@@ -124,7 +131,10 @@ def main():
runs += 1
flags = ['--python-version', '%d.%d' % (major, minor)]
flags.append('--strict-optional')
# flags.append('--warn-unused-ignores') # Fast parser and regular parser disagree.
if args.no_implicit_optional:
flags.append('--no-implicit-optional')
if args.warn_unused_ignores:
flags.append('--warn-unused-ignores')
sys.argv = ['mypy'] + flags + files
if args.verbose:
print("running", ' '.join(sys.argv))

View File

@@ -27,13 +27,13 @@ class parserinfo(object):
def validate(self, res: datetime) -> bool: ...
class parser(object):
def __init__(self, info: parserinfo = None) -> None: ...
def __init__(self, info: Optional[parserinfo] = None) -> None: ...
def parse(self, timestr: Union[str, unicode, IO[unicode]],
default: datetime = None,
ignoretz: bool = ..., tzinfos: Dict[Union[str, unicode], tzinfo] = None,
default: Optional[datetime] = None,
ignoretz: bool = ..., tzinfos: Optional[Dict[Union[str, unicode], tzinfo]] = None,
**kwargs: Any) -> datetime: ...
DEFAULTPARSER = ... # type: parser
def parse(timestr: Union[str, unicode, IO[unicode]],
parserinfo: parserinfo = None,
parserinfo: Optional[parserinfo] = None,
**kwargs: Any) -> datetime: ...

View File

@@ -6,7 +6,7 @@ from .descriptor_pool import DescriptorPool
class MessageFactory:
pool = ... # type: Any
def __init__(self, pool: DescriptorPool=None) -> None: ...
def __init__(self, pool: Optional[DescriptorPool] = None) -> None: ...
def GetPrototype(self, descriptor: Descriptor) -> Type[Message]: ...
def GetMessages(self, files: Iterable[str]) -> Dict[str, Type[Message]]: ...

View File

@@ -76,7 +76,15 @@ class BaseResponse:
status = ... # type: str
direct_passthrough = ... # type: bool
response = ... # type: Iterable[str]
def __init__(self, response: Union[Iterable[str], str]=None, status=Union[basestring, int], headers: Union[Headers, Mapping[basestring, basestring], Sequence[Tuple[basestring, basestring]]]=None, mimetype: basestring=None, content_type: basestring=None, direct_passthrough: bool=False) -> None: ...
def __init__(self,
response: Optional[Union[Iterable[str], str]] = None,
status: Optional[Union[basestring, int]] = None,
headers: Optional[Union[Headers,
Mapping[basestring, basestring],
Sequence[Tuple[basestring, basestring]]]] = None,
mimetype: Optional[basestring] = None,
content_type: Optional[basestring] = None,
direct_passthrough: Optional[bool] = False) -> None: ...
def call_on_close(self, func): ...
@classmethod
def force_type(cls, response, environ=None): ...

View File

@@ -1,7 +1,7 @@
import os
import sys
import tempfile
from typing import Any, AnyStr, Callable, ContextManager, IO, Iterator, Text
from typing import Any, AnyStr, Callable, ContextManager, IO, Iterator, Optional, Text
def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ...
def move_atomic(src: AnyStr, dst: AnyStr) -> None: ...
@@ -9,7 +9,7 @@ class AtomicWriter(object):
def __init__(self, path: AnyStr, mode: Text='w', overwrite: bool=False) -> None: ...
def open(self) -> ContextManager[IO]: ...
def _open(self, get_fileobject: Callable) -> ContextManager[IO]: ...
def get_fileobject(self, dir: AnyStr=None, **kwargs) -> IO: ...
def get_fileobject(self, dir: Optional[AnyStr] = None, **kwargs) -> IO: ...
def sync(self, f: IO) -> None: ...
def commit(self, f: IO) -> None: ...
def rollback(self, f: IO) -> None: ...

View File

@@ -1,3 +1,5 @@
from typing import Optional
from .connection import S3Connection
from boto.connection import AWSAuthConnection
@@ -6,7 +8,7 @@ from boto.regioninfo import RegionInfo
from typing import List, Type, Text
class S3RegionInfo(RegionInfo):
def connect(self, name: Text=None, endpoint: str=None, connection_cls: Type[AWSAuthConnection]=None, **kw_params) -> S3Connection: ...
def connect(self, name: Optional[Text] = None, endpoint: Optional[str] = None, connection_cls: Optional[Type[AWSAuthConnection]] = None, **kw_params) -> S3Connection: ...
def regions() -> List[S3RegionInfo]: ...
def connect_to_region(region_name: Text, **kw_params): ...

View File

@@ -30,7 +30,7 @@ def invoke_param_callback(
@contextmanager
def augment_usage_errors(
ctx: 'Context', param: 'Parameter' = None
ctx: 'Context', param: Optional['Parameter'] = None
) -> Generator[None, None, None]:
...
@@ -73,20 +73,20 @@ class Context:
def __init__(
self,
command: 'Command',
parent: 'Context' = None,
info_name: str = None,
obj: Any = None,
auto_envvar_prefix: str = None,
default_map: Mapping[str, Any] = None,
terminal_width: int = None,
max_content_width: int = None,
parent: Optional['Context'] = None,
info_name: Optional[str] = None,
obj: Optional[Any] = None,
auto_envvar_prefix: Optional[str] = None,
default_map: Optional[Mapping[str, Any]] = None,
terminal_width: Optional[int] = None,
max_content_width: Optional[int] = None,
resilient_parsing: bool = False,
allow_extra_args: bool = None,
allow_interspersed_args: bool = None,
ignore_unknown_options: bool = None,
help_option_names: List[str] = None,
token_normalize_func: Callable[[str], str] = None,
color: bool = None
allow_extra_args: Optional[bool] = None,
allow_interspersed_args: Optional[bool] = None,
ignore_unknown_options: Optional[bool] = None,
help_option_names: Optional[List[str]] = None,
token_normalize_func: Optional[Callable[[str], str]] = None,
color: Optional[bool] = None
) -> None:
...
@@ -147,7 +147,7 @@ class BaseCommand:
name: str
context_settings: Dict
def __init__(self, name: str, context_settings: Dict = None) -> None:
def __init__(self, name: str, context_settings: Optional[Dict] = None) -> None:
...
def get_usage(self, ctx: Context) -> str:
@@ -157,7 +157,7 @@ class BaseCommand:
...
def make_context(
self, info_name: str, args: List[str], parent: Context = None, **extra
self, info_name: str, args: List[str], parent: Optional[Context] = None, **extra
) -> Context:
...
@@ -169,9 +169,9 @@ class BaseCommand:
def main(
self,
args: List[str] = None,
prog_name: str = None,
complete_var: str = None,
args: Optional[List[str]] = None,
prog_name: Optional[str] = None,
complete_var: Optional[str] = None,
standalone_mode: bool = True,
**extra
) -> Any:
@@ -193,12 +193,12 @@ class Command(BaseCommand):
def __init__(
self,
name: str,
context_settings: Dict = None,
callback: Callable = None,
params: List['Parameter'] = None,
help: str = None,
epilog: str = None,
short_help: str = None,
context_settings: Optional[Dict] = None,
callback: Optional[Callable] = None,
params: Optional[List['Parameter']] = None,
help: Optional[str] = None,
epilog: Optional[str] = None,
short_help: Optional[str] = None,
options_metavar: str = '[OPTIONS]',
add_help_option: bool = True
) -> None:
@@ -252,12 +252,12 @@ class MultiCommand(Command):
def __init__(
self,
name: str = None,
name: Optional[str] = None,
invoke_without_command: bool = False,
no_args_is_help: bool = None,
subcommand_metavar: str = None,
no_args_is_help: Optional[bool] = None,
subcommand_metavar: Optional[str] = None,
chain: bool = False,
result_callback: Callable = None,
result_callback: Optional[Callable] = None,
**attrs
) -> None:
...
@@ -286,11 +286,11 @@ class Group(MultiCommand):
commands: Dict[str, Command]
def __init__(
self, name: str = None, commands: Dict[str, Command] = None, **attrs
self, name: Optional[str] = None, commands: Optional[Dict[str, Command]] = None, **attrs
) -> None:
...
def add_command(self, cmd: Command, name: str = None):
def add_command(self, cmd: Command, name: Optional[str] = None):
...
def command(self, *args, **kwargs) -> _Decorator:
@@ -304,7 +304,7 @@ class CommandCollection(MultiCommand):
sources: List[MultiCommand]
def __init__(
self, name: str = None, sources: List[MultiCommand] = None, **attrs
self, name: Optional[str] = None, sources: Optional[List[MultiCommand]] = None, **attrs
) -> None:
...
@@ -332,16 +332,16 @@ class Parameter:
def __init__(
self,
param_decls: List[str] = None,
type: Union[type, 'ParamType'] = None,
param_decls: Optional[List[str]] = None,
type: Optional[Union[type, 'ParamType']] = None,
required: bool = False,
default: Any = None,
callback: Callable[[Context, 'Parameter', str], Any] = None,
nargs: int = None,
metavar: str = None,
default: Optional[Any] = None,
callback: Optional[Callable[[Context, 'Parameter', str], Any]] = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> None:
...
@@ -402,18 +402,18 @@ class Option(Parameter):
def __init__(
self,
param_decls: List[str] = None,
param_decls: Optional[List[str]] = None,
show_default: bool = False,
prompt: Union[bool, str] = False,
confirmation_prompt: bool = False,
hide_input: bool = False,
is_flag: bool = None,
flag_value: Any = None,
is_flag: Optional[bool] = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, 'ParamType'] = None,
help: str = None,
type: Optional[Union[type, 'ParamType']] = None,
help: Optional[str] = None,
**attrs
) -> None:
...
@@ -425,8 +425,8 @@ class Option(Parameter):
class Argument(Parameter):
def __init__(
self,
param_decls: List[str] = None,
required: bool = None,
param_decls: Optional[List[str]] = None,
required: Optional[bool] = None,
**attrs
) -> None:
...

View File

@@ -30,13 +30,13 @@ def make_pass_decorator(
# arguments from core.pyi to help with type checking.
def command(
name: str = None,
name: Optional[str] = None,
cls: type = Command,
# Command
context_settings: Optional[Dict] = ...,
help: str = None,
epilog: str = None,
short_help: str = None,
help: Optional[str] = None,
epilog: Optional[str] = None,
short_help: Optional[str] = None,
options_metavar: str = '[OPTIONS]',
add_help_option: bool = True,
) -> _Decorator:
@@ -46,20 +46,20 @@ def command(
# This inherits attrs from Group, MultiCommand and Command.
def group(
name: str = None,
name: Optional[str] = None,
cls: type = Group,
# Group
commands: Dict[str, Command] = None,
commands: Optional[Dict[str, Command]] = None,
# MultiCommand
invoke_without_command: bool = False,
no_args_is_help: bool = None,
subcommand_metavar: str = None,
no_args_is_help: Optional[bool] = None,
subcommand_metavar: Optional[str] = None,
chain: bool = False,
result_callback: Callable = None,
result_callback: Optional[Callable] = None,
# Command
help: str = None,
epilog: str = None,
short_help: str = None,
help: Optional[str] = None,
epilog: Optional[str] = None,
short_help: Optional[str] = None,
options_metavar: str = '[OPTIONS]',
add_help_option: bool = True,
# User-defined
@@ -72,16 +72,16 @@ def argument(
*param_decls: str,
cls: type = Argument,
# Argument
required: bool = None,
required: Optional[bool] = None,
# Parameter
type: Union[type, ParamType] = None,
default: Any = None,
type: Optional[Union[type, ParamType]] = None,
default: Optional[Any] = None,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...
@@ -94,22 +94,22 @@ def option(
prompt: bool = False,
confirmation_prompt: bool = False,
hide_input: bool = False,
is_flag: bool = None,
flag_value: Any = None,
is_flag: Optional[bool] = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, ParamType] = None,
help: str = None,
type: Optional[Union[type, ParamType]] = None,
help: Optional[str] = None,
# Parameter
default: Any = None,
default: Optional[Any] = None,
required: bool = False,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...
@@ -124,20 +124,20 @@ def confirmation_option(
confirmation_prompt: bool = False,
hide_input: bool = False,
is_flag: bool = True,
flag_value: Any = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, ParamType] = None,
type: Optional[Union[type, ParamType]] = None,
help: str = 'Confirm the action without prompting.',
# Parameter
default: Any = None,
default: Optional[Any] = None,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = False,
is_eager: bool = False,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...
@@ -151,51 +151,51 @@ def password_option(
prompt: bool = True,
confirmation_prompt: bool = True,
hide_input: bool = True,
is_flag: bool = None,
flag_value: Any = None,
is_flag: Optional[bool] = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, ParamType] = None,
help: str = None,
type: Optional[Union[type, ParamType]] = None,
help: Optional[str] = None,
# Parameter
default: Any = None,
default: Optional[Any] = None,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = True,
is_eager: bool = False,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...
# Defaults copied from the decorator body.
def version_option(
version: Union[str, Version] = None,
version: Optional[Union[str, Version]] = None,
*param_decls: str,
cls: type = Option,
# Option
prog_name: str = None,
prog_name: Optional[str] = None,
show_default: bool = False,
prompt: bool = False,
confirmation_prompt: bool = False,
hide_input: bool = False,
is_flag: bool = True,
flag_value: Any = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, ParamType] = None,
type: Optional[Union[type, ParamType]] = None,
help: str = 'Show the version and exit.',
# Parameter
default: Any = None,
default: Optional[Any] = None,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = False,
is_eager: bool = True,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...
@@ -210,19 +210,19 @@ def help_option(
confirmation_prompt: bool = False,
hide_input: bool = False,
is_flag: bool = True,
flag_value: Any = None,
flag_value: Optional[Any] = None,
multiple: bool = False,
count: bool = False,
allow_from_autoenv: bool = True,
type: Union[type, ParamType] = None,
type: Optional[Union[type, ParamType]] = None,
help: str = 'Show this message and exit.',
# Parameter
default: Any = None,
default: Optional[Any] = None,
callback: Optional[_Callback] = ...,
nargs: int = None,
metavar: str = None,
nargs: Optional[int] = None,
metavar: Optional[str] = None,
expose_value: bool = False,
is_eager: bool = True,
envvar: Union[str, List[str]] = None
envvar: Optional[Union[str, List[str]]] = None
) -> _Decorator:
...

View File

@@ -20,10 +20,10 @@ class ClickException(Exception):
class UsageError(ClickException):
ctx: Optional[Context]
def __init__(self, message: str, ctx: Context = None) -> None:
def __init__(self, message: str, ctx: Optional[Context] = None) -> None:
...
def show(self, file: IO = None) -> None:
def show(self, file: Optional[IO] = None) -> None:
...
@@ -34,9 +34,9 @@ class BadParameter(UsageError):
def __init__(
self,
message: str,
ctx: Context = None,
param: Parameter = None,
param_hint: str = None
ctx: Optional[Context] = None,
param: Optional[Parameter] = None,
param_hint: Optional[str] = None
) -> None:
...
@@ -46,11 +46,11 @@ class MissingParameter(BadParameter):
def __init__(
self,
message: str = None,
ctx: Context = None,
param: Parameter = None,
param_hint: str = None,
param_type: str = None
message: Optional[str] = None,
ctx: Optional[Context] = None,
param: Optional[Parameter] = None,
param_hint: Optional[str] = None,
param_type: Optional[str] = None
) -> None:
...
@@ -62,20 +62,20 @@ class NoSuchOption(UsageError):
def __init__(
self,
option_name: str,
message: str = None,
possibilities: List[str] = None,
ctx: Context = None
message: Optional[str] = None,
possibilities: Optional[List[str]] = None,
ctx: Optional[Context] = None
) -> None:
...
class BadOptionUsage(UsageError):
def __init__(self, message: str, ctx: Context = None) -> None:
def __init__(self, message: str, ctx: Optional[Context] = None) -> None:
...
class BadArgumentUsage(UsageError):
def __init__(self, message: str, ctx: Context = None) -> None:
def __init__(self, message: str, ctx: Optional[Context] = None) -> None:
...
@@ -83,7 +83,7 @@ class FileError(ClickException):
ui_filename: str
filename: str
def __init__(self, filename: str, hint: str = None) -> None:
def __init__(self, filename: str, hint: Optional[str] = None) -> None:
...

View File

@@ -34,8 +34,8 @@ class HelpFormatter:
def __init__(
self,
indent_increment: int = 2,
width: int = None,
max_width: int = None,
width: Optional[int] = None,
max_width: Optional[int] = None,
) -> None:
...

View File

@@ -13,5 +13,5 @@ def pop_context() -> None:
...
def resolve_color_default(color: bool = None) -> Optional[bool]:
def resolve_color_default(color: Optional[bool] = None) -> Optional[bool]:
...

View File

@@ -37,10 +37,10 @@ class Option:
self,
opts: Iterable[str],
dest: str,
action: str = None,
action: Optional[str] = None,
nargs: int = 1,
const: Any = None,
obj: Any = None
const: Optional[Any] = None,
obj: Optional[Any] = None
) -> None:
...
@@ -53,7 +53,7 @@ class Argument:
nargs: int
obj: Any
def __init__(self, dest: str, nargs: int = 1, obj: Any = None) -> None:
def __init__(self, dest: str, nargs: int = 1, obj: Optional[Any] = None) -> None:
...
def process(self, value: Any, state: 'ParsingState') -> None:
@@ -79,21 +79,21 @@ class OptionParser:
_opt_prefixes: Set[str]
_args: List[Argument]
def __init__(self, ctx: Context = None) -> None:
def __init__(self, ctx: Optional[Context] = None) -> None:
...
def add_option(
self,
opts: Iterable[str],
dest: str,
action: str = None,
action: Optional[str] = None,
nargs: int = 1,
const: Any = None,
obj: Any = None
const: Optional[Any] = None,
obj: Optional[Any] = None
) -> None:
...
def add_argument(self, dest: str, nargs: int = 1, obj: Any = None) -> None:
def add_argument(self, dest: str, nargs: int = 1, obj: Optional[Any] = None) -> None:
...
def parse_args(

View File

@@ -20,18 +20,18 @@ def _build_prompt(
text: str,
suffix: str,
show_default: bool = False,
default: str = None,
default: Optional[str] = None,
) -> str:
...
def prompt(
text: str,
default: str = None,
default: Optional[str] = None,
hide_input: bool = False,
confirmation_prompt: bool = False,
type: Any = None,
value_proc: Callable[[Optional[str]], Any] = None,
type: Optional[Any] = None,
value_proc: Optional[Callable[[Optional[str]], Any]] = None,
prompt_suffix: str = ': ',
show_default: bool = True,
err: bool = False,
@@ -54,7 +54,7 @@ def get_terminal_size() -> Tuple[int, int]:
...
def echo_via_pager(text: str, color: bool = None) -> None:
def echo_via_pager(text: str, color: Optional[bool] = None) -> None:
...
@@ -63,20 +63,20 @@ _T = TypeVar('_T')
@contextmanager
def progressbar(
iterable: Optional[Iterable[_T]] = None,
length: int = None,
label: str = None,
iterable: Optional[Optional[Iterable[_T]]] = None,
length: Optional[int] = None,
label: Optional[str] = None,
show_eta: bool = True,
show_percent: bool = None,
show_percent: Optional[bool] = None,
show_pos: bool = False,
item_show_func: Callable[[_T], str] = None,
item_show_func: Optional[Callable[[_T], str]] = None,
fill_char: str = '#',
empty_char: str = '-',
bar_template: str = '%(label)s [%(bar)s] %(info)s',
info_sep: str = ' ',
width: int = 36,
file: IO = None,
color: bool = None,
file: Optional[IO] = None,
color: Optional[bool] = None,
) -> Generator[_T, None, None]:
...
@@ -87,13 +87,13 @@ def clear() -> None:
def style(
text: str,
fg: str = None,
bg: str = None,
bold: bool = None,
dim: bool = None,
underline: bool = None,
blink: bool = None,
reverse: bool = None,
fg: Optional[str] = None,
bg: Optional[str] = None,
bold: Optional[bool] = None,
dim: Optional[bool] = None,
underline: Optional[bool] = None,
blink: Optional[bool] = None,
reverse: Optional[bool] = None,
reset: bool = True,
):
...
@@ -106,29 +106,29 @@ def unstyle(text: str) -> str:
# Styling options copied from style() for nicer type checking.
def secho(
text: str,
file: IO = None,
file: Optional[IO] = None,
nl: bool =True,
err: bool = False,
color: bool = None,
fg: str = None,
bg: str = None,
bold: bool = None,
dim: bool = None,
underline: bool = None,
blink: bool = None,
reverse: bool = None,
color: Optional[bool] = None,
fg: Optional[str] = None,
bg: Optional[str] = None,
bold: Optional[bool] = None,
dim: Optional[bool] = None,
underline: Optional[bool] = None,
blink: Optional[bool] = None,
reverse: Optional[bool] = None,
reset: bool = True,
):
...
def edit(
text: str = None,
editor: str = None,
env: str = None,
text: Optional[str] = None,
editor: Optional[str] = None,
env: Optional[str] = None,
require_save: bool = True,
extension: str = '.txt',
filename: str = None,
filename: Optional[str] = None,
) -> str:
...

View File

@@ -12,8 +12,8 @@ class ParamType:
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> Any:
...
@@ -34,7 +34,7 @@ class ParamType:
def split_envvar_value(self, rv: str) -> List[str]:
...
def fail(self, message: str, param: Parameter = None, ctx: Context = None) -> None:
def fail(self, message: str, param: Optional[Parameter] = None, ctx: Optional[Context] = None) -> None:
...
@@ -42,8 +42,8 @@ class BoolParamType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> bool:
...
@@ -70,8 +70,8 @@ class FloatParamType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> float:
...
@@ -92,18 +92,18 @@ class File(ParamType):
def __init__(
self,
mode: str = 'r',
encoding: str = None,
errors: str = None,
lazy: bool = None,
atomic: bool = None,
encoding: Optional[str] = None,
errors: Optional[str] = None,
lazy: Optional[bool] = None,
atomic: Optional[bool] = None,
) -> None:
...
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> IO:
...
@@ -132,8 +132,8 @@ class FuncParamType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> _F:
...
@@ -150,8 +150,8 @@ class IntParamType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> int:
...
@@ -166,7 +166,7 @@ class IntParamType(ParamType):
class IntRange(IntParamType):
def __init__(
self, min: int = None, max: int = None, clamp: bool = False
self, min: Optional[int] = None, max: Optional[int] = None, clamp: bool = False
) -> None:
...
@@ -184,7 +184,7 @@ class Path(ParamType):
readable: bool = True,
resolve_path: bool = False,
allow_dash: bool = False,
path_type: _PathType = None,
path_type: Optional[_PathType] = None,
) -> None:
...
@@ -194,8 +194,8 @@ class Path(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> _PathType:
...
@@ -211,8 +211,8 @@ class StringParamType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> str:
...
@@ -234,8 +234,8 @@ class Tuple(CompositeParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> Tuple:
...
@@ -256,8 +256,8 @@ class UUIDParameterType(ParamType):
def __call__(
self,
value: Optional[str],
param: Parameter = None,
ctx: Context = None,
param: Optional[Parameter] = None,
ctx: Optional[Context] = None,
) -> uuid.UUID:
...
@@ -270,7 +270,7 @@ class UUIDParameterType(ParamType):
...
def convert_type(ty: Any, default: Any = None) -> ParamType:
def convert_type(ty: Any, default: Optional[Any] = None) -> ParamType:
...
# parameter type shortcuts

View File

@@ -32,7 +32,7 @@ class LazyFile:
self,
filename: str,
mode: str = 'r',
encoding: str = None,
encoding: Optional[str] = None,
errors: str = 'strict',
atomic: bool = False
) -> None:
@@ -74,11 +74,11 @@ class KeepOpenFile:
def echo(
message: str = None,
file: IO = None,
message: Optional[str] = None,
file: Optional[IO] = None,
nl: bool = True,
err: bool = False,
color: bool = None,
color: Optional[bool] = None,
) -> None:
...
@@ -88,7 +88,7 @@ def get_binary_stream(name: str) -> IO[bytes]:
def get_text_stream(
name: str, encoding: str = None, errors: str = 'strict'
name: str, encoding: Optional[str] = None, errors: str = 'strict'
) -> IO[str]:
...
@@ -96,7 +96,7 @@ def get_text_stream(
def open_file(
filename: str,
mode: str = 'r',
encoding: str = None,
encoding: Optional[str] = None,
errors: str = 'strict',
lazy: bool = False,
atomic: bool = False

View File

@@ -16,8 +16,8 @@ class Markup(text_type):
def __rmul__(self, num: int) -> Markup: ...
def __mod__(self, *args: Any) -> Markup: ...
def join(self, seq: Iterable[text_type]): ...
def split(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ...
def rsplit(self, sep: text_type = None, maxsplit: int = -1) -> List[text_type]: ...
def split(self, sep: Optional[text_type] = None, maxsplit: int = -1) -> List[text_type]: ...
def rsplit(self, sep: Optional[text_type] = None, maxsplit: int = -1) -> List[text_type]: ...
def splitlines(self, keepends: bool = ...) -> List[text_type]: ...
def unescape(self) -> Text: ...
def striptags(self) -> Text: ...
@@ -37,9 +37,9 @@ class Markup(text_type):
def replace(self, old: text_type, new: text_type, count: int = -1) -> Markup: ...
def ljust(self, width: int, fillchar: text_type = ...) -> Markup: ...
def rjust(self, width: int, fillchar: text_type = ...) -> Markup: ...
def lstrip(self, chars: text_type = None) -> Markup: ...
def rstrip(self, chars: text_type = None) -> Markup: ...
def strip(self, chars: text_type = None) -> Markup: ...
def lstrip(self, chars: Optional[text_type] = None) -> Markup: ...
def rstrip(self, chars: Optional[text_type] = None) -> Markup: ...
def strip(self, chars: Optional[text_type] = None) -> Markup: ...
def center(self, width: int, fillchar: text_type = ...) -> Markup: ...
def zfill(self, width: int) -> Markup: ...
def translate(self, table: Union[Dict[int, Any], text_type]) -> Markup: ...

View File

@@ -22,7 +22,7 @@ class Cursor:
def executemany(self, query: str, args) -> int: ...
def callproc(self, procname, args=...): ...
def fetchone(self) -> Optional[Gen]: ...
def fetchmany(self, size: int = None) -> Optional[Gen]: ...
def fetchmany(self, size: Optional[int] = None) -> Optional[Gen]: ...
def fetchall(self) -> Optional[Tuple[Gen, ...]]: ...
def scroll(self, value, mode=''): ...
def __iter__(self): ...