pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
941 stars 156 forks source link

How to fix the recent `TypeAlias` addition #3149

Closed damusss closed 1 month ago

damusss commented 1 month ago

A recent PR marked types inside typing.py with TypeAlias, but that object is only available from python 3.10. We now know how it passed the checks: inside __init__.py we catch import errors, and importing TypeAlias from typing before 3.10 results in an import error, so pygame.typing becomes a missing module with no exception. Once a PR fixing this is merged, the unit test for typing can be merged and issues like this won't appear again.

We can fix this in two ways:

The one choosing should be @zoldalma999 as they made the original PR. :3

aatle commented 1 month ago

Note that typing.py and typing.pyi should exclude TypeAlias in either case, because it is not guaranteed that typing_extensions will be available at runtime.

ankith26 commented 1 month ago

The linked PR puts up what I think is the best fix for now.