Skip to content

Commit befa79e

Browse files
committed
Try using fused type instead of object
1 parent d454061 commit befa79e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src_c/cython/pygame/_sdl2/video.pxd

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,10 @@ cdef extern from "pygame.h" nogil:
430430
cdef SDL_FRect r
431431
cdef object weakreflist
432432

433+
ctypedef fused RectLike:
434+
Rect
435+
FRect
436+
433437
ctypedef class pygame.window.Window [object pgWindowObject]:
434438
cdef SDL_Window *_win
435439
cdef SDL_bool _is_borrowed
@@ -468,7 +472,7 @@ cdef class Renderer:
468472
cdef int _is_borrowed
469473

470474
cpdef object get_viewport(self)
471-
cpdef object blit(self, object source, object dest=*, object area=*, int special_flags=*)
475+
cpdef object blit(self, object source, RectLike dest=*, RectLike area=*, int special_flags=*)
472476

473477
cdef class Texture:
474478
cdef SDL_Texture* _tex

src_c/cython/pygame/_sdl2/video.pyx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ cdef class Renderer:
998998
else:
999999
raise TypeError('target must be a Texture or None')
10001000

1001-
cpdef object blit(self, object source, object dest=None, object area=None, int special_flags=0):
1001+
cpdef object blit(self, object source, RectLike dest=None, RectLike area=None, int special_flags=0):
10021002
"""Draw textures using a Surface-like API
10031003
10041004
For compatibility purposes. Draws :class:`Texture` objects onto the
@@ -1011,10 +1011,6 @@ cdef class Renderer:
10111011
10121012
.. note:: Textures created by different Renderers cannot shared with each other!
10131013
"""
1014-
if not isinstance(dest, (Rect, FRect)):
1015-
raise TypeError('dest must be a Rect or FRect')
1016-
if area is not None and not isinstance(area, (Rect, FRect)):
1017-
raise TypeError('area must be None or a Rect or FRect')
10181014
if isinstance(source, Texture):
10191015
(<Texture>source).draw(area, dest)
10201016
elif isinstance(source, Image):

0 commit comments

Comments
 (0)