Fix typehint of click progressbar (#2003)

* Fix typehint of click progressbar

* Oops -- stubs are *.pyi files
This commit is contained in:
Alan Du
2018-04-03 10:16:17 -04:00
committed by Jelle Zijlstra
parent bd26c7bf84
commit 603be5e1da
2 changed files with 35 additions and 5 deletions

View File

@@ -0,0 +1,12 @@
from typing import ContextManager, Iterator, Generic, TypeVar
_T = TypeVar("_T")
class ProgressBar(object, Generic[_T]):
def update(self, n_steps: int) -> None: ...
def finish(self) -> None: ...
def __enter__(self) -> "ProgressBar[_T]": ...
def __exit__(self, exc_type, exc_value, tb) -> None: ...
def __iter__(self) -> "ProgressBar[_T]": ...
def next(self) -> _T: ...
def __next__(self) -> _T: ...

View File

@@ -1,4 +1,3 @@
from contextlib import contextmanager
from typing import (
Any,
Callable,
@@ -7,11 +6,13 @@ from typing import (
IO,
List,
Optional,
overload,
Tuple,
TypeVar,
)
from click.types import _ConvertibleType
from click._termui_impl import ProgressBar as _ProgressBar
def hidden_prompt_func(prompt: str) -> str:
@@ -62,10 +63,9 @@ def echo_via_pager(text: str, color: Optional[bool] = ...) -> None:
_T = TypeVar('_T')
@contextmanager
@overload
def progressbar(
iterable: Optional[Iterable[_T]] = ...,
iterable: Iterable[_T],
length: Optional[int] = ...,
label: Optional[str] = ...,
show_eta: bool = ...,
@@ -79,9 +79,27 @@ def progressbar(
width: int = ...,
file: Optional[IO] = ...,
color: Optional[bool] = ...,
) -> Generator[_T, None, None]:
) -> _ProgressBar[_T]:
...
@overload
def progressbar(
iterable: None = ...,
length: Optional[int] = ...,
label: Optional[str] = ...,
show_eta: bool = ...,
show_percent: Optional[bool] = ...,
show_pos: bool = ...,
item_show_func: Optional[Callable[[_T], str]] = ...,
fill_char: str = ...,
empty_char: str = ...,
bar_template: str = ...,
info_sep: str = ...,
width: int = ...,
file: Optional[IO] = ...,
color: Optional[bool] = ...,
) -> _ProgressBar[int]:
...
def clear() -> None:
...