Skip to content

tqdm.auto never uses asyncio_tqdm on python >= 3.5 #1028

@asfaltboy

Description

@asfaltboy
  • 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 have mentioned version numbers, operating system and
    environment, where applicable:
    >>> import tqdm, sys
    >>> print(tqdm.__version__, sys.version, sys.platform)
    4.48.2 3.8.5 (default, Jul 21 2020, 10:48:26)
    [Clang 11.0.3 (clang-1103.0.32.62)] darwin

I was surprised that tqdm.auto didn't select the tqdm_asyncio variant when I used python 3.8.5. It seems the code will never go into the else condition (not before python 4 😛 ), here's a pdb log that explains why:

> /Users/pavel.savchenko/.virtualenvs/test_tqdm_auto/lib/python3.8/site-packages/tqdm/auto.py(26)<module>()
-> if sys.version_info[:1] < (3, 4):
(Pdb) n
> /Users/pavel.savchenko/.virtualenvs/test_tqdm_auto/lib/python3.8/site-packages/tqdm/auto.py(27)<module>()
-> tqdm = notebook_tqdm
(Pdb) l
 22  	    from .autonotebook import tqdm as notebook_tqdm
 23  	    from .autonotebook import trange as notebook_trange
 24
 25  	breakpoint()
 26  	if sys.version_info[:1] < (3, 4):
 27  ->	    tqdm = notebook_tqdm
 28  	    trange = notebook_trange
 29  	else:  # Python3.5+
 30  	    from .asyncio import tqdm as asyncio_tqdm
 31  	    from .std import tqdm as std_tqdm
 32
(Pdb) sys.version_info
sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
(Pdb) sys.version_info[:1]
(3,)

Am I missing something obvious, or is this a really simple fix?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions