You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "C:\test.py", line 13, in <module>
group: pygame.sprite.Group[thing] = pygame.sprite.Group()
~~~~~~~~~~~~~~~~~~~^^^^^^^
TypeError: type 'Group' is not subscriptable
The text was updated successfully, but these errors were encountered:
In the mean time (apparently until 2.5.3 is released), you have two approaches to still use subscripts for type hints without running into runtime errors:
Environment:
pygame-ce 2.5.2 (SDL 2.30.8, Python 3.12.1)
Platform: Windows-11-10.0.22631-SP0
System: Windows
System Version: 10.0.22631
Processor: AMD64 Family 23 Model 104 Stepping 1, AuthenticAMD SSE2: Yes AVX2: Yes NEON: No
Architecture: Bits: 64bit Linkage: WindowsPE
Python: CPython 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
pygame version: 2.5.2
SDL versions: Linked: 2.30.8 Compiled: 2.30.8
SDL Mixer versions: Linked: 2.8.0 Compiled: 2.8.0
SDL Font versions: Linked: 2.22.0 Compiled: 2.22.0
SDL Image versions: Linked: 2.8.2 Compiled: 2.8.2
Freetype versions: Linked: 2.11.1 Compiled: 2.11.1
Display Driver: windows
Mixer Driver: wasapi
None
Current behavior:
Attempting to type hint a
pygame.sprite.Group
likegroup: pygame.sprite.Group[sprite]
results inTypeError: type 'Group' is not subscriptable
Removing the
[sprite]
works but mypy complains:error: Missing type parameters for generic type "Group"
Expected behavior:
No errors would occur and the type checker would be happy with
group: pygame.sprite.Group[sprite]
Screenshots
N/A
Steps to reproduce:
Test code
Stack trace/error output/other error logs
The text was updated successfully, but these errors were encountered: