pygame-ce
pygame-ce copied to clipboard
Remove property accessors and `None` initialization of `Sprite.rect`, `Sprite.image`
Revert the changes of #1942 (which initializes rect and image to None, and turns those attributes into properties).
Reasons:
The None values aren't actually compatible with the sprite functions and methods; they will error for a None sprite rect or image. It isn't really useful to initialize them to None.
By having them uninitialized instead, the remaining sprite stub issues involving optionals can be solved. -> makes sprite module comfortably usable and safe with typing.
The property accessors for these attributes seem to be redundant. Also, they are slightly slower than normal attributes.
The revert will also make sprite behavior in line with upstream pygame, as #1942 didn't apply to it.
Additionally, this PR fixes typing for DirtySprite.source_rect and LayeredDirty.get_clip().