-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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]
- Loading branch information
Showing
3 changed files
with
65 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,22 @@ | ||
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) |