fix: correct type annotations for alive_bar and alive_it#311
Closed
daniel7an wants to merge 1 commit intorsalmei:mainfrom
Closed
fix: correct type annotations for alive_bar and alive_it#311daniel7an wants to merge 1 commit intorsalmei:mainfrom
daniel7an wants to merge 1 commit intorsalmei:mainfrom
Conversation
- alive_bar now returns AbstractContextManager[__AliveBarHandle] instead of untyped - alive_it now returns __AliveBarIteratorAdapter[T] instead of Iterable[T], exposing bar handle attributes (text, title, current, monitor, rate, eta, elapsed) - __AliveBarIteratorAdapter.__iter__ now has proper Iterator[T] return type - Make __AliveBarIteratorAdapter properly Generic[T] Fixes #306
Owner
|
Thanks a lot! That’s fantastic, @daniel7an 👍 |
Owner
|
Oh, sorry, I haven’t merged it yet, @daniel7an. My local repository is quite messed up because I was testing some changes. But I did intend to merge it sometime. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #306
Problem
alive_barhad no return type annotation, showing up asAnyto type checkersalive_itreturnedIterable[T], hiding the bar handle methods (.text(),.title(), etc.) from type checkersChanges
alive_barnow returnsAbstractContextManager[__AliveBarHandle], so type checkers know thewithstatement yields a proper bar handle withtext,title,pause,current,monitor,rate,eta,elapsed, andreceiptattributesalive_itnow returns__AliveBarIteratorAdapter[T]instead ofIterable[T], so code likeprogress.text('...')type-checks correctly while still being recognized as iterable__AliveBarIteratorAdapterfor the proxied bar handle attributesIterator[T]return type to__iter____AliveBarIteratorAdapterproperlyGeneric[T]Example