Skip to content

Make LightQueue and derivatives subscriptable#1027

Merged
4383 merged 1 commit intoeventlet:masterfrom
stephenfin:typing
Mar 2, 2025
Merged

Make LightQueue and derivatives subscriptable#1027
4383 merged 1 commit intoeventlet:masterfrom
stephenfin:typing

Conversation

@stephenfin
Copy link
Copy Markdown
Contributor

Closes: #1026

Since Python 3.9, queue.Queue is subscriptable [1]:

  import queue
  a: queue.Queue[int] = queue.Queue()
  a.put(123)

By adding evenlet, this gets monkey patched:

  import evenlet
  eventlet.monkey_patch()

  import queue
  a: queue.Queue[int] = queue.Queue()
  a.put(123)

However, when this happens, things break:

  Traceback (most recent call last):
    File "/tmp/foo/test.py", line 5, in <module>
      a: queue.Queue[int] = queue.Queue()
         ~~~~~~~~~~~^^^^^
  TypeError: type 'Queue' is not subscriptable

Resolve this by allowing the class to be parameterized.

[1] https://bugs.python.org/issue33315
[2] https://docs.python.org/3/reference/datamodel.html#object.__class_getitem__

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: eventlet#1026
@4383
Copy link
Copy Markdown
Member

4383 commented Feb 26, 2025

Thanks Stephen

@4383 4383 merged commit 6747839 into eventlet:master Mar 2, 2025
@4383
Copy link
Copy Markdown
Member

4383 commented Mar 2, 2025

Will release it soon. Thanks

@stephenfin stephenfin deleted the typing branch March 3, 2025 10:18
@4383 4383 mentioned this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventlet.queue.LightQueue and derivatives are not subscriptable

2 participants