File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change 8484# specific ones that aren't quite so general but fit into common
8585# specialized cases.
8686
87- from warnings import warn
87+ import sys
8888from typing import Optional
89+ from warnings import warn
8990
90- import pygame
91+ if sys .version_info [:3 ] >= (3 , 9 , 0 ):
92+ from types import GenericAlias
93+ else :
94+ from typing import _GenericAlias as GenericAlias # type: ignore[name-defined]
9195
96+ import pygame
97+ from pygame .mask import from_surface
9298from pygame .rect import Rect
9399from pygame .time import get_ticks
94- from pygame .mask import from_surface
95100
96101
97102class Sprite :
@@ -372,10 +377,7 @@ class AbstractGroup:
372377 """
373378
374379 def __class_getitem__ (cls , generic ):
375- # switch to `types.GenericAlias` once Python 3.8 support is dropped
376- import typing
377-
378- return typing ._GenericAlias (cls , generic ) # type: ignore[name-defined]
380+ return GenericAlias (cls , generic )
379381
380382 # protected identifier value to identify sprite groups, and avoid infinite recursion
381383 _spritegroup = True
Original file line number Diff line number Diff line change 11#################################### IMPORTS ###################################
22
3-
3+ import sys
4+ import typing
45import unittest
56
7+ if sys .version_info [:3 ] >= (3 , 9 , 0 ):
8+ from types import GenericAlias
9+ else :
10+ from typing import _GenericAlias as GenericAlias # type: ignore[name-defined]
11+
612import pygame
713from pygame import sprite
814
9-
1015################################# MODULE LEVEL #################################
1116
1217
@@ -666,10 +671,7 @@ def test_type_subscript(self):
666671 except TypeError as e :
667672 self .fail (e )
668673
669- # switch to `types.GenericAlias` once Python 3.8 support is dropped
670- import typing
671-
672- self .assertIsInstance (group_generic_alias , typing ._GenericAlias ) # type: ignore[name-defined]
674+ self .assertIsInstance (group_generic_alias , GenericAlias )
673675 self .assertIs (typing .get_origin (group_generic_alias ), sprite .Group )
674676 self .assertEqual (typing .get_args (group_generic_alias ), (sprite .Sprite ,))
675677
@@ -1375,8 +1377,8 @@ def test_memoryleak_bug(self):
13751377 # For memory leak bug posted to mailing list by Tobias Steinrücken on 16/11/10.
13761378 # Fixed in revision 2953.
13771379
1378- import weakref
13791380 import gc
1381+ import weakref
13801382
13811383 class MySprite (sprite .Sprite ):
13821384 def __init__ (self , * args , ** kwargs ):
You can’t perform that action at this time.
0 commit comments