8000 Interactive client requires Python>=3.9.0 · Issue #951 · python-websockets/websockets · GitHub
[go: up one dir, main page]

Skip to content
Interactive client requires Python>=3.9.0 #951
@paskozdilar

Description

@paskozdilar

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0