Skip to content

TypeError with Iterators using the GUI #971

@rwhitt2049

Description

@rwhitt2049
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
    • documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
    • new feature request
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
    • I searched for "gui", "TypeError", "Iterator", and various combinations.
  • I have mentioned version numbers, operating system and
    environment, where applicable:
    >>> import tqdm, sys
    >>> print(tqdm.__version__, sys.version, sys.platform)
    4.42.0 3.8.1 (default, Jan  8 2020, 15:55:49) [MSC v.1916 64 bit (AMD64)] win32

Hopefully I searched enough that this isn't a duplicate issue. I'm getting a TypeError when I try to run tqdm_gui with iterators.

TypeError: 'NoneType' object cannot be interpreted as an integer

The offending line is here: https://github.com/tqdm/tqdm/blob/master/tqdm/gui.py#L56

I fixed it by adding a try/except and the gui worked fine after that. The len function will raise a TypeError if it gets something that can't be interpreted as an integer.

    try:
        total = len(self)
    except TypeError:
        total = None

It looks like the intent was to support iterators as there is an if total is None, but using an unguarded len may have been an oversight? Is it worth it to issue a PR with the gui being experimental?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions