You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In most cases type parameter V will be inferred from iterable function parameter:
fromtypingimportreveal_typeimportclickwithclick.progressbar([1, 2, 3]) asbar:
reveal_type(bar) # Revealed type is "click._termui_impl.ProgressBar[builtins.int]"
However, if iterable parameter is not specified (or if it's empty list), type parameter V cannot be inferred:
But in this case ProgressBar is imported as not a part of public interface.
So, I think ProgressBartype should be a part of the public interface. Maybe it should not
be exported directly like class, because users should use click.progressbar() function instead.
Public ProgressBar type can be defined as protocol and click.progressbar() just returns its implementation.
Environment:
Python version: 3.11.5
Click version: 8.1.7
Mypy version: 1.6.1
The text was updated successfully, but these errors were encountered:
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: