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

Interactive client requires Python>=3.9.0 #951

Closed
paskozdilar opened this issue May 11, 2021 · 1 comment
Closed

Interactive client requires Python>=3.9.0 #951

paskozdilar opened this issue May 11, 2021 · 1 comment
Labels

Comments

@paskozdilar
Copy link

paskozdilar commented May 11, 2021

Running python3 -m websockets wss://echo.websocket.org/ on Python 3.8.5 gives an uninformative error:

Traceback (most recent call last):                                                                                                                                                                                 
  File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main                                                                                                                                             
    return _run_code(code, main_globals, None,                                                                                                                                                                     
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code                                                                                                                                                        
    exec(code, run_globals)                                                                                                                                                                                        
  File "/home/$USER/websockets/src/websockets/__main__.py", line 215, in <module>                                                                                                                            
    main()                                                                                                                                                                                                         
  File "/home/$USER/websockets/src/websockets/__main__.py", line 181, in main                                                                                                                                
    async def queue_factory() -> asyncio.Queue[str]:                                                                                                                                                               
TypeError: 'type' object is not subscriptable

The issue is related to the PEP 585 - Type Hinting Generics In Standard Collections, which is introduced in Python 3.9.

This does not fit the Python version requirement specified in the documentation.

The fix could be either:

  • quoting the asyncio.Queue[str] on the line 181 of __main__.py, or
  • importing from __future__ import annotations the backwards compatility.

NOTE: If the latter fix is chosen, I think it would be style-consistent to convert other quoted type hints (on lines 94 and 95) to type-hinted generics.

I have submitted a PR with the latter fix.

@aaugustin
Copy link
Member

from __future__ import annotations doesn't work on Python 3.6, which is supported in 9.x (and removed in 10.x) so we have to go with quoting.

aaugustin added a commit that referenced this issue May 13, 2021
@aaugustin aaugustin added the bug label May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants