mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
Make pytype happy with the third_party click stubs. (#2966)
This also makes the flask stubs that depend on click parseable. * In pytype_test, only parse files with the .pyi extension. (There's a README in third_party/2and3/click/.) * Annotate with ContextManager rather than using the contextmanager decorator. This is shorter, removes a dependency, and gets rid of the slight weirdness of a decorator needing to be evaluated in a stub. * Fix non-stub things.
This commit is contained in:
committed by
Sebastian Rittau
parent
5dda362b05
commit
4990830c8f
@@ -20,30 +20,7 @@ third_party/2and3/attr/converters.pyi
|
||||
third_party/2and3/attr/filters.pyi
|
||||
third_party/2and3/attr/validators.pyi
|
||||
third_party/2and3/boto/utils.pyi
|
||||
third_party/2and3/click/README.md
|
||||
third_party/2and3/click/__init__.pyi
|
||||
third_party/2and3/click/core.pyi
|
||||
third_party/2and3/click/decorators.pyi
|
||||
third_party/2and3/click/exceptions.pyi
|
||||
third_party/2and3/click/formatting.pyi
|
||||
third_party/2and3/click/globals.pyi
|
||||
third_party/2and3/click/parser.pyi
|
||||
third_party/2and3/click/termui.pyi
|
||||
third_party/2and3/click/testing.pyi
|
||||
third_party/2and3/click/types.pyi
|
||||
third_party/2and3/dateutil/rrule.pyi
|
||||
third_party/2and3/flask/__init__.pyi
|
||||
third_party/2and3/flask/app.pyi
|
||||
third_party/2and3/flask/blueprints.pyi
|
||||
third_party/2and3/flask/cli.pyi
|
||||
third_party/2and3/flask/ctx.pyi
|
||||
third_party/2and3/flask/debughelpers.pyi
|
||||
third_party/2and3/flask/globals.pyi
|
||||
third_party/2and3/flask/helpers.pyi
|
||||
third_party/2and3/flask/logging.pyi
|
||||
third_party/2and3/flask/templating.pyi
|
||||
third_party/2and3/flask/testing.pyi
|
||||
third_party/2and3/flask/views.pyi
|
||||
third_party/2and3/google/protobuf/any_pb2.pyi
|
||||
third_party/2and3/google/protobuf/any_test_pb2.pyi
|
||||
third_party/2and3/google/protobuf/api_pb2.pyi
|
||||
|
||||
@@ -172,7 +172,7 @@ def pytype_test(args):
|
||||
|
||||
for root, _, filenames in itertools.chain.from_iterable(
|
||||
os.walk(p) for p in paths):
|
||||
for f in sorted(filenames):
|
||||
for f in sorted(f for f in filenames if f.endswith('.pyi')):
|
||||
f = os.path.join(root, f)
|
||||
rel = _get_relative(f)
|
||||
if not skipped.search(rel):
|
||||
|
||||
4
third_party/2and3/click/README.md
vendored
4
third_party/2and3/click/README.md
vendored
@@ -1,7 +1,7 @@
|
||||
# click 6.6, Python 3
|
||||
|
||||
`__init__.pyi` is literally a copy of click/__init__.py. It's a shortcut module
|
||||
anyway in the actual sources so it works well without additional changes.
|
||||
`__init__.pyi` is almost a copy of `click/__init__.py`. It's a shortcut module
|
||||
anyway in the actual sources so it works well with minimal changes.
|
||||
|
||||
The types are pretty complete but they were created mostly for public API use
|
||||
so some internal modules (`_compat`) or functions (`core._bashcomplete`) are
|
||||
|
||||
44
third_party/2and3/click/__init__.pyi
vendored
44
third_party/2and3/click/__init__.pyi
vendored
@@ -108,49 +108,9 @@ from .formatting import HelpFormatter as HelpFormatter, wrap_text as wrap_text
|
||||
# Parsing
|
||||
from .parser import OptionParser as OptionParser
|
||||
|
||||
|
||||
__all__ = [
|
||||
# Core classes
|
||||
'Context', 'BaseCommand', 'Command', 'MultiCommand', 'Group',
|
||||
'CommandCollection', 'Parameter', 'Option', 'Argument',
|
||||
|
||||
# Globals
|
||||
'get_current_context',
|
||||
|
||||
# Decorators
|
||||
'pass_context', 'pass_obj', 'make_pass_decorator', 'command', 'group',
|
||||
'argument', 'option', 'confirmation_option', 'password_option',
|
||||
'version_option', 'help_option',
|
||||
|
||||
# Types
|
||||
'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'Tuple', 'STRING',
|
||||
'INT', 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED',
|
||||
|
||||
# Utilities
|
||||
'echo', 'get_binary_stream', 'get_text_stream', 'open_file',
|
||||
'format_filename', 'get_app_dir', 'get_os_args',
|
||||
|
||||
# Terminal functions
|
||||
'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager',
|
||||
'progressbar', 'clear', 'style', 'unstyle', 'secho', 'edit', 'launch',
|
||||
'getchar', 'pause',
|
||||
|
||||
# Exceptions
|
||||
'ClickException', 'UsageError', 'BadParameter', 'FileError',
|
||||
'Abort', 'NoSuchOption', 'BadOptionUsage', 'BadArgumentUsage',
|
||||
'MissingParameter',
|
||||
|
||||
# Formatting
|
||||
'HelpFormatter', 'wrap_text',
|
||||
|
||||
# Parsing
|
||||
'OptionParser',
|
||||
]
|
||||
|
||||
|
||||
# Controls if click should emit the warning about the use of unicode
|
||||
# literals.
|
||||
disable_unicode_literals_warning = False
|
||||
disable_unicode_literals_warning: bool
|
||||
|
||||
|
||||
__version__ = '6.6'
|
||||
__version__: str
|
||||
|
||||
8
third_party/2and3/click/core.pyi
vendored
8
third_party/2and3/click/core.pyi
vendored
@@ -1,7 +1,7 @@
|
||||
from contextlib import contextmanager
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Generator,
|
||||
Iterable,
|
||||
@@ -28,10 +28,9 @@ def invoke_param_callback(
|
||||
...
|
||||
|
||||
|
||||
@contextmanager
|
||||
def augment_usage_errors(
|
||||
ctx: Context, param: Optional[Parameter] = ...
|
||||
) -> Generator[None, None, None]:
|
||||
) -> ContextManager[None]:
|
||||
...
|
||||
|
||||
|
||||
@@ -90,8 +89,7 @@ class Context:
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@contextmanager
|
||||
def scope(self, cleanup: bool = ...) -> Generator[Context, None, None]:
|
||||
def scope(self, cleanup: bool = ...) -> ContextManager[Context]:
|
||||
...
|
||||
|
||||
def make_formatter(self) -> HelpFormatter:
|
||||
|
||||
9
third_party/2and3/click/formatting.pyi
vendored
9
third_party/2and3/click/formatting.pyi
vendored
@@ -1,5 +1,4 @@
|
||||
from contextlib import contextmanager
|
||||
from typing import Generator, Iterable, List, Optional, Tuple
|
||||
from typing import ContextManager, Generator, Iterable, List, Optional, Tuple
|
||||
|
||||
|
||||
FORCED_WIDTH: Optional[int]
|
||||
@@ -73,12 +72,10 @@ class HelpFormatter:
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@contextmanager
|
||||
def section(self, name) -> Generator[None, None, None]:
|
||||
def section(self, name) -> ContextManager[None]:
|
||||
...
|
||||
|
||||
@contextmanager
|
||||
def indentation(self) -> Generator[None, None, None]:
|
||||
def indentation(self) -> ContextManager[None]:
|
||||
...
|
||||
|
||||
def getvalue(self) -> str:
|
||||
|
||||
12
third_party/2and3/click/types.pyi
vendored
12
third_party/2and3/click/types.pyi
vendored
@@ -261,9 +261,9 @@ def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -
|
||||
|
||||
# parameter type shortcuts
|
||||
|
||||
BOOL = BoolParamType()
|
||||
FLOAT = FloatParamType()
|
||||
INT = IntParamType()
|
||||
STRING = StringParamType()
|
||||
UNPROCESSED = UnprocessedParamType()
|
||||
UUID = UUIDParameterType()
|
||||
BOOL: BoolParamType
|
||||
FLOAT: FloatParamType
|
||||
INT: IntParamType
|
||||
STRING: StringParamType
|
||||
UNPROCESSED: UnprocessedParamType
|
||||
UUID: UUIDParameterType
|
||||
|
||||
Reference in New Issue
Block a user