-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make ProgressBar type available in public interface #2626
Comments
Also possible to use function overloading to solve the problem above with inference of type parameter @overload
def progressbar(iterable: Optional[Iterable[V]], ...) -> ProgressBar[V]: ...
@overload
def progressbar(length: int, ...) -> ProgressBar[int]: ... Anyway, return type of the function should be public. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mypy
considers functionclick.progressbar()
as generic with type parameterV
:click/src/click/termui.py
Lines 287 to 303 in ca5e1c3
In most cases type parameter
V
will be inferred fromiterable
function parameter:However, if
iterable
parameter is not specified (or if it's empty list), type parameterV
cannot be inferred:This issue can be solved with manually specified type parameter:
Unfortunately, this doesn't work for functions:
Another way to fix this is specify type for variable
bar
:But in this case
ProgressBar
is imported as not a part of public interface.So, I think
ProgressBar
type should be a part of the public interface. Maybe it should notbe exported directly like class, because users should use
click.progressbar()
function instead.Public
ProgressBar
type can be defined as protocol andclick.progressbar()
just returns its implementation.Environment:
The text was updated successfully, but these errors were encountered: