forked from pallets/click
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
specialize progressbar(length=...) as ProgressBar[int] (pallets#2630)
Co-authored-by: Andreas Backx <[email protected]>
- Loading branch information
1 parent
0d69b6c
commit 2cabbe3
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from __future__ import annotations | ||
|
||
from typing_extensions import assert_type | ||
|
||
from click import progressbar | ||
from click._termui_impl import ProgressBar | ||
|
||
|
||
def test_length_is_int() -> None: | ||
with progressbar(length=5) as bar: | ||
assert_type(bar, ProgressBar[int]) | ||
for i in bar: | ||
assert_type(i, int) | ||
|
||
|
||
def it() -> tuple[str, ...]: | ||
return ("hello", "world") | ||
|
||
|
||
def test_generic_on_iterable() -> None: | ||
with progressbar(it()) as bar: | ||
assert_type(bar, ProgressBar[str]) | ||
for s in bar: | ||
assert_type(s, str) |