Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
5 of 8 tasks
asfaltboy opened this issue Sep 5, 2020 · 3 comments · Fixed by #1029 or #1019
Closed
5 of 8 tasks

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

asfaltboy opened this issue Sep 5, 2020 · 3 comments · Fixed by #1029 or #1019
Assignees
Labels
c1-quick 🕐 Complexity low submodule ⊂ Periphery/subclasses to-merge ↰ Imminent
Milestone

Comments

@asfaltboy
Copy link
Contributor

  • 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?

@casperdcl
Copy link
Member

Yes, silly bug requiring

- sys.version_info[:1]
+ sys.version_info[:2]

@casperdcl casperdcl self-assigned this Sep 6, 2020
@casperdcl casperdcl added this to the Non-breaking milestone Sep 6, 2020
@casperdcl casperdcl added c1-quick 🕐 Complexity low submodule ⊂ Periphery/subclasses to-merge ↰ Imminent labels Sep 6, 2020
@asfaltboy
Copy link
Contributor Author

asfaltboy commented Sep 6, 2020

Thanks for the quick response @casperdcl , I opened a small PR for the fix in #1029, could you kindly review?

Note: I had to shift condition to support 3.5, when native async/await coroutine syntax was first introduced (from PEP-492)

casperdcl pushed a commit that referenced this issue Sep 7, 2020
fix version detection in auto.py

- fixes #1028
@casperdcl
Copy link
Member

Yes, saw that, thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c1-quick 🕐 Complexity low submodule ⊂ Periphery/subclasses to-merge ↰ Imminent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants