question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Outdated documentation for Spinner

See original GitHub issue

Description

The current docstring in the Spinner class demonstrates using s.next() to update the spinner. But this is a Python 2-ism that no longer exists for iterators in Python 3. Instead the correct documentation would be next(s).

Additionally, I think it’s confusing that the API for Spinner is so different from ProgressBar and ProgressBarOrSpinner. In the latter two cases, their __enter__ method (when using with ProgressBar(...) as bar: returns the ProgressBar(OrSpinner) instance itself, which is iterable itself. It also provides an update() method which can be called to update the progress bar. Whereas with Spinner(...) as s: does not return the Spinner instance itself, but rather a generator.

It should be easy to update the API for Spinner (make it iterable, make __enter__ return the Spinner instance, and add an update() method) so that it is more like ProgressBar.

I would suggest making the updates to Spinner and fixing the documentation at the same time.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
embraycommented, May 21, 2021

I swear this issue is cursed.

1reaction
embraycommented, Nov 9, 2020

That’s a good point and exposes another inconsistency between Spinner and ProgressBar, where the latter can take a length/iterator as an argument. This makes sense since a progress bar is more for something with a known amount of work, while a spinner is for an unknown amount of work. Though sometimes iterators are non-finite, and it would be useful to wrap such an iterator in a spinner.

That said, your for loop example is still useful (though it would also be used with a with statement to properly cancel the spinner when done, like:

with Spinner('message') as spin:
    for _ in spin:
        # do stuff
        break

This is equivalent to having a while True: loop that you eventually have to break out of, except it updates the spinner while looping.

Meanwhile having an update() method would just be equivalent to calling next(spinner).

Basically this would be matter of:

  • change Spinner.__init__ so it does self._iter = self._iterator() (or self._silent_iterator)
  • change __enter__ to just return self and also add __iter__ which does the same (return self)
  • add __next__ which takes next(self._iter)
  • add update() which calls next(self)
  • update the examples in the documentation
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spinners - AUI Documentation - Atlassian
Spinners are used for showing a system process of unknown length going on that ends with the system ... JavaScript API Deprecated ......
Read more >
Spinner - dbc docs - Dash Bootstrap Components
Spinner. Indicate the loading state of a component or page with the Spinner component. ... fullscreenClassName (string; optional): DEPRECATED - use ...
Read more >
cli-spinners - npm
The header GIF is outdated. See all the spinner at once or one at the time. API. Each spinner comes with a recommended...
Read more >
Getting Started with Blazor Spinner Component | Syncfusion
This section briefly explains about how to include Blazor Spinner component in your Blazor Server App and Blazor WebAssembly App using Visual Studio....
Read more >
12. Spinner — Python GTK+ 3 Tutorial 3.4 documentation
Spinner displays an icon-size spinning animation. It is often used as an alternative to a GtkProgressBar for displaying indefinite activity, instead of actual ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found