Skip to content

Conversation

ankith26
Copy link
Member

Python 3.9 will be EOL by October 31st. In addition to dropping python 3.9 support, this PR modernises our stubs with python 3.10 specific features.

@ankith26 ankith26 added this to the 2.5.7 milestone Oct 15, 2025
@ankith26 ankith26 requested a review from a team as a code owner October 15, 2025 03:48
Copy link
Contributor

coderabbitai bot commented Oct 15, 2025

📝 Walkthrough

Walkthrough

Raised CPython minimum to 3.10 across CI, packaging, and docs; migrated many stub and runtime type annotations from typing.Optional/typing.Union to PEP 604 union syntax and added TypeAlias usages. No runtime control-flow or behavioral changes.

Changes

Cohort / File(s) Change summary
CI & Packaging
.github/workflows/run-ubuntu-checks.yml, .github/workflows/build-sdl3.yml, pyproject.toml, setup.cfg, setup.py
Bumped minimum Python to 3.10 in CI/workflows and packaging metadata; updated CI Python matrices and cibuildwheel pattern; removed Python 3.9 classifier; added setup-python@v6 (3.14) step in SDL3 workflow; adjusted tox envlist.
Documentation (READMEs)
README.rst, docs/readmes/README.*.rst
Updated CPython requirement from >=3.9 to >=3.10 across README files; added SDL >= 2.0.14 line in Spanish README.
Stub migrations — PEP 604 / TypeAlias
buildconfig/stubs/pygame/... (many files, e.g., _debug.pyi, _render.pyi, _sdl2/*, camera.pyi, color.pyi, cursors.pyi, display.pyi, draw.pyi, event.pyi, font.pyi, freetype.pyi, geometry.pyi, image.pyi, mask.pyi, math.pyi, midi.pyi, mixer.pyi, pixelarray.pyi, rect.pyi, rwobject.pyi, scrap.pyi, sprite.pyi, surface.pyi, system.pyi, time.pyi, transform.pyi, typing.pyi, window.pyi, pixelcopy.pyi)
Replaced typing.Optional/typing.Union with PEP 604 union syntax (`A
Runtime typing updates
src_py/_data_classes.py, src_py/sprite.py, src_py/typing.py, dev.py, src_py/_debug.py
Converted runtime annotations to PEP 604 unions and TypeAlias where applicable (PowerState fields, Sprite private attrs/setters, FileLike/ColorLike/RectLike aliases); removed unused imports and one removed public alias; dev.cmd_run typing updated to `list[str

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Improve sprite stubs #3525 — Overlaps changes to sprite typing and stub signatures (e.g., buildconfig/stubs/pygame/sprite.pyi).
  • flood fill #2840 — Related to draw.flood_fill stub signature and docstring edits in buildconfig/stubs/pygame/draw.pyi.

Suggested labels

type hints

Suggested reviewers

  • MyreMylar
  • damusss

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.99% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Drop python 3.9" is concise, clear, and directly summarizes the main objective of the changeset. The pull request systematically removes Python 3.9 support across all configuration files, CI workflows, and documentation. The title accurately reflects the primary change that anyone scanning commit history would want to understand, making it appropriate and specific.
Description Check ✅ Passed The description is clearly related to the changeset and accurately describes what the PR accomplishes. It mentions dropping Python 3.9 support and modernizing stubs with Python 3.10 specific features, both of which are directly supported by the changes shown in the raw summary. The description provides appropriate context about Python 3.9's EOL date and explains the dual objectives of the PR.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ankith26-drop-3.9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
src_py/_data_classes.py (1)

2-2: Remove unused Optional import.

After migrating to PEP 604 union syntax, the Optional import is no longer used.

Apply this diff:

-from typing import Optional
buildconfig/stubs/pygame/transform.pyi (2)

157-168: Doc/typing mismatch for smoothscale backend names.

Return/arg types allow only "GENERIC" | "SSE2" | "NEON", but docs still mention "MMX" and "SSE". Align the docs (and examples) to avoid confusion.

Also applies to: 169-181


388-401: Minor: incorrect param type labels in threshold docs.

The RST uses “:type color:” for search_color/threshold/set_color. Update to “:type search_color: …”, “:type threshold: …”, “:type set_color: …” to match parameter names.

src_py/sprite.py (1)

88-88: Remove unused import.

The Optional import is no longer used in this file since all type hints have been migrated to PEP 604 union syntax (X | None).

Apply this diff to remove the unused import:

-from typing import Optional
 from warnings import warn
buildconfig/stubs/pygame/camera.pyi (1)

8-8: PEP 604 migration looks good; minor param-name consistency nit

Signatures are correct. Consider harmonizing get_image param name between AbstractCamera (dest_surf) and Camera (surface) to reduce confusion in docs and autocomplete.

Also applies to: 27-27, 37-37, 52-52

buildconfig/stubs/pygame/_render.pyi (1)

12-13: Renderer/Texture unions aligned with SDL2 stubs

PEP 604 updates look correct and consistent with _sdl2/video.pyi. Optionally, consider annotating _DrawableClass.draw -> None to reflect Texture/Image.draw, but current Protocol is acceptable.

Also applies to: 26-31, 44-47, 85-86, 109-115, 144-145

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b269a0 and df8d601.

⛔ Files ignored due to path filters (5)
  • src_c/doc/display_doc.h is excluded by !src_c/doc/*
  • src_c/doc/image_doc.h is excluded by !src_c/doc/*
  • src_c/doc/surface_doc.h is excluded by !src_c/doc/*
  • src_c/doc/system_doc.h is excluded by !src_c/doc/*
  • src_c/doc/window_doc.h is excluded by !src_c/doc/*
📒 Files selected for processing (50)
  • .github/workflows/run-ubuntu-checks.yml (1 hunks)
  • README.rst (1 hunks)
  • buildconfig/stubs/pygame/_debug.pyi (1 hunks)
  • buildconfig/stubs/pygame/_render.pyi (7 hunks)
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/touch.pyi (2 hunks)
  • buildconfig/stubs/pygame/_sdl2/video.pyi (7 hunks)
  • buildconfig/stubs/pygame/camera.pyi (4 hunks)
  • buildconfig/stubs/pygame/color.pyi (2 hunks)
  • buildconfig/stubs/pygame/cursors.pyi (2 hunks)
  • buildconfig/stubs/pygame/display.pyi (5 hunks)
  • buildconfig/stubs/pygame/draw.pyi (2 hunks)
  • buildconfig/stubs/pygame/event.pyi (2 hunks)
  • buildconfig/stubs/pygame/font.pyi (3 hunks)
  • buildconfig/stubs/pygame/freetype.pyi (7 hunks)
  • buildconfig/stubs/pygame/geometry.pyi (2 hunks)
  • buildconfig/stubs/pygame/image.pyi (2 hunks)
  • buildconfig/stubs/pygame/mask.pyi (4 hunks)
  • buildconfig/stubs/pygame/math.pyi (8 hunks)
  • buildconfig/stubs/pygame/midi.pyi (3 hunks)
  • buildconfig/stubs/pygame/mixer.pyi (4 hunks)
  • buildconfig/stubs/pygame/pixelarray.pyi (2 hunks)
  • buildconfig/stubs/pygame/rect.pyi (6 hunks)
  • buildconfig/stubs/pygame/rwobject.pyi (1 hunks)
  • buildconfig/stubs/pygame/scrap.pyi (1 hunks)
  • buildconfig/stubs/pygame/sprite.pyi (6 hunks)
  • buildconfig/stubs/pygame/surface.pyi (9 hunks)
  • buildconfig/stubs/pygame/system.pyi (3 hunks)
  • buildconfig/stubs/pygame/time.pyi (2 hunks)
  • buildconfig/stubs/pygame/transform.pyi (17 hunks)
  • buildconfig/stubs/pygame/typing.pyi (2 hunks)
  • buildconfig/stubs/pygame/window.pyi (5 hunks)
  • dev.py (2 hunks)
  • docs/readmes/README.es.rst (1 hunks)
  • docs/readmes/README.fa.rst (1 hunks)
  • docs/readmes/README.fr.rst (1 hunks)
  • docs/readmes/README.gr.rst (1 hunks)
  • docs/readmes/README.it.rst (1 hunks)
  • docs/readmes/README.ja.rst (1 hunks)
  • docs/readmes/README.pt-br.rst (1 hunks)
  • docs/readmes/README.ru.rst (1 hunks)
  • docs/readmes/README.zh-cn.rst (1 hunks)
  • docs/readmes/README.zh-tw.rst (1 hunks)
  • pyproject.toml (2 hunks)
  • setup.cfg (1 hunks)
  • setup.py (2 hunks)
  • src_py/_data_classes.py (1 hunks)
  • src_py/sprite.py (2 hunks)
  • src_py/typing.py (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (26)
buildconfig/stubs/pygame/mixer.pyi (3)
src_c/mixer.c (1)
  • pre_init (609-644)
buildconfig/stubs/pygame/mixer_music.pyi (1)
  • set_endevent (25-25)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/scrap.pyi (1)
buildconfig/stubs/pygame/event.pyi (1)
  • get (39-43)
buildconfig/stubs/pygame/camera.pyi (1)
buildconfig/stubs/pygame/mixer.pyi (1)
  • init (17-24)
buildconfig/stubs/pygame/midi.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/bufferproxy.pyi (1)
  • write (23-27)
buildconfig/stubs/pygame/geometry.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/rect.pyi (2)
  • Rect (300-300)
  • FRect (301-301)
buildconfig/stubs/pygame/system.pyi (1)
src_py/_data_classes.py (1)
  • PowerState (6-14)
buildconfig/stubs/pygame/time.pyi (2)
src_c/event.c (1)
  • event (2565-2636)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
src_py/typing.py (5)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (57-57)
  • _HasRectAttribute (53-57)
src_py/sprite.py (2)
  • rect (128-129)
  • rect (132-133)
buildconfig/stubs/pygame/window.pyi (3)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • get_grabbed_window (29-29)
src_c/window.c (1)
  • get_grabbed_window (119-133)
src_py/__init__.py (1)
  • Window (380-381)
buildconfig/stubs/pygame/sprite.pyi (1)
src_py/sprite.py (32)
  • rect (128-129)
  • rect (132-133)
  • image (120-121)
  • image (124-125)
  • visible (322-327)
  • visible (330-331)
  • Sprite (97-264)
  • DirtySprite (267-359)
  • AbstractGroup (362-637)
  • add_internal (171-177)
  • add_internal (396-407)
  • add_internal (759-794)
  • add_internal (1115-1135)
  • add_internal (1424-1428)
  • sprite (1442-1448)
  • sprite (1451-1452)
  • layer (239-252)
  • layer (255-264)
  • layer (334-342)
  • layer (345-354)
  • clear (586-609)
  • clear (1304-1310)
  • repaint_rect (1312-1323)
  • set_clip (1325-1335)
  • get_clip (1337-1343)
  • set_timing_threshold (1377-1395)
  • set_timing_treshold (1358-1375)
  • GroupSingle (1398-1465)
  • collide_mask (1663-1687)
  • spritecollide (1690-1724)
  • groupcollide (1727-1756)
  • spritecollideany (1759-1789)
buildconfig/stubs/pygame/_sdl2/video.pyi (3)
buildconfig/stubs/pygame/window.pyi (2)
  • get_grabbed_window (7-7)
  • Window (9-498)
src_c/window.c (2)
  • get_grabbed_window (119-133)
  • window (1470-1523)
buildconfig/stubs/pygame/_render.pyi (12)
  • update (144-144)
  • Image (147-148)
  • Texture (76-144)
  • get_rect (143-143)
  • draw (12-12)
  • draw (107-115)
  • set_viewport (44-44)
  • scale (61-61)
  • scale (63-63)
  • target (65-65)
  • target (67-67)
  • blit (24-30)
src_py/sprite.py (3)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/sprite.pyi (6)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
  • image (36-36)
  • image (45-45)
  • image (47-47)
buildconfig/stubs/pygame/rect.pyi (1)
  • Rect (300-300)
buildconfig/stubs/pygame/surface.pyi (2)
src_py/__init__.py (1)
  • Surface (227-228)
src_py/sprite.py (3)
  • rect (128-129)
  • rect (132-133)
  • set_clip (1325-1335)
buildconfig/stubs/pygame/rect.pyi (2)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (57-57)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/_render.pyi (2)
buildconfig/stubs/pygame/_sdl2/video.pyi (5)
  • draw (66-74)
  • draw (111-113)
  • set_viewport (147-147)
  • to_surface (168-170)
  • update (102-102)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/freetype.pyi (1)
buildconfig/stubs/pygame/font.pyi (10)
  • name (33-33)
  • size (69-69)
  • bold (37-37)
  • bold (39-39)
  • italic (41-41)
  • italic (43-43)
  • Font (31-87)
  • get_default_font (16-16)
  • get_fonts (17-17)
  • match_font (18-22)
buildconfig/stubs/pygame/transform.pyi (3)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/typing.pyi (2)
  • SequenceLike (31-39)
  • rect (57-57)
src_c/transform.c (3)
  • laplacian (2898-3088)
  • invert (4136-4198)
  • grayscale (2277-2339)
buildconfig/stubs/pygame/draw.pyi (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/rect.pyi (1)
  • Rect (300-300)
buildconfig/stubs/pygame/cursors.pyi (2)
buildconfig/stubs/pygame/surface.pyi (2)
  • Surface (42-1051)
  • copy (335-346)
src_py/cursors.py (2)
  • copy (219-224)
  • Cursor (92-243)
buildconfig/stubs/pygame/pixelarray.pyi (3)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
src_py/__init__.py (1)
  • PixelArray (253-254)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/math.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
src_py/typing.py (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/event.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/mask.pyi (4)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
src_py/__init__.py (2)
  • Surface (227-228)
  • Mask (245-246)
buildconfig/stubs/pygame/_render.pyi (1)
  • to_surface (45-47)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • to_surface (168-170)
buildconfig/stubs/pygame/display.pyi (4)
buildconfig/stubs/pygame/window.pyi (2)
  • get_surface (349-366)
  • Window (9-498)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • update (102-102)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/font.pyi (1)
buildconfig/stubs/pygame/freetype.pyi (8)
  • name (58-58)
  • SysFont (20-26)
  • size (44-44)
  • size (46-46)
  • Font (42-195)
  • render (158-166)
  • bgcolor (128-128)
  • bgcolor (130-130)
buildconfig/stubs/pygame/typing.pyi (6)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
src_py/typing.py (3)
  • rect (57-57)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-57)
🪛 Ruff (0.14.0)
setup.py

160-160: Avoid specifying long messages outside the exception class

(TRY003)


162-162: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: msys2 (clang64, clang-x86_64)
  • GitHub Check: msys2 (mingw64, x86_64)
  • GitHub Check: msys2 (ucrt64, ucrt-x86_64)
  • GitHub Check: Debian (Bookworm - 12) [armv7]
  • GitHub Check: Debian (Bookworm - 12) [s390x]
  • GitHub Check: Debian (Bookworm - 12) [armv6]
  • GitHub Check: Debian (Bookworm - 12) [ppc64le]
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.14.0)
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.10.17)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: build (macos-14)
  • GitHub Check: Pyodide build
  • GitHub Check: dev-check
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (50)
src_py/_data_classes.py (1)

7-8: LGTM! Type annotations modernized to PEP 604 syntax.

The migration from Optional[int] to int | None is semantically equivalent and correctly adopts the Python 3.10+ union syntax.

docs/readmes/README.zh-tw.rst (1)

112-112: LGTM!

The CPython minimum version update from 3.9 to 3.10 correctly reflects the PR's objective to drop Python 3.9 support.

.github/workflows/run-ubuntu-checks.yml (1)

56-57: LGTM!

The CI matrix correctly tests the new minimum Python version (3.10.17) and the latest stable version (3.14.0), properly reflecting the dropped support for Python 3.9.

docs/readmes/README.es.rst (1)

120-120: LGTM!

The CPython minimum version update correctly documents the new requirement of Python 3.10 or later.

buildconfig/stubs/pygame/scrap.pyi (1)

11-11: LGTM!

The return type correctly adopts PEP 604 union syntax (bytes | None), which is equivalent to the previous Optional[bytes] but uses Python 3.10+ features.

buildconfig/stubs/pygame/draw.pyi (2)

31-31: LGTM!

Correctly removed the unused Union import after migrating to PEP 604 union syntax.


572-572: LGTM!

The function signature correctly adopts PEP 604 union syntax (ColorLike | Surface), modernizing the type hint while maintaining the same semantics.

buildconfig/stubs/pygame/pixelarray.pyi (3)

2-3: LGTM!

The imports correctly modernize to Python 3.10+: EllipsisType is now unconditionally imported from types (available in 3.10+), and Union is removed after migrating to PEP 604 syntax.


9-9: LGTM!

The _PixelColor type alias correctly adopts PEP 604 union syntax, modernizing from Union[...] to the | operator.


36-40: LGTM!

The __getitem__ overloads correctly adopt PEP 604 union syntax for their return types, maintaining the same semantics with modern Python 3.10+ syntax.

buildconfig/stubs/pygame/system.pyi (3)

6-6: LGTM!

Correctly removed the unused Optional import after migrating to PEP 604 union syntax.


28-28: LGTM!

The country field correctly adopts PEP 604 union syntax (str | None), equivalent to the previous Optional[str].


147-147: LGTM!

The return type correctly adopts PEP 604 union syntax (PowerState | None), modernizing the type hint while maintaining the same semantics.

buildconfig/stubs/pygame/cursors.pyi (3)

2-2: LGTM!

Correctly removed the unused Union import after migrating to PEP 604 union syntax.


82-82: LGTM!

The __getitem__ return type correctly adopts PEP 604 union syntax (int | IntPoint | Surface).


85-89: LGTM!

The data attribute type correctly adopts PEP 604 union syntax with clear multiline formatting for readability.

buildconfig/stubs/pygame/rwobject.pyi (1)

6-9: PEP 604 unions applied cleanly

The _PathLike | None and str | None annotations align with the broader 3.10+ migration while preserving the original defaults. Looks great.

buildconfig/stubs/pygame/display.pyi (1)

288-845: Display stub updates look consistent

All optional parameters and return types now use the inline union form without altering semantics, and the overload set remains intact. Nicely synchronized with the overall 3.10 baseline.

buildconfig/stubs/pygame/font.pyi (1)

19-78: Font typing refresh looks solid

The new unions keep parity with the freetype counterparts and maintain compatibility for callers (str/bytes/iterables), so this transition is seamless.

buildconfig/stubs/pygame/freetype.pyi (1)

21-195: Freetype stubs updated accurately

Switching to inline unions (including EllipsisType import and text str | None) mirrors the runtime signatures and harmonizes with the font stubs. Nicely done.

buildconfig/stubs/pygame/rect.pyi (1)

19-287: Rect generics now match Python 3.10 style

The added EllipsisType import plus updated slice handling, move_to, and collision helpers all keep the previous semantics while embracing the new union syntax. Looks great.

buildconfig/stubs/pygame/transform.pyi (1)

33-36: PEP 604 union migration looks correct across transform stubs.

Signatures now consistently use Surface | None and PEP 604 unions; matches runtime expectations (e.g., dest surface optional, factors as float | SequenceLike[float]). Good cleanup.

Also applies to: 51-56, 95-101, 111-116, 135-140, 195-205, 207-213, 233-239, 264-269, 289-291, 302-313, 314-329, 330-336, 358-367, 425-432, 463-468

buildconfig/stubs/pygame/math.pyi (2)

30-31: Broad typing modernization (PEP 604) looks good.

Unions simplified across vectors/proxies; overloads remain consistent with pygame vector semantics. No issues spotted.

Also applies to: 36-43, 51-56, 61-87, 88-105, 110-185, 211-213, 228-229, 276-277, 281-297, 283-297, 319-323


14-15: Decorator import: consider future-proofing for 3.13+.

Since typing.deprecated exists in 3.13, consider a conditional approach in runtime code paths (if any) or keep as-is for stubs. Ensure typing_extensions is available for type checking workflows.

README.rst (1)

142-143: CPython minimum raised to 3.10 — LGTM.

Matches project-wide drop of 3.9.

setup.cfg (1)

2-2: Tox envlist updated to 3.10–3.14 — LGTM.

Consistent with CI and packaging changes.

pyproject.toml (2)

6-6: requires-python bumped to >=3.10 — LGTM.

Aligned with classifiers and docs.


79-81: CIBW patterns updated; verify the skip glob.

build matrix looks right (cp3{10–14}, pp311). However, “cp31?t-” likely doesn’t match tags like “cp310-”. If the intent was to skip 3.10–3.19, use “cp31?-*”.

Would you like me to propose a diff to correct the skip pattern if needed?

setup.py (2)

65-65: LGTM! Python version requirement correctly updated.

The python_requires field now enforces Python 3.10+ as the minimum supported version, aligning with the PR objective to drop Python 3.9 support.


158-162: LGTM! Runtime version checks correctly updated.

The version gating logic now enforces Python 3.10+ at runtime, with clear error messages. The static analysis hints about long exception messages are pedantic and acceptable in this context where clarity is more important than brevity.

buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1)

13-13: LGTM! Type hint correctly updated to PEP 604 syntax.

The return type now uses Python 3.10+ union syntax (str | None), which is more concise and idiomatic than Optional[str].

buildconfig/stubs/pygame/image.pyi (2)

65-65: LGTM! Import statement correctly updated.

The imports have been narrowed to only Literal, removing Optional and Union which are no longer needed after migrating to PEP 604 union syntax.


180-180: LGTM! Return type correctly updated to PEP 604 syntax.

The function signature now uses Python 3.10+ union syntax for the optional return type, which is more concise and idiomatic.

dev.py (2)

17-17: LGTM! Import statement correctly updated.

The Union import has been removed since all union types now use PEP 604 syntax (|).


88-92: LGTM! Function signature correctly updated to PEP 604 syntax.

The parameter type now uses Python 3.10+ union syntax (str | Path), which is more concise than Union[str, Path].

buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1)

11-12: LGTM! Type hint correctly updated to PEP 604 syntax.

The parameter type now uses Python 3.10+ union syntax (str | None), which is more concise and idiomatic than Optional[str].

buildconfig/stubs/pygame/_sdl2/touch.pyi (2)

1-1: LGTM! Import statement correctly updated.

The Optional import has been removed since the optional type now uses PEP 604 union syntax.


12-12: LGTM! Return type correctly updated to PEP 604 syntax.

The function signature now uses Python 3.10+ union syntax for the optional return type.

buildconfig/stubs/pygame/window.pyi (5)

7-7: LGTM! Return type correctly updated to PEP 604 syntax.

The function signature now uses Python 3.10+ union syntax for the optional return type.


90-113: LGTM! Constructor parameter type correctly updated to PEP 604 syntax.

The position parameter type now uses Python 3.10+ union syntax (int | Point), which is more concise than Union[int, Point].


233-246: LGTM! Property type correctly updated to PEP 604 syntax.

The mouse_rect property now uses Python 3.10+ union syntax for the optional return type.


248-249: LGTM! Setter parameter type correctly updated to PEP 604 syntax.

The setter parameter type now uses Python 3.10+ union syntax for the optional value.


305-306: LGTM! Setter parameter type correctly updated to PEP 604 syntax.

The setter parameter type now uses Python 3.10+ union syntax for the union value.

src_py/sprite.py (2)

112-117: LGTM! Private attribute type hints correctly updated to PEP 604 syntax.

The private attributes now use Python 3.10+ union syntax for optional types, which is more concise and idiomatic.


123-133: LGTM! Property setter type hints correctly updated to PEP 604 syntax.

The setter parameters now use Python 3.10+ union syntax for optional types, maintaining consistency with the updated private attribute types.

src_py/typing.py (1)

18-18: Type alias modernisation LGTM; ensure stub parity

Updates to FileLike/ColorLike/RectLike and unions look correct. Please re-run the stub sync (gen_stubs.py) so buildconfig/stubs/pygame/typing.pyi stays identical.

Also applies to: 24-27, 45-46, 50-50, 57-57, 60-60

buildconfig/stubs/pygame/surface.pyi (1)

122-129: Consistent union updates across Surface API — looks good

Signatures for blit/blits/fblits/fill/alpha/clip align with PEP 604 and broader PR changes. One check: confirm get_colorkey’s return type (tuple[int, int, int, int] | None) matches current pygame-ce docs and other stubs (vs returning Color). Update if needed for consistency.

Also applies to: 140-146, 197-207, 256-261, 348-354, 421-421, 452-452, 652-652

buildconfig/stubs/pygame/mask.pyi (1)

2-2: Mask stubs union migration is consistent

from_threshold/overlap/convolve/to_surface updates correctly adopt X | None and precise unions. No issues spotted.

Also applies to: 14-16, 26-26, 42-44, 50-57

buildconfig/stubs/pygame/_sdl2/video.pyi (1)

29-34: _sdl2/video union updates validated against runtime

Types align with runtime (e.g., get_grabbed_window can be None) and mirror _render.pyi. Looks good.

Also applies to: 51-52, 68-73, 102-102, 107-113, 115-115, 147-147, 152-152, 155-159, 169-170

buildconfig/stubs/pygame/sprite.pyi (1)

31-37: Sprite/Group union updates look correct

PEP 604 conversions across Sprite properties, group APIs, collision helpers, and LayeredDirty clip methods are consistent with src_py/sprite.py behavior.

Please confirm no other attributes with default None remained non-optional in stubs.

Also applies to: 45-51, 77-79, 81-90, 99-105, 144-152, 159-161, 185-190, 193-210

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src_py/_data_classes.py (1)

2-2: Remove unused import.

The Optional import is no longer used after migrating to PEP 604 union syntax.

Apply this diff to remove the unused import:

-from typing import Optional
buildconfig/stubs/pygame/font.pyi (2)

89-90: Add runtime and documentation deprecation for FontType.

  • Emit a DeprecationWarning in the implementation when FontType is accessed.
  • Update the official docs (CHANGELOG or API reference) to mark FontType deprecated in favor of Font.

81-87: Stub declarations lack implementations

  • get_height, get_ascent, and get_descent are present in src_py/ftfont.py with matching signatures.
  • set_script, set_direction, get_point_size, and set_point_size are declared in buildconfig/stubs/pygame/font.pyi (lines 81–87) but have no corresponding implementations; add these methods to the codebase or remove their stubs.
♻️ Duplicate comments (1)
buildconfig/stubs/pygame/sprite.pyi (1)

69-69: Fix DirtySprite.source_rect to include None.

Runtime sets DirtySprite.source_rect = None initially (src_py/sprite.py line 273); declaring it as FRect | Rect only will cause type-checking mismatches. Include None.

Apply this diff:

-    source_rect: FRect | Rect
+    source_rect: FRect | Rect | None
🧹 Nitpick comments (1)
buildconfig/stubs/pygame/font.pyi (1)

6-6: Clarify the comment about deprecated availability.

The comment "added in 3.13" may be misleading. While deprecated will be added to the standard library typing module in Python 3.13, it has been available in typing_extensions for earlier versions, which is what's being imported here.

Consider updating the comment to be more precise:

-from typing_extensions import deprecated  # added in 3.13
+from typing_extensions import deprecated  # added to stdlib typing in 3.13
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df8d601 and 51942b5.

⛔ Files ignored due to path filters (5)
  • src_c/doc/display_doc.h is excluded by !src_c/doc/*
  • src_c/doc/image_doc.h is excluded by !src_c/doc/*
  • src_c/doc/surface_doc.h is excluded by !src_c/doc/*
  • src_c/doc/system_doc.h is excluded by !src_c/doc/*
  • src_c/doc/window_doc.h is excluded by !src_c/doc/*
📒 Files selected for processing (50)
  • .github/workflows/run-ubuntu-checks.yml (1 hunks)
  • README.rst (1 hunks)
  • buildconfig/stubs/pygame/_debug.pyi (1 hunks)
  • buildconfig/stubs/pygame/_render.pyi (7 hunks)
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/touch.pyi (2 hunks)
  • buildconfig/stubs/pygame/_sdl2/video.pyi (7 hunks)
  • buildconfig/stubs/pygame/camera.pyi (4 hunks)
  • buildconfig/stubs/pygame/color.pyi (2 hunks)
  • buildconfig/stubs/pygame/cursors.pyi (2 hunks)
  • buildconfig/stubs/pygame/display.pyi (5 hunks)
  • buildconfig/stubs/pygame/draw.pyi (2 hunks)
  • buildconfig/stubs/pygame/event.pyi (2 hunks)
  • buildconfig/stubs/pygame/font.pyi (3 hunks)
  • buildconfig/stubs/pygame/freetype.pyi (7 hunks)
  • buildconfig/stubs/pygame/geometry.pyi (2 hunks)
  • buildconfig/stubs/pygame/image.pyi (2 hunks)
  • buildconfig/stubs/pygame/mask.pyi (4 hunks)
  • buildconfig/stubs/pygame/math.pyi (8 hunks)
  • buildconfig/stubs/pygame/midi.pyi (3 hunks)
  • buildconfig/stubs/pygame/mixer.pyi (4 hunks)
  • buildconfig/stubs/pygame/pixelarray.pyi (2 hunks)
  • buildconfig/stubs/pygame/rect.pyi (6 hunks)
  • buildconfig/stubs/pygame/rwobject.pyi (1 hunks)
  • buildconfig/stubs/pygame/scrap.pyi (1 hunks)
  • buildconfig/stubs/pygame/sprite.pyi (6 hunks)
  • buildconfig/stubs/pygame/surface.pyi (9 hunks)
  • buildconfig/stubs/pygame/system.pyi (3 hunks)
  • buildconfig/stubs/pygame/time.pyi (2 hunks)
  • buildconfig/stubs/pygame/transform.pyi (17 hunks)
  • buildconfig/stubs/pygame/typing.pyi (3 hunks)
  • buildconfig/stubs/pygame/window.pyi (5 hunks)
  • dev.py (2 hunks)
  • docs/readmes/README.es.rst (1 hunks)
  • docs/readmes/README.fa.rst (1 hunks)
  • docs/readmes/README.fr.rst (1 hunks)
  • docs/readmes/README.gr.rst (1 hunks)
  • docs/readmes/README.it.rst (1 hunks)
  • docs/readmes/README.ja.rst (1 hunks)
  • docs/readmes/README.pt-br.rst (1 hunks)
  • docs/readmes/README.ru.rst (1 hunks)
  • docs/readmes/README.zh-cn.rst (1 hunks)
  • docs/readmes/README.zh-tw.rst (1 hunks)
  • pyproject.toml (2 hunks)
  • setup.cfg (1 hunks)
  • setup.py (2 hunks)
  • src_py/_data_classes.py (1 hunks)
  • src_py/sprite.py (2 hunks)
  • src_py/typing.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (18)
  • docs/readmes/README.zh-tw.rst
  • pyproject.toml
  • setup.cfg
  • buildconfig/stubs/pygame/display.pyi
  • docs/readmes/README.zh-cn.rst
  • docs/readmes/README.fr.rst
  • docs/readmes/README.ru.rst
  • README.rst
  • buildconfig/stubs/pygame/window.pyi
  • buildconfig/stubs/pygame/cursors.pyi
  • docs/readmes/README.ja.rst
  • buildconfig/stubs/pygame/transform.pyi
  • buildconfig/stubs/pygame/pixelarray.pyi
  • buildconfig/stubs/pygame/mixer.pyi
  • src_py/sprite.py
  • buildconfig/stubs/pygame/color.pyi
  • docs/readmes/README.it.rst
  • buildconfig/stubs/pygame/mask.pyi
🧰 Additional context used
🧬 Code graph analysis (16)
buildconfig/stubs/pygame/time.pyi (2)
src_c/event.c (1)
  • event (2565-2636)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/system.pyi (1)
src_py/_data_classes.py (1)
  • PowerState (6-14)
buildconfig/stubs/pygame/geometry.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/rect.pyi (2)
  • Rect (300-300)
  • FRect (301-301)
buildconfig/stubs/pygame/camera.pyi (3)
buildconfig/stubs/pygame/pixelarray.pyi (1)
  • surface (13-13)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/mixer.pyi (1)
  • init (17-24)
src_py/typing.py (6)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/typing.pyi (3)
  • rect (57-57)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-57)
src_py/sprite.py (2)
  • rect (128-129)
  • rect (132-133)
buildconfig/stubs/pygame/typing.pyi (5)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/_render.pyi (1)
buildconfig/stubs/pygame/_sdl2/video.pyi (5)
  • draw (66-74)
  • draw (111-113)
  • set_viewport (147-147)
  • to_surface (168-170)
  • update (102-102)
buildconfig/stubs/pygame/surface.pyi (4)
buildconfig/stubs/pygame/display.pyi (1)
  • masks (81-81)
src_py/__init__.py (1)
  • Surface (227-228)
buildconfig/stubs/pygame/sprite.pyi (4)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
  • set_clip (150-150)
src_py/sprite.py (3)
  • rect (128-129)
  • rect (132-133)
  • set_clip (1325-1335)
buildconfig/stubs/pygame/event.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/sprite.pyi (1)
src_py/sprite.py (32)
  • rect (128-129)
  • rect (132-133)
  • image (120-121)
  • image (124-125)
  • visible (322-327)
  • visible (330-331)
  • Sprite (97-264)
  • DirtySprite (267-359)
  • AbstractGroup (362-637)
  • add_internal (171-177)
  • add_internal (396-407)
  • add_internal (759-794)
  • add_internal (1115-1135)
  • add_internal (1424-1428)
  • sprite (1442-1448)
  • sprite (1451-1452)
  • layer (239-252)
  • layer (255-264)
  • layer (334-342)
  • layer (345-354)
  • clear (586-609)
  • clear (1304-1310)
  • repaint_rect (1312-1323)
  • set_clip (1325-1335)
  • get_clip (1337-1343)
  • set_timing_threshold (1377-1395)
  • set_timing_treshold (1358-1375)
  • GroupSingle (1398-1465)
  • collide_mask (1663-1687)
  • spritecollide (1690-1724)
  • groupcollide (1727-1756)
  • spritecollideany (1759-1789)
buildconfig/stubs/pygame/_sdl2/video.pyi (2)
buildconfig/stubs/pygame/window.pyi (2)
  • get_grabbed_window (7-7)
  • Window (9-498)
buildconfig/stubs/pygame/_render.pyi (12)
  • update (144-144)
  • Image (147-148)
  • Texture (76-144)
  • get_rect (143-143)
  • draw (12-12)
  • draw (107-115)
  • set_viewport (44-44)
  • scale (61-61)
  • scale (63-63)
  • target (65-65)
  • target (67-67)
  • blit (24-30)
buildconfig/stubs/pygame/rect.pyi (2)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (57-57)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/freetype.pyi (1)
buildconfig/stubs/pygame/font.pyi (10)
  • name (33-33)
  • size (69-69)
  • bold (37-37)
  • bold (39-39)
  • italic (41-41)
  • italic (43-43)
  • Font (31-87)
  • get_default_font (16-16)
  • get_fonts (17-17)
  • match_font (18-22)
buildconfig/stubs/pygame/font.pyi (1)
buildconfig/stubs/pygame/freetype.pyi (6)
  • name (58-58)
  • SysFont (20-26)
  • size (44-44)
  • size (46-46)
  • Font (42-195)
  • render (158-166)
buildconfig/stubs/pygame/math.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
src_py/typing.py (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/midi.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
🪛 Ruff (0.14.0)
setup.py

160-160: Avoid specifying long messages outside the exception class

(TRY003)


162-162: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: arm64
  • GitHub Check: AMD64
  • GitHub Check: x86
  • GitHub Check: build (ubuntu-22.04)
  • GitHub Check: aarch64
  • GitHub Check: i686
  • GitHub Check: x86_64
  • GitHub Check: msys2 (clang64, clang-x86_64)
  • GitHub Check: msys2 (mingw64, x86_64)
  • GitHub Check: msys2 (ucrt64, ucrt-x86_64)
  • GitHub Check: Debian (Bookworm - 12) [ppc64le]
  • GitHub Check: Debian (Bookworm - 12) [s390x]
  • GitHub Check: Debian (Bookworm - 12) [armv6]
  • GitHub Check: Debian (Bookworm - 12) [armv7]
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.14.0)
  • GitHub Check: dev-check
  • GitHub Check: build (macos-14)
  • GitHub Check: Pyodide build
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.10.17)
🔇 Additional comments (63)
buildconfig/stubs/pygame/_sdl2/touch.pyi (2)

1-1: LGTM!

The import change correctly removes Optional since the PEP 604 union syntax (| None) is used instead.


12-12: LGTM!

The return type annotation correctly uses Python 3.10+ PEP 604 union syntax (_FingerDict | None), which is semantically equivalent to Optional[_FingerDict] and aligns with the PR's modernization objectives.

buildconfig/stubs/pygame/camera.pyi (2)

2-2: LGTM! Import statement correctly updated for PEP 604 syntax.

The removal of Optional from the imports is appropriate since the file now uses Python 3.10's PEP 604 union syntax (X | None) throughout.


8-52: LGTM! Type annotations correctly modernized to PEP 604 syntax.

All function signatures have been properly updated:

  • Optional[str]str | None (line 8)
  • Union[str, int]str | int (line 37)
  • Optional[Surface]Surface | None (lines 27, 52)

The changes are semantically equivalent and align with Python 3.10+ best practices.

buildconfig/stubs/pygame/system.pyi (3)

6-6: LGTM! Import cleanup is correct.

Removing Optional from the imports is appropriate since the file now uses PEP 604 union syntax (T | None) throughout.


28-28: LGTM! PEP 604 union syntax correctly applied.

The migration from Optional[str] to str | None is semantically equivalent and aligns with Python 3.10+ best practices. The type annotation accurately reflects the documented behavior where country may be None if undetermined.


147-147: LGTM! Return type annotation modernized correctly.

The change from Optional[PowerState] to PowerState | None is correct and consistent with:

  • The function's documented behavior (returns None if power state is unknown)
  • The PowerState class definition, which already uses PEP 604 syntax
  • The PR's objective to modernize type stubs for Python 3.10+
buildconfig/stubs/pygame/freetype.pyi (1)

2-2: LGTM! Type annotations successfully modernized to Python 3.10+ syntax.

The changes correctly replace Optional[X] with X | None and Union[X, Y] with X | Y throughout the stub file. The semantics are preserved, and the new syntax aligns with PEP 604, which is available in Python 3.10+.

Also applies to: 21-21, 25-25, 30-30, 44-46, 137-137, 145-145, 160-162, 171-173, 180-180, 189-190

buildconfig/stubs/pygame/draw.pyi (2)

31-31: LGTM! Import cleanup is correct.

Removing the Union import is appropriate since the file now uses Python 3.10+ PEP 604 union syntax (|) instead.


572-572: LGTM! Type annotation modernized correctly.

The function signature has been properly updated to use PEP 604 union syntax (ColorLike | Surface), which is the idiomatic way to express union types in Python 3.10+. The semantics remain unchanged, and the docstring correctly documents the parameter.

buildconfig/stubs/pygame/event.pyi (2)

1-1: Excellent modernization with TypeAlias.

The addition of TypeAlias to the imports and the creation of _EventTypes type alias using PEP 604 syntax (|) is a clean refactoring that reduces duplication across multiple function signatures.

Also applies to: 36-36


40-50: Consistent migration to PEP 604 union syntax.

All function signatures have been correctly updated to use the modern | syntax instead of Union and Optional. The use of _EventTypes | None is consistent across get, peek, clear, set_blocked, and set_allowed functions.

buildconfig/stubs/pygame/time.pyi (1)

8-8: Clean migration to PEP 604 syntax.

The removal of Union from imports and the update to set_timer signature using int | Event is a straightforward and correct modernization to Python 3.10+ syntax.

Also applies to: 40-40

docs/readmes/README.fa.rst (1)

192-192: LGTM!

The CPython minimum version requirement has been correctly updated from 3.9 to 3.10 in the dependencies table, aligning with the PR's objective to drop Python 3.9 support.

docs/readmes/README.pt-br.rst (1)

138-138: LGTM!

The CPython minimum version requirement has been correctly updated to 3.10 in the Portuguese (Brazil) documentation.

docs/readmes/README.gr.rst (1)

143-143: LGTM!

The CPython minimum version requirement has been correctly updated to 3.10 in the Greek documentation.

docs/readmes/README.es.rst (1)

120-120: LGTM!

The CPython minimum version requirement has been correctly updated to 3.10. The mixed language text in the parenthetical appears to be a pre-existing issue in this outdated translation section (noted at line 112).

.github/workflows/run-ubuntu-checks.yml (1)

56-57: LGTM!

The CI matrix has been correctly updated to test Python 3.10.17 (new minimum) and 3.14.0, dropping support for Python 3.9.x versions. This ensures the codebase is validated against the updated minimum Python version.

setup.py (2)

65-65: LGTM!

The python_requires metadata has been correctly updated to require Python 3.10+, ensuring pip will enforce the minimum version requirement.


158-162: LGTM!

The runtime version checks and error messages have been consistently updated to require Python 3.10+ for both CPython and PyPy. All references to the minimum version are now aligned with the new requirement.

buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1)

13-13: LGTM!

The type annotation has been correctly modernized to use PEP 604 union syntax (str | None instead of Optional[str]), which is supported in Python 3.10+. This aligns with the new minimum Python version requirement.

buildconfig/stubs/pygame/scrap.pyi (1)

11-11: LGTM!

The type annotation has been correctly modernized to use PEP 604 union syntax (bytes | None instead of Optional[bytes]), consistent with Python 3.10+ features. The semantic meaning remains unchanged.

src_py/_data_classes.py (1)

7-8: LGTM!

The migration from Optional[int] to int | None correctly applies Python 3.10+ union syntax.

dev.py (2)

17-17: LGTM!

The removal of Union from imports aligns with the migration to PEP 604 union syntax.


89-89: LGTM!

The type annotation correctly uses Python 3.10+ union syntax (str | Path instead of Union[str, Path]).

buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1)

12-12: LGTM!

The error constructor signature correctly uses Python 3.10+ union syntax (str | None instead of Optional[str]).

buildconfig/stubs/pygame/rwobject.pyi (3)

1-1: LGTM!

The removal of Optional from imports aligns with the migration to PEP 604 union syntax.


5-10: LGTM!

All parameter type annotations correctly use Python 3.10+ union syntax (X | None instead of Optional[X]).


12-18: LGTM!

The overloaded function signatures correctly use Python 3.10+ union syntax for optional parameters.

buildconfig/stubs/pygame/_debug.pyi (3)

2-2: LGTM!

Adding TypeAlias import enables the use of explicit type aliases following PEP 613.


4-4: LGTM!

The ImportResult type alias correctly uses Python 3.10+ union syntax and explicit TypeAlias annotation.


6-10: LGTM!

All function signatures correctly use Python 3.10+ union syntax (X | None instead of Optional[X] or Union[X, None]).

src_py/typing.py (4)

18-18: LGTM!

Adding TypeAlias import enables explicit type alias annotations following PEP 613.


24-26: LGTM!

The type aliases correctly use Python 3.10+ union syntax and explicit TypeAlias annotations.


50-50: LGTM!

The ColorLike type alias correctly uses Python 3.10+ union syntax and explicit TypeAlias annotation.


60-62: LGTM!

The RectLike type alias correctly uses Python 3.10+ union syntax and explicit TypeAlias annotation with proper formatting.

buildconfig/stubs/pygame/image.pyi (2)

65-65: LGTM!

The removal of Optional and Union from imports aligns with the migration to PEP 604 union syntax.


180-180: LGTM!

The return type annotation correctly uses Python 3.10+ union syntax (tuple[int, int, int] | None instead of Optional[tuple[int, int, int]]).

buildconfig/stubs/pygame/typing.pyi (4)

18-18: LGTM!

Adding TypeAlias import enables explicit type alias annotations following PEP 613.


24-26: LGTM!

The type aliases correctly use Python 3.10+ union syntax and explicit TypeAlias annotations.


50-50: LGTM!

The ColorLike type alias correctly uses Python 3.10+ union syntax and explicit TypeAlias annotation.


60-62: LGTM!

The RectLike type alias correctly uses Python 3.10+ union syntax and explicit TypeAlias annotation with proper formatting.

buildconfig/stubs/pygame/math.pyi (4)

30-104: LGTM! Consistent modernization of _GenericVector type annotations.

The migration to PEP 604 union syntax (SequenceLike[float] | _TVec) is correctly applied across all methods. The pattern is consistent and maintains compatibility with the existing API surface.


110-189: LGTM! VectorElementwiseProxy type signatures correctly updated.

All binary operations, comparisons, and elementwise operations now consistently use float | _TVec | VectorElementwiseProxy[_TVec], which aligns with Python 3.10+ union syntax.


211-232: LGTM! Vector2 signatures modernized correctly.

The __init__ overloads and method signatures now use str | float | SequenceLike[float] | _TVec and SequenceLike[float] | _TVec patterns consistently.


276-324: LGTM! Vector3 signatures updated correctly.

All rotation methods and other operations now consistently accept SequenceLike[float] | _TVec for axis and vector parameters, following the same pattern as Vector2.

buildconfig/stubs/pygame/geometry.pyi (4)

2-2: LGTM! Correct import for Python 3.10+ TypeAlias.

The addition of TypeAlias to the imports enables explicit type alias declarations as used throughout this file.


11-15: LGTM! _CircleLike properly defined with TypeAlias.

The protocol property and type alias correctly use union syntax, making the type alias explicit and maintainable.


21-25: LGTM! _LineLike properly defined with TypeAlias.

Consistent with _CircleLike, the protocol and type alias follow the same modern typing pattern.


27-28: LGTM! Collision type aliases correctly updated.

Both _CanBeCollided and _CanBeIntersected use the modern union syntax appropriately.

buildconfig/stubs/pygame/sprite.pyi (7)

31-36: LGTM! Protocol properties correctly include None.

The _HasRect and _HasImageAndRect protocols properly declare that rect and image can be None, matching runtime behavior.


45-51: LGTM! Sprite properties correctly typed with None.

Both image and rect properties correctly include None in their type unions, consistent with the runtime initialization shown in src_py/sprite.py lines 102-106.


77-82: LGTM! Group type aliases and attributes correctly updated.

The recursive type aliases _GroupOrGroups and _SpriteOrSprites use modern union syntax correctly. The spritedict and lostsprites attributes properly handle None in their value types.


89-106: LGTM! AbstractGroup method signatures modernized.

Methods correctly use union syntax for optional parameters and return types. The clear method's bgd parameter properly accepts both Surface and callable types.


144-151: LGTM! LayeredDirty method signatures correctly updated.

The draw, set_clip, and get_clip methods properly use union syntax with None for optional parameters and return types.


159-160: LGTM! GroupSingle correctly handles None sprite.

Both the sprite attribute and __init__ parameter properly include None, matching the runtime behavior shown in src_py/sprite.py lines 1400-1403.


185-210: LGTM! Collision function signatures modernized correctly.

All collision-related functions now use union syntax for optional callback parameters and return types. The _SupportsCollideMask type alias properly uses union syntax for the protocol types.

buildconfig/stubs/pygame/font.pyi (6)

18-22: LGTM!

The migration to PEP 604 union syntax is correct and improves readability.


23-29: LGTM!

The migration to PEP 604 union syntax is correct, and the signature is consistent with the equivalent function in pygame.freetype (shown in relevant code snippets).


60-60: LGTM!

The migration to PEP 604 union syntax is correct and consistent with the Font class in pygame.freetype.


61-68: LGTM!

The migration to PEP 604 union syntax is correct. The type annotations appropriately reflect that text can be str, bytes, or None, and bgcolor is optional.


77-77: Confirm bytes support in Font.metrics The stub now allows bytes for text; please verify the underlying implementation (get_metrics) accepts bytes at runtime.


69-69: No action needed: Font.size/Font.metrics accept bytes
The C implementation uses _PGFT_EncodePyString, which branches on PyBytes_Check(obj), so both str and bytes are supported.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (4)
buildconfig/stubs/pygame/image.pyi (1)

180-196: Add typing-extensions to stubs dependencies in dev.py.

The codebase extensively uses typing_extensions across 18+ .pyi stub files (deprecated, Buffer, Self), but it is not declared in the stubs dependencies. This must be added to ensure stub tooling functions correctly:

-            "stubs": {"mypy==1.18.2", "numpy"},
+            "stubs": {"mypy==1.18.2", "numpy", "typing-extensions>=4.12"},
buildconfig/stubs/pygame/surface.pyi (2)

703-709: get_parent should be Optional.

Docs state None is returned when not a subsurface; signature currently forbids that.

-    def get_parent(self) -> Surface:
+    def get_parent(self) -> Surface | None:

122-130: Surface.init and convert() masks parameters typed too broadly; should restrict to int tuples only.

Pygame's masks parameter should be a sequence/tuple of integers (Rmask, Gmask, Bmask, Amask) that define bit-masks for pixel format. Current ColorLike annotation incorrectly permits str, int, and Color objects, weakening type safety.

Changes needed:

  1. Line 128 (__init__ masks): Change to tuple[int, int, int] | tuple[int, int, int, int] | None
  2. Line 290 (convert() masks): Apply same fix for consistency

Follow-up: Consider introducing a shared MasksLike type alias and using it consistently across both methods.

buildconfig/stubs/pygame/_render.pyi (1)

65-67: Allow clearing render target (accept None)

Renderer.target should be Texture | None to support resetting to the default target and to match _sdl2/video.pyi.

-    @property
-    def target(self) -> "Texture": ...
-    @target.setter
-    def target(self, value: "Texture") -> None: ...
+    @property
+    def target(self) -> "Texture | None": ...
+    @target.setter
+    def target(self, value: "Texture | None") -> None: ...
♻️ Duplicate comments (1)
buildconfig/stubs/pygame/sprite.pyi (1)

69-69: Include None in DirtySprite.source_rect (runtime initializes to None)

Matches src_py/sprite.py (source_rect = None). Keep stub in sync.

-    source_rect: FRect | Rect
+    source_rect: FRect | Rect | None
🧹 Nitpick comments (7)
dev.py (1)

88-120: Fix cmd_run return annotation to match behavior.

When capture_output=False, ret.stdout is None; current return type is str. Adjust annotation.

Apply:

-def cmd_run(
-    cmd: list[str | Path],
-    capture_output: bool = False,
-    error_on_output: bool = False,
-) -> str:
+def cmd_run(
+    cmd: list[str | Path],
+    capture_output: bool = False,
+    error_on_output: bool = False,
+) -> str | None:

Optionally, if you prefer always returning a string:

-    return ret.stdout
+    return ret.stdout or ""
buildconfig/stubs/pygame/window.pyi (1)

7-7: PEP 604 updates look consistent; consider a small DRY improvement.

To avoid repeating int | Point in multiple places, introduce a local alias.

Example:

@@
-from pygame.typing import Point, RectLike
+from pygame.typing import Point, RectLike
+from typing import TypeAlias
+
+WindowPosition: TypeAlias = int | Point
@@
-        position: int | Point = WINDOWPOS_UNDEFINED,
+        position: WindowPosition = WINDOWPOS_UNDEFINED,
@@
-    def position(self, value: int | Point) -> None: ...
+    def position(self, value: WindowPosition) -> None: ...

Same idea could be applied for Rect | None / RectLike | None if you want symmetrical aliases.

Also applies to: 90-96, 234-235, 248-250, 305-307

buildconfig/stubs/pygame/pixelarray.pyi (1)

36-40: Use SupportsIndex for index parameters.

Indexing accepts any int-like type. Prefer SupportsIndex to match Python typing conventions (used elsewhere in stubs, e.g., Color.getitem).

Apply:

-from typing import Any, TypeAlias, overload
+from typing import Any, SupportsIndex, TypeAlias, overload
@@
-    def __getitem__(self, index: int) -> PixelArray | int: ...
+    def __getitem__(self, index: SupportsIndex) -> PixelArray | int: ...
buildconfig/stubs/pygame/_debug.pyi (1)

2-7: Tighten Callable in ImportResult.

Spell out the callable signature to avoid “bare Callable” ambiguity in some type checkers.

-ImportResult: TypeAlias = tuple[str, bool, Callable | None]
+ImportResult: TypeAlias = tuple[str, bool, Callable[..., object] | None]
buildconfig/stubs/pygame/_sdl2/video.pyi (2)

83-86: Use ColorLike for modulation params to match the rest of the API

Texture.draw_triangle/Texture.draw_quad use Iterable[int]; other stubs (e.g., _render.pyi) use ColorLike. Aligning avoids drift and broadens accepted call sites.

Apply:

-        p1_mod: Iterable[int] = (255, 255, 255, 255),
-        p2_mod: Iterable[int] = (255, 255, 255, 255),
-        p3_mod: Iterable[int] = (255, 255, 255, 255),
+        p1_mod: ColorLike = (255, 255, 255, 255),
+        p2_mod: ColorLike = (255, 255, 255, 255),
+        p3_mod: ColorLike = (255, 255, 255, 255),
@@
-        p1_mod: Iterable[int] = (255, 255, 255, 255),
-        p2_mod: Iterable[int] = (255, 255, 255, 255),
-        p3_mod: Iterable[int] = (255, 255, 255, 255),
-        p4_mod: Iterable[int] = (255, 255, 255, 255),
+        p1_mod: ColorLike = (255, 255, 255, 255),
+        p2_mod: ColorLike = (255, 255, 255, 255),
+        p3_mod: ColorLike = (255, 255, 255, 255),
+        p4_mod: ColorLike = (255, 255, 255, 255),

Also applies to: 97-101


107-109: Optional: quote the forward reference for Image

texture_or_image: Texture | Image references Image within its own class. Quoting improves tool compatibility.

-        texture_or_image: Texture | Image,
+        texture_or_image: Texture | "Image",
buildconfig/stubs/pygame/sprite.pyi (1)

150-151: Confirm get_clip return type; may be None before first set_clip

src_py/sprite.py returns self._clip; it appears unset before first set_clip, suggesting None is possible. If so, widen return type.

-    def get_clip(self) -> FRect | Rect: ...
+    def get_clip(self) -> FRect | Rect | None: ...
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec71b2b and 384034b.

⛔ Files ignored due to path filters (5)
  • src_c/doc/display_doc.h is excluded by !src_c/doc/*
  • src_c/doc/image_doc.h is excluded by !src_c/doc/*
  • src_c/doc/surface_doc.h is excluded by !src_c/doc/*
  • src_c/doc/system_doc.h is excluded by !src_c/doc/*
  • src_c/doc/window_doc.h is excluded by !src_c/doc/*
📒 Files selected for processing (35)
  • buildconfig/stubs/pygame/_debug.pyi (1 hunks)
  • buildconfig/stubs/pygame/_render.pyi (7 hunks)
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/touch.pyi (2 hunks)
  • buildconfig/stubs/pygame/_sdl2/video.pyi (7 hunks)
  • buildconfig/stubs/pygame/camera.pyi (4 hunks)
  • buildconfig/stubs/pygame/color.pyi (2 hunks)
  • buildconfig/stubs/pygame/cursors.pyi (2 hunks)
  • buildconfig/stubs/pygame/display.pyi (5 hunks)
  • buildconfig/stubs/pygame/draw.pyi (2 hunks)
  • buildconfig/stubs/pygame/event.pyi (2 hunks)
  • buildconfig/stubs/pygame/font.pyi (3 hunks)
  • buildconfig/stubs/pygame/freetype.pyi (7 hunks)
  • buildconfig/stubs/pygame/geometry.pyi (2 hunks)
  • buildconfig/stubs/pygame/image.pyi (2 hunks)
  • buildconfig/stubs/pygame/mask.pyi (4 hunks)
  • buildconfig/stubs/pygame/math.pyi (8 hunks)
  • buildconfig/stubs/pygame/midi.pyi (3 hunks)
  • buildconfig/stubs/pygame/mixer.pyi (4 hunks)
  • buildconfig/stubs/pygame/pixelarray.pyi (2 hunks)
  • buildconfig/stubs/pygame/rect.pyi (6 hunks)
  • buildconfig/stubs/pygame/rwobject.pyi (1 hunks)
  • buildconfig/stubs/pygame/scrap.pyi (1 hunks)
  • buildconfig/stubs/pygame/sprite.pyi (6 hunks)
  • buildconfig/stubs/pygame/surface.pyi (9 hunks)
  • buildconfig/stubs/pygame/system.pyi (3 hunks)
  • buildconfig/stubs/pygame/time.pyi (2 hunks)
  • buildconfig/stubs/pygame/transform.pyi (17 hunks)
  • buildconfig/stubs/pygame/typing.pyi (3 hunks)
  • buildconfig/stubs/pygame/window.pyi (5 hunks)
  • dev.py (2 hunks)
  • src_py/_data_classes.py (1 hunks)
  • src_py/sprite.py (2 hunks)
  • src_py/typing.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • buildconfig/stubs/pygame/scrap.pyi
  • buildconfig/stubs/pygame/color.pyi
  • src_py/_data_classes.py
  • src_py/typing.py
  • buildconfig/stubs/pygame/cursors.pyi
  • buildconfig/stubs/pygame/midi.pyi
🧰 Additional context used
🧬 Code graph analysis (22)
buildconfig/stubs/pygame/mixer.pyi (3)
src_c/mixer.c (1)
  • pre_init (609-644)
buildconfig/stubs/pygame/mixer_music.pyi (1)
  • set_endevent (25-25)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/camera.pyi (3)
buildconfig/stubs/pygame/pixelarray.pyi (1)
  • surface (13-13)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/mixer.pyi (1)
  • init (17-24)
buildconfig/stubs/pygame/system.pyi (1)
src_py/_data_classes.py (1)
  • PowerState (5-13)
src_py/sprite.py (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/sprite.pyi (6)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
  • image (36-36)
  • image (45-45)
  • image (47-47)
buildconfig/stubs/pygame/draw.pyi (1)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/display.pyi (3)
buildconfig/stubs/pygame/window.pyi (2)
  • get_surface (349-366)
  • Window (9-498)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • update (102-102)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/pixelarray.pyi (2)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/typing.pyi (7)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
src_py/sprite.py (2)
  • rect (127-128)
  • rect (131-132)
src_py/typing.py (3)
  • rect (57-57)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-57)
buildconfig/stubs/pygame/event.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/geometry.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/rect.pyi (2)
  • Rect (300-300)
  • FRect (301-301)
buildconfig/stubs/pygame/rect.pyi (3)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (57-57)
  • SequenceLike (31-39)
src_py/sprite.py (2)
  • rect (127-128)
  • rect (131-132)
buildconfig/stubs/pygame/sprite.pyi (3)
src_py/sprite.py (30)
  • rect (127-128)
  • rect (131-132)
  • image (119-120)
  • image (123-124)
  • visible (321-326)
  • visible (329-330)
  • Sprite (96-263)
  • DirtySprite (266-358)
  • AbstractGroup (361-636)
  • add_internal (170-176)
  • add_internal (395-406)
  • add_internal (758-793)
  • add_internal (1114-1134)
  • add_internal (1423-1427)
  • sprite (1441-1447)
  • sprite (1450-1451)
  • layer (238-251)
  • layer (254-263)
  • layer (333-341)
  • layer (344-353)
  • clear (585-608)
  • clear (1303-1309)
  • repaint_rect (1311-1322)
  • set_clip (1324-1334)
  • get_clip (1336-1342)
  • GroupSingle (1397-1464)
  • collide_mask (1662-1686)
  • spritecollide (1689-1723)
  • groupcollide (1726-1755)
  • spritecollideany (1758-1788)
buildconfig/stubs/pygame/rect.pyi (6)
  • FRect (301-301)
  • Rect (300-300)
  • left (44-44)
  • left (46-46)
  • right (52-52)
  • right (54-54)
buildconfig/stubs/pygame/surface.pyi (3)
  • Surface (42-1051)
  • set_clip (652-663)
  • get_clip (665-672)
buildconfig/stubs/pygame/surface.pyi (3)
src_py/__init__.py (1)
  • Surface (227-228)
buildconfig/stubs/pygame/sprite.pyi (4)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
  • set_clip (150-150)
src_py/sprite.py (3)
  • rect (127-128)
  • rect (131-132)
  • set_clip (1324-1334)
buildconfig/stubs/pygame/window.pyi (3)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • get_grabbed_window (29-29)
src_c/window.c (1)
  • get_grabbed_window (119-133)
src_py/__init__.py (1)
  • Window (380-381)
buildconfig/stubs/pygame/time.pyi (2)
src_c/event.c (1)
  • event (2565-2636)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/transform.pyi (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/typing.pyi (2)
  • SequenceLike (31-39)
  • rect (57-57)
buildconfig/stubs/pygame/font.pyi (1)
buildconfig/stubs/pygame/freetype.pyi (8)
  • name (58-58)
  • SysFont (20-26)
  • size (44-44)
  • size (46-46)
  • Font (42-195)
  • render (158-166)
  • bgcolor (128-128)
  • bgcolor (130-130)
buildconfig/stubs/pygame/_render.pyi (3)
buildconfig/stubs/pygame/_sdl2/video.pyi (5)
  • draw (66-74)
  • draw (111-113)
  • set_viewport (147-147)
  • to_surface (168-170)
  • update (102-102)
buildconfig/stubs/pygame/mask.pyi (3)
  • draw (33-33)
  • to_surface (48-57)
  • angle (37-37)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/freetype.pyi (1)
buildconfig/stubs/pygame/font.pyi (10)
  • name (33-33)
  • size (69-69)
  • bold (37-37)
  • bold (39-39)
  • italic (41-41)
  • italic (43-43)
  • Font (31-87)
  • get_default_font (16-16)
  • get_fonts (17-17)
  • match_font (18-22)
buildconfig/stubs/pygame/_sdl2/video.pyi (3)
buildconfig/stubs/pygame/window.pyi (2)
  • get_grabbed_window (7-7)
  • Window (9-498)
src_c/window.c (2)
  • get_grabbed_window (119-133)
  • window (1470-1523)
buildconfig/stubs/pygame/_render.pyi (11)
  • update (144-144)
  • Image (147-148)
  • Texture (76-144)
  • get_rect (143-143)
  • draw (12-12)
  • draw (107-115)
  • scale (61-61)
  • scale (63-63)
  • target (65-65)
  • target (67-67)
  • blit (24-30)
buildconfig/stubs/pygame/math.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/mask.pyi (4)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
src_py/__init__.py (2)
  • Surface (227-228)
  • Mask (245-246)
buildconfig/stubs/pygame/_render.pyi (1)
  • to_surface (45-47)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • to_surface (168-170)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.10.17)
  • GitHub Check: Pyodide build
  • GitHub Check: x86_64
  • GitHub Check: aarch64
  • GitHub Check: i686
  • GitHub Check: dev-check
  • GitHub Check: x86
  • GitHub Check: AMD64
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.14.0)
  • GitHub Check: msys2 (ucrt64, ucrt-x86_64)
  • GitHub Check: msys2 (clang64, clang-x86_64)
  • GitHub Check: msys2 (mingw64, x86_64)
  • GitHub Check: build (ubuntu-22.04)
  • GitHub Check: Debian (Bookworm - 12) [armv7]
  • GitHub Check: build (macos-14)
  • GitHub Check: Debian (Bookworm - 12) [ppc64le]
  • GitHub Check: Debian (Bookworm - 12) [s390x]
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: Debian (Bookworm - 12) [armv6]
  • GitHub Check: build (windows-latest)
🔇 Additional comments (47)
buildconfig/stubs/pygame/time.pyi (1)

8-8: LGTM! Clean migration to PEP 604 union syntax.

The changes correctly modernize the type annotations by removing the Union import and updating the set_timer signature to use the Python 3.10+ union syntax (int | Event). This aligns perfectly with the PR objective to adopt Python 3.10-specific features.

Also applies to: 40-40

buildconfig/stubs/pygame/rwobject.pyi (1)

1-18: LGTM! Clean migration to PEP 604 union syntax.

The type stub correctly adopts Python 3.10's X | None syntax throughout, and the Optional import has been appropriately removed. All signatures are consistently updated with no semantic changes.

buildconfig/stubs/pygame/system.pyi (3)

6-6: LGTM! Clean removal of unused import.

The removal of Optional from the import statement is correct, as all usages have been migrated to the PEP 604 union syntax (T | None).


28-28: LGTM! Correct modernization of type annotation.

The migration from Optional[str] to str | None is semantically equivalent and correctly reflects that the country field can be None as documented in the docstring.


147-147: LGTM! Type annotation correctly modernized.

The migration from Optional[PowerState] to PowerState | None is correct and consistent with both the function's documented behavior and the PowerState class definition, which already uses PEP 604 union syntax.

buildconfig/stubs/pygame/_sdl2/touch.pyi (2)

1-1: LGTM! Clean migration to PEP 604 syntax.

The removal of Optional from the imports is correct, as the code now uses the modern | union syntax available in Python 3.10+.


12-12: LGTM! Modern type annotation syntax.

The migration from Optional[_FingerDict] to _FingerDict | None is correct and adopts the cleaner PEP 604 union syntax introduced in Python 3.10. The return type semantics remain unchanged.

buildconfig/stubs/pygame/transform.pyi (4)

18-18: LGTM! Clean migration to PEP 604 union syntax.

The import statement correctly removes Optional and Union as they're no longer needed with Python 3.10+'s native union syntax (|), while retaining Literal which is still required.


35-35: LGTM! Consistent migration of optional Surface parameters.

All dest_surface parameters have been correctly migrated from Optional[Surface] to Surface | None using the PEP 604 syntax. The transformation is semantically equivalent and consistent across all affected functions.

Also applies to: 54-54, 95-95, 114-114, 138-138, 195-195, 211-211, 237-237, 266-266, 302-302, 314-314, 333-333, 430-430, 466-466


53-53: LGTM! Clean union syntax for factor parameters.

The factor parameter type has been correctly migrated from Union[float, SequenceLike[float]] to float | SequenceLike[float] in both scale_by and smoothscale_by functions.

Also applies to: 137-137


267-267: LGTM! Remaining type annotations correctly migrated.

All remaining type annotations have been properly migrated to PEP 604 syntax:

  • palette_colors: Union[bool, int]bool | int
  • rect: Optional[RectLike]RectLike | None
  • search_color, set_color: Optional[ColorLike]ColorLike | None
  • search_surf: Optional[Surface]Surface | None

Also applies to: 290-290, 359-359, 361-361, 363-363, 365-365

buildconfig/stubs/pygame/draw.pyi (2)

31-31: LGTM: Import modernization aligns with Python 3.10+ requirements.

The import statement correctly retains only overload, which is needed for the aacircle function overloads. Removing Union and Optional imports is appropriate since PEP 604 union syntax (|) is now used throughout the file.


572-593: Type annotation correctly reflects pygame.draw.flood_fill capabilities.

The ColorLike | Surface union type is accurate—pygame.draw.flood_fill does support filling with either a solid color or a Surface pattern. The updated docstring appropriately documents this dual functionality. Since this is a stub file, implementation verification within the repository is not applicable; the type signature aligns with the actual pygame API.

buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1)

12-12: PEP 604 union migration looks good.

Signature stays semantically identical; no runtime impact expected.

buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1)

13-13: LGTM on return type modernization.

Consistent with 3.10+ stubs elsewhere.

dev.py (1)

17-17: Import cleanup is correct.

Dropping Union aligns with PEP 604 usage project-wide.

buildconfig/stubs/pygame/pixelarray.pyi (1)

2-3: Union/TypeAlias modernization looks good.

Importing EllipsisType directly (now that 3.9 is dropped) and introducing _PixelColor via TypeAlias align with the PR goals. No issues.

Also applies to: 9-10

buildconfig/stubs/pygame/display.pyi (1)

288-309: Optional→X|None conversions and overloads LGTM.

  • get_surface → Surface | None
  • update(rectangle|rectangles) accept X | None
  • set_caption icontitle: str | None
  • message_box parameters updated to X | None

Consistent with 3.10+ style; no behavioral change.

Also applies to: 681-687, 837-845

buildconfig/stubs/pygame/geometry.pyi (1)

2-3: TypeAlias migration and property unions look correct.

Use of TypeAlias and pipe unions across _CircleLike/_LineLike and properties matches the project-wide update. Forward references are fine in .pyi. No issues.

Also applies to: 11-15, 21-25, 27-28

buildconfig/stubs/pygame/surface.pyi (1)

421-427: Return/param Optional conversions LGTM.

  • get_colorkey → tuple[int, int, int, int] | None
  • get_alpha → int | None
  • set_clip(rect: RectLike | None)

All consistent with runtime behavior and modern typing.

Also applies to: 452-456, 652-659

buildconfig/stubs/pygame/font.pyi (1)

19-29: Font unions and new methods LGTM.

  • match_font/SysFont names accept str | bytes | Iterable[...] | None
  • Font.init filename: FileLike | None
  • render/text, bgcolor Optionals; size/metrics accept str | bytes
  • New getters/setters added

Consistent with pygame.font and freetype stubs. No issues.

Also applies to: 60-70, 77-88

buildconfig/stubs/pygame/_sdl2/video.pyi (1)

155-159: Confirm omission of _DrawableClass in Renderer.blit

_video.Renderer.blit limits source to Texture | Image, while _render.Renderer.blit also accepts _DrawableClass. If this is intentional API divergence, please confirm; otherwise, consider aligning.

buildconfig/stubs/pygame/rect.pyi (1)

19-19: LGTM on union/ellipsis typing updates

The switch to PEP 604 unions and EllipsisType looks consistent and correct across slicing, move_to, clipline, contains, and collide* APIs.

Also applies to: 141-141, 146-147, 158-158, 206-217, 244-244, 272-276, 282-286

buildconfig/stubs/pygame/mask.pyi (2)

14-16: LGTM on PEP 604 unions and None-handling

from_threshold/overlap/convolve/to_surface updates align with the broader migration and runtime semantics.

Also applies to: 26-26, 42-44, 50-57


58-60: Verify generic memoryview typing

memoryview[int] under sys.version_info >= (3, 12) may not be universally accepted by all type checkers yet; some expect plain memoryview.

Would you confirm current mypy/pyright support for parameterized memoryview on Python 3.12 stubs? If not broadly supported, consider falling back to memoryview.

buildconfig/stubs/pygame/freetype.pyi (1)

21-26: LGTM on freetype typing modernisation

Signatures and property types look consistent and accurate for 3.10+.

Also applies to: 30-33, 44-46, 137-142, 145-149, 160-166, 171-177, 180-185, 189-195

buildconfig/stubs/pygame/sprite.pyi (1)

77-79: Ignore this review comment; the code is correct.

The review's concern is outdated. Your project uses mypy==1.18.2, which fully supports recursive type aliases. Mypy added support for recursive aliases in 0.981 and enabled it by default in 0.991, so version 1.18.2 handles these without issue.

The recursive aliases in sprite.pyi work correctly—they're actively used throughout the file and pass type checking in CI. Option A would break type semantics by removing recursion. Option B (PEP 695) is not viable because your project supports Python >=3.10, and PEP 695 requires 3.12+.

No changes needed.

Likely an incorrect or invalid review comment.

buildconfig/stubs/pygame/math.pyi (4)

30-104: LGTM! Type annotations successfully modernized for Python 3.10+.

The migration from Union and Optional to pipe union syntax (PEP 604) is correctly applied across all _GenericVector methods. All type hints now use the cleaner A | B and X | None syntax, which is more readable and aligns with modern Python typing conventions.


110-189: LGTM! VectorElementwiseProxy type annotations correctly updated.

All method signatures in the VectorElementwiseProxy generic class now use the pipe union syntax consistently. The type hints correctly express float | _TVec | VectorElementwiseProxy[_TVec] for arithmetic operations and comparisons.


211-228: LGTM! Vector2 type annotations modernized.

Constructor and method overloads for Vector2 now correctly use str | float | SequenceLike[float] | _TVec and SequenceLike[float] | _TVec, replacing the older Union forms. The changes are consistent with the broader modernization effort.


276-297: LGTM! Vector3 type annotations updated correctly.

Constructor and rotation method signatures now use pipe union syntax consistently. The axis parameters correctly accept SequenceLike[float] | _TVec, and the deprecated methods maintain the same updated type hints.

src_py/sprite.py (3)

113-114: LGTM! Private attribute type annotations modernized.

The type hints for __image and __rect now correctly use pygame.surface.Surface | None and pygame.rect.Rect | None, replacing the older Optional syntax. These annotations are used for type checking and don't affect runtime behavior.


123-123: LGTM! Property setter type annotation updated.

The image setter now accepts pygame.surface.Surface | None, consistent with the private attribute type and modern Python 3.10+ syntax.


131-131: LGTM! Property setter type annotation updated.

The rect setter now accepts pygame.rect.Rect | None, consistent with the private attribute type and modern Python 3.10+ syntax.

buildconfig/stubs/pygame/mixer.pyi (5)

2-2: LGTM! Import statement simplified.

The import now only includes Any and overload from typing, as Optional and Union are no longer needed with Python 3.10+ pipe union syntax.


22-22: LGTM! Function parameter type annotation updated.

The devicename parameter in init() now uses str | None, correctly replacing Optional[str].


30-30: LGTM! Function parameter type annotation updated.

The devicename parameter in pre_init() now uses str | None, consistent with the init() function update.


44-45: LGTM! Function signatures updated correctly.

Both set_soundfont() and get_soundfont() now use str | None for the parameter and return type respectively, replacing the older Optional[str] syntax.


104-104: LGTM! Method parameter type annotation updated.

The set_endevent() method's type parameter now correctly uses int | Event, replacing Union[int, Event] with the more concise pipe union syntax.

buildconfig/stubs/pygame/camera.pyi (5)

2-2: LGTM! Import statement simplified.

The import now only includes Literal from typing, as Optional and Union are no longer needed with Python 3.10+ pipe union syntax.


8-8: LGTM! Function parameter type annotation updated.

The backend parameter in init() now uses str | None, correctly replacing Optional[str].


27-27: LGTM! Method parameter type annotation updated.

The dest_surf parameter in AbstractCamera.get_image() now uses Surface | None, consistent with Python 3.10+ syntax.


37-37: LGTM! Constructor parameter type annotation updated.

The device parameter in Camera.__init__() now uses str | int, correctly replacing Union[str, int] with the more concise pipe union syntax.


52-52: LGTM! Method parameter type annotation updated.

The surface parameter in Camera.get_image() now uses Surface | None, consistent with the abstract base class update.

buildconfig/stubs/pygame/event.pyi (3)

1-1: LGTM! Import statement updated correctly.

The import now includes TypeAlias from typing, which is needed for the modern type alias syntax on line 36.


36-36: LGTM! Type alias correctly modernized.

The _EventTypes alias now uses TypeAlias annotation with pipe union syntax (int | SequenceLike[int]), replacing the older Union form. This is the recommended way to define type aliases in Python 3.10+.


40-50: LGTM! Function signatures consistently updated.

All function parameters that accept optional event types now use _EventTypes | None, correctly replacing Optional[_EventTypes]. The changes are consistent across get(), peek(), clear(), set_blocked(), and set_allowed().

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src_py/typing.py (1)

56-61: Intentional Union[...] here is correct; do not convert to |.

Forward-ref to RectLike makes | problematic without stringifying all annotations; matching stub keeps Union here. Marking as resolved vs earlier suggestion.

Based on learnings

🧹 Nitpick comments (6)
buildconfig/stubs/pygame/math.pyi (1)

103-104: Optional future cleanup: consider typing_extensions.Self to simplify _TVec return/self types.

After this PR lands, using Self (from typing_extensions; stdlib in 3.11+) could reduce generic noise in methods like arithmetic ops and __round__. Defer to a follow‑up. Based on learnings

buildconfig/stubs/pygame/typing.pyi (1)

56-60: Complete the PEP 604 migration for _HasRectAttribute.rect.

Lines 56-58 claim that "on python < 3.14 new style unions would result in a syntax error" with forward references, but PEP 604 union syntax (X | Y) works correctly with string forward references in Python 3.10+. Since this PR raises the minimum to Python 3.10, line 60 should be updated for consistency.

Apply this diff:

-    # We still use old style Union[...] syntax here because RectLike is a
-    # forward reference and on python < 3.14 new style unions would result in a
-    # syntax error.
     @property
-    def rect(self) -> Union["RectLike", Callable[[], "RectLike"]]: ...
+    def rect(self) -> "RectLike" | Callable[[], "RectLike"]: ...

Also remove Union from the imports on line 18 and the cleanup section (lines 69-78) after this change.

Based on learnings

src_py/typing.py (1)

68-78: Optional: also del Union to keep namespace tidy.

Non-essential, but mirrors the cleanup of other typing imports.

 del (
     abstractmethod,
     Color,
     Rect,
     FRect,
     IO,
     Callable,
     TypeVar,
     Protocol,
+    Union,
 )
buildconfig/stubs/pygame/freetype.pyi (1)

30-33: Prefer Hashable for bold/italic to match font.pyi.

Align types with buildconfig/stubs/pygame/font.pyi (it uses Hashable), while keeping defaults.

-from typing import Any
+from typing import Any, Hashable
@@
-def match_font(
-    name: str | bytes | Iterable[str | bytes],
-    bold: Any = False,
-    italic: Any = False,
-) -> str: ...
+def match_font(
+    name: str | bytes | Iterable[str | bytes],
+    bold: Hashable = False,
+    italic: Hashable = False,
+) -> str: ...
src_py/sprite.py (1)

118-121: Add return annotations on getters to mirror stubs.

Improves type-checker fidelity and matches buildconfig/stubs/pygame/sprite.pyi.

 @property
-    def image(self):
+    def image(self) -> pygame.surface.Surface | None:
         return self.__image
@@
 @property
-    def rect(self):
+    def rect(self) -> pygame.rect.Rect | None:
         return self.__rect

Also applies to: 126-129

buildconfig/stubs/pygame/_render.pyi (1)

12-12: LGTM: _DrawableClass.draw uses PEP 604 and defaults.
Optional: consider adding explicit -> None in a follow‑up cleanup.

Based on learnings

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 384034b and 4b6bb5e.

⛔ Files ignored due to path filters (5)
  • src_c/doc/display_doc.h is excluded by !src_c/doc/*
  • src_c/doc/image_doc.h is excluded by !src_c/doc/*
  • src_c/doc/surface_doc.h is excluded by !src_c/doc/*
  • src_c/doc/system_doc.h is excluded by !src_c/doc/*
  • src_c/doc/window_doc.h is excluded by !src_c/doc/*
📒 Files selected for processing (52)
  • .github/workflows/build-sdl3.yml (1 hunks)
  • .github/workflows/run-ubuntu-checks.yml (1 hunks)
  • README.rst (1 hunks)
  • buildconfig/stubs/pygame/_debug.pyi (1 hunks)
  • buildconfig/stubs/pygame/_render.pyi (7 hunks)
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/touch.pyi (2 hunks)
  • buildconfig/stubs/pygame/_sdl2/video.pyi (7 hunks)
  • buildconfig/stubs/pygame/camera.pyi (4 hunks)
  • buildconfig/stubs/pygame/color.pyi (2 hunks)
  • buildconfig/stubs/pygame/cursors.pyi (2 hunks)
  • buildconfig/stubs/pygame/display.pyi (5 hunks)
  • buildconfig/stubs/pygame/draw.pyi (2 hunks)
  • buildconfig/stubs/pygame/event.pyi (2 hunks)
  • buildconfig/stubs/pygame/font.pyi (3 hunks)
  • buildconfig/stubs/pygame/freetype.pyi (7 hunks)
  • buildconfig/stubs/pygame/geometry.pyi (2 hunks)
  • buildconfig/stubs/pygame/image.pyi (2 hunks)
  • buildconfig/stubs/pygame/mask.pyi (4 hunks)
  • buildconfig/stubs/pygame/math.pyi (8 hunks)
  • buildconfig/stubs/pygame/midi.pyi (3 hunks)
  • buildconfig/stubs/pygame/mixer.pyi (4 hunks)
  • buildconfig/stubs/pygame/pixelarray.pyi (2 hunks)
  • buildconfig/stubs/pygame/rect.pyi (6 hunks)
  • buildconfig/stubs/pygame/rwobject.pyi (1 hunks)
  • buildconfig/stubs/pygame/scrap.pyi (1 hunks)
  • buildconfig/stubs/pygame/sprite.pyi (6 hunks)
  • buildconfig/stubs/pygame/surface.pyi (9 hunks)
  • buildconfig/stubs/pygame/system.pyi (3 hunks)
  • buildconfig/stubs/pygame/time.pyi (2 hunks)
  • buildconfig/stubs/pygame/transform.pyi (17 hunks)
  • buildconfig/stubs/pygame/typing.pyi (2 hunks)
  • buildconfig/stubs/pygame/window.pyi (5 hunks)
  • dev.py (2 hunks)
  • docs/readmes/README.es.rst (1 hunks)
  • docs/readmes/README.fa.rst (1 hunks)
  • docs/readmes/README.fr.rst (1 hunks)
  • docs/readmes/README.gr.rst (1 hunks)
  • docs/readmes/README.it.rst (1 hunks)
  • docs/readmes/README.ja.rst (1 hunks)
  • docs/readmes/README.pt-br.rst (1 hunks)
  • docs/readmes/README.ru.rst (1 hunks)
  • docs/readmes/README.zh-cn.rst (1 hunks)
  • docs/readmes/README.zh-tw.rst (1 hunks)
  • pyproject.toml (2 hunks)
  • setup.cfg (1 hunks)
  • setup.py (2 hunks)
  • src_py/_data_classes.py (1 hunks)
  • src_py/_debug.py (0 hunks)
  • src_py/sprite.py (2 hunks)
  • src_py/typing.py (2 hunks)
💤 Files with no reviewable changes (1)
  • src_py/_debug.py
✅ Files skipped from review due to trivial changes (1)
  • docs/readmes/README.it.rst
🚧 Files skipped from review as they are similar to previous changes (18)
  • docs/readmes/README.ja.rst
  • .github/workflows/run-ubuntu-checks.yml
  • docs/readmes/README.zh-cn.rst
  • buildconfig/stubs/pygame/draw.pyi
  • docs/readmes/README.zh-tw.rst
  • buildconfig/stubs/pygame/_sdl2/touch.pyi
  • docs/readmes/README.fr.rst
  • buildconfig/stubs/pygame/image.pyi
  • buildconfig/stubs/pygame/cursors.pyi
  • buildconfig/stubs/pygame/color.pyi
  • docs/readmes/README.fa.rst
  • README.rst
  • buildconfig/stubs/pygame/_debug.pyi
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi
  • buildconfig/stubs/pygame/surface.pyi
  • docs/readmes/README.gr.rst
  • docs/readmes/README.es.rst
  • buildconfig/stubs/pygame/transform.pyi
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ankith26
PR: pygame-community/pygame-ce#3616
File: buildconfig/stubs/pygame/sprite.pyi:144-146
Timestamp: 2025-10-17T07:12:35.663Z
Learning: In PR #3616 (Drop python 3.9), the scope is strictly limited to porting type syntax from Python 3.9 to Python 3.10+ style (replacing Optional[X] with X | None, Union[X, Y] with X | Y, etc.). Implementation fixes or runtime signature mismatches should not be flagged in this PR and will be addressed in future PRs.
📚 Learning: 2025-10-17T07:12:35.663Z
Learnt from: ankith26
PR: pygame-community/pygame-ce#3616
File: buildconfig/stubs/pygame/sprite.pyi:144-146
Timestamp: 2025-10-17T07:12:35.663Z
Learning: In PR #3616 (Drop python 3.9), the scope is strictly limited to porting type syntax from Python 3.9 to Python 3.10+ style (replacing Optional[X] with X | None, Union[X, Y] with X | Y, etc.). Implementation fixes or runtime signature mismatches should not be flagged in this PR and will be addressed in future PRs.

Applied to files:

  • buildconfig/stubs/pygame/sprite.pyi
  • setup.py
🧬 Code graph analysis (21)
buildconfig/stubs/pygame/scrap.pyi (1)
buildconfig/stubs/pygame/event.pyi (1)
  • get (39-43)
buildconfig/stubs/pygame/time.pyi (2)
src_c/event.c (1)
  • event (2565-2636)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/display.pyi (4)
buildconfig/stubs/pygame/window.pyi (2)
  • get_surface (349-366)
  • Window (9-498)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • update (102-102)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/event.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/_sdl2/video.pyi (3)
buildconfig/stubs/pygame/window.pyi (2)
  • get_grabbed_window (7-7)
  • Window (9-498)
src_c/window.c (2)
  • get_grabbed_window (119-133)
  • window (1470-1523)
buildconfig/stubs/pygame/_render.pyi (9)
  • update (144-144)
  • Texture (76-144)
  • get_rect (143-143)
  • draw (12-12)
  • draw (107-115)
  • scale (61-61)
  • scale (63-63)
  • target (65-65)
  • target (67-67)
buildconfig/stubs/pygame/system.pyi (1)
src_py/_data_classes.py (1)
  • PowerState (5-13)
buildconfig/stubs/pygame/window.pyi (3)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • get_grabbed_window (29-29)
src_c/window.c (1)
  • get_grabbed_window (119-133)
src_py/__init__.py (1)
  • Window (380-381)
src_py/sprite.py (3)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/sprite.pyi (6)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
  • image (36-36)
  • image (45-45)
  • image (47-47)
buildconfig/stubs/pygame/rect.pyi (1)
  • Rect (300-300)
buildconfig/stubs/pygame/pixelarray.pyi (3)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/_render.pyi (2)
buildconfig/stubs/pygame/_sdl2/video.pyi (5)
  • draw (66-74)
  • draw (111-113)
  • set_viewport (147-147)
  • to_surface (168-170)
  • update (102-102)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/typing.pyi (6)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
src_py/typing.py (3)
  • rect (60-60)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-60)
buildconfig/stubs/pygame/midi.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/bufferproxy.pyi (1)
  • write (23-27)
src_py/typing.py (4)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (3)
  • rect (60-60)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-60)
buildconfig/stubs/pygame/mixer.pyi (3)
src_c/mixer.c (1)
  • pre_init (609-644)
buildconfig/stubs/pygame/mixer_music.pyi (1)
  • set_endevent (25-25)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
buildconfig/stubs/pygame/rect.pyi (2)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (31-31)
  • rect (49-49)
  • rect (51-51)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (60-60)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/geometry.pyi (3)
buildconfig/stubs/pygame/draw.pyi (2)
  • circle (149-212)
  • line (374-424)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/rect.pyi (2)
  • Rect (300-300)
  • FRect (301-301)
buildconfig/stubs/pygame/font.pyi (1)
buildconfig/stubs/pygame/freetype.pyi (8)
  • name (58-58)
  • SysFont (20-26)
  • size (44-44)
  • size (46-46)
  • Font (42-195)
  • render (158-166)
  • bgcolor (128-128)
  • bgcolor (130-130)
buildconfig/stubs/pygame/sprite.pyi (1)
src_py/sprite.py (32)
  • rect (127-128)
  • rect (131-132)
  • image (119-120)
  • image (123-124)
  • visible (321-326)
  • visible (329-330)
  • Sprite (96-263)
  • DirtySprite (266-358)
  • AbstractGroup (361-636)
  • add_internal (170-176)
  • add_internal (395-406)
  • add_internal (758-793)
  • add_internal (1114-1134)
  • add_internal (1423-1427)
  • sprite (1441-1447)
  • sprite (1450-1451)
  • layer (238-251)
  • layer (254-263)
  • layer (333-341)
  • layer (344-353)
  • clear (585-608)
  • clear (1303-1309)
  • repaint_rect (1311-1322)
  • set_clip (1324-1334)
  • get_clip (1336-1342)
  • set_timing_threshold (1376-1394)
  • set_timing_treshold (1357-1374)
  • GroupSingle (1397-1464)
  • collide_mask (1662-1686)
  • spritecollide (1689-1723)
  • groupcollide (1726-1755)
  • spritecollideany (1758-1788)
buildconfig/stubs/pygame/freetype.pyi (1)
buildconfig/stubs/pygame/font.pyi (10)
  • name (33-33)
  • size (69-69)
  • bold (37-37)
  • bold (39-39)
  • italic (41-41)
  • italic (43-43)
  • Font (31-87)
  • get_default_font (16-16)
  • get_fonts (17-17)
  • match_font (18-22)
buildconfig/stubs/pygame/mask.pyi (4)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
src_py/__init__.py (2)
  • Surface (227-228)
  • Mask (245-246)
buildconfig/stubs/pygame/_render.pyi (1)
  • to_surface (45-47)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • to_surface (168-170)
buildconfig/stubs/pygame/math.pyi (2)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
src_py/typing.py (1)
  • SequenceLike (31-39)
🪛 Ruff (0.14.0)
setup.py

160-160: Avoid specifying long messages outside the exception class

(TRY003)


162-162: Avoid specifying long messages outside the exception class

(TRY003)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: x86_64
  • GitHub Check: msys2 (clang64, clang-x86_64)
  • GitHub Check: msys2 (mingw64, x86_64)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-24.04)
  • GitHub Check: x86_64
  • GitHub Check: dev-check
  • GitHub Check: i686
  • GitHub Check: aarch64
  • GitHub Check: Pyodide build
  • GitHub Check: Debian (Bookworm - 12) [ppc64le]
  • GitHub Check: Debian (Bookworm - 12) [armv6]
  • GitHub Check: Debian (Bookworm - 12) [s390x]
  • GitHub Check: Debian (Bookworm - 12) [armv7]
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.14.0)
  • GitHub Check: build (ubuntu-22.04)
  • GitHub Check: debug_coverage (ubuntu-24.04, 3.10.17)
  • GitHub Check: x86
  • GitHub Check: AMD64
🔇 Additional comments (93)
docs/readmes/README.ru.rst (1)

142-142: Version requirement update is consistent with PR scope.

The CPython minimum version has been correctly updated from 3.9 to 3.10 in the dependencies table, aligning with the PR's objective to drop Python 3.9 support. The reStructuredText table formatting remains unchanged.

Please verify that the corresponding line in docs/readmes/README.rst (English version) and other translation files have been updated consistently with the same version requirement change.

buildconfig/stubs/pygame/scrap.pyi (1)

11-11: LGTM! Type annotation correctly modernized to Python 3.10+ syntax.

The migration from Optional[bytes] to bytes | None follows PEP 604 union syntax and aligns perfectly with the PR's objective to modernize type stubs.

.github/workflows/build-sdl3.yml (1)

56-58: The review comment is based on a misunderstanding of the testing strategy and is incorrect.

The project explicitly declares support for Python 3.10 through 3.14 in both pyproject.toml (requires-python = ">=3.10") and package classifiers. Python 3.14 is an intentional, supported version.

More importantly, the build-sdl3.yml workflow serves a specific purpose: it is marked "WIP" for SDL3 porting. This is not the project's general compatibility testing workflow. The run-ubuntu-checks.yml workflow explicitly tests both the minimum (3.10.17) and maximum (3.14.0) Python versions, which addresses the concern about minimum version coverage.

The multi-workflow design is intentional: different workflows test different aspects (architectures, platforms, SDL versions, and Python versions across the full range). Testing Python 3.14 in the SDL3-specific workflow is appropriate for forward-compatibility with the latest version.

Likely an incorrect or invalid review comment.

buildconfig/stubs/pygame/math.pyi (7)

30-30: PEP 604 union migration for slice assignment looks correct.

SequenceLike[float] | _TVec preserves the previous intent and keeps same‑type vector assignment possible. Based on learnings


36-39: Arithmetic/aug‑assign overloads: syntax-only conversion LGTM.

The | unions for add/sub/mul and their in‑place forms match the prior Union[...] forms without changing accepted types or returns. Based on learnings

Also applies to: 41-41, 51-56


61-92: Vector ops (dot/reflect/distance/lerp/angle/move/project): consistent union updates.

All parameters now use SequenceLike[float] | _TVec; signatures remain semantically identical to prior stubs. Based on learnings

Also applies to: 103-103


104-104: Optional to int | None for __round__ is correct.

Matches PEP 604 and preserves default None. Based on learnings


112-117: VectorElementwiseProxy unions updated consistently across all binary ops and comparisons.

Accepts float | _TVec | VectorElementwiseProxy[_TVec] as before; no behavior shift. Based on learnings

Also applies to: 120-125, 128-133, 136-141, 144-149, 152-157, 160-167, 172-185


211-211: Vector2 constructor, cross, and update: union syntax modernization looks good.

str | float | SequenceLike[float] | _TVec mirrors earlier overload shape; 2D cross retains scalar return. Based on learnings

Also applies to: 222-222, 228-228


276-276: Vector3 constructor/cross/rotation/update: unions and overloads remain aligned.

Axis parameters now use SequenceLike[float] | _TVec; 3D cross returns _TVec as before. Based on learnings

Also applies to: 281-297, 321-321

docs/readmes/README.pt-br.rst (1)

138-138: LGTM!

The CPython minimum version update from >= 3.9 to >= 3.10 is consistent with the PR objectives.

setup.cfg (1)

2-2: LGTM!

The tox environment list correctly removes Python 3.9 and adds Python 3.14, aligning with the updated version requirements.

setup.py (2)

65-65: LGTM!

The Python version requirement correctly updated from >=3.9 to >=3.10.


158-162: LGTM!

The runtime version checks and error messages are consistently updated to require Python 3.10+.

dev.py (2)

17-17: LGTM!

Correctly removes the Union import as it's no longer needed with Python 3.10+ union syntax.


89-89: LGTM!

The type annotation correctly adopts Python 3.10+ PEP 604 union syntax (list[str | Path] instead of list[Union[str, Path]]).

buildconfig/stubs/pygame/system.pyi (3)

6-6: LGTM!

Correctly removes the Optional import as it's replaced by the PEP 604 union syntax.


28-28: LGTM!

The type annotation correctly adopts Python 3.10+ union syntax (str | None instead of Optional[str]).


147-147: LGTM!

The return type correctly adopts Python 3.10+ union syntax (PowerState | None instead of Optional[PowerState]).

pyproject.toml (2)

6-6: LGTM!

The Python version requirement correctly updated from >=3.9 to >=3.10.


79-79: LGTM!

The build pattern correctly removes Python 3.9 from the CPython versions and updates the PyPy pattern to pp311-*.

buildconfig/stubs/pygame/rwobject.pyi (3)

1-1: LGTM!

Correctly removes the Optional import as it's replaced by the PEP 604 union syntax.


5-10: LGTM!

The encode_string function signature correctly adopts Python 3.10+ union syntax for all optional parameters.


11-18: LGTM!

The encode_file_path overloads correctly adopt Python 3.10+ union syntax for optional parameters.

buildconfig/stubs/pygame/window.pyi (5)

7-7: LGTM!

The return type correctly adopts Python 3.10+ union syntax (Window | None instead of Optional[Window]).


94-94: LGTM!

The parameter type correctly adopts Python 3.10+ union syntax (int | Point instead of Union[int, Point]).


234-234: LGTM!

The return type correctly adopts Python 3.10+ union syntax (Rect | None instead of Optional[Rect]).


249-249: LGTM!

The parameter type correctly adopts Python 3.10+ union syntax (RectLike | None instead of Optional[RectLike]).


306-306: LGTM!

The parameter type correctly adopts Python 3.10+ union syntax (int | Point instead of Union[int, Point]).

buildconfig/stubs/pygame/pixelarray.pyi (2)

2-9: LGTM! Clean migration to Python 3.10+ type syntax.

The changes correctly:

  • Import EllipsisType from types (available in Python 3.10+)
  • Add TypeAlias to typing imports
  • Convert _PixelColor to use TypeAlias with PEP 604 union syntax

36-46: LGTM! Consistent union syntax migration.

All return type annotations have been properly migrated from Union[X, Y] to X | Y syntax, and EllipsisType is correctly used in the overload signature.

buildconfig/stubs/pygame/display.pyi (4)

55-55: LGTM! Proper import cleanup.

Optional has been correctly removed from the imports after migrating to PEP 604 union syntax.


288-314: LGTM! Consistent migration to union syntax.

All function signatures have been properly updated:

  • get_surface() return type: Surface | None
  • update() overloads: RectLike | None and Iterable[RectLike | None]

681-681: LGTM! Parameter type updated correctly.

The icontitle parameter has been migrated from Optional[str] to str | None.


837-845: LGTM! Complete union syntax migration.

All optional parameters in message_box() have been correctly updated to use PEP 604 syntax:

  • message: str | None
  • parent_window: Window | None
  • escape_button: int | None
buildconfig/stubs/pygame/event.pyi (3)

1-1: LGTM! Proper import migration.

Optional and Union have been correctly replaced with TypeAlias in the imports.


36-36: LGTM! TypeAlias declaration with PEP 604 syntax.

The _EventTypes alias has been properly migrated from Union[int, SequenceLike[int]] to use TypeAlias with the | operator.


39-51: LGTM! Consistent parameter type migration.

All function parameters have been correctly updated from Optional[_EventTypes] to _EventTypes | None:

  • get(): eventtype and exclude parameters
  • peek(), clear(), set_blocked(), set_allowed(): type parameters
buildconfig/stubs/pygame/time.pyi (2)

8-8: LGTM! Import cleanup after union syntax migration.

Union has been correctly removed from imports.


40-40: LGTM! Parameter type migrated to PEP 604 syntax.

The event parameter type has been properly updated from Union[int, Event] to int | Event.

buildconfig/stubs/pygame/midi.pyi (3)

19-21: LGTM! Parameter type migrated correctly.

The midis parameter type has been updated from Union[SequenceLike[int], int] to use PEP 604 syntax.


27-32: LGTM! Return type uses union syntax.

The read() return type has been properly updated to use list[int] | int within the nested list structure.


48-50: LGTM! Method signatures migrated consistently.

Both methods have been updated to use PEP 604 union syntax:

  • write(): nested union with SequenceLike[int] | int
  • write_sys_ex(): list[int] | str
buildconfig/stubs/pygame/typing.pyi (2)

24-50: LGTM! TypeAlias declarations migrated to PEP 604 syntax.

All the type aliases have been properly updated:

  • _PathLike, FileLike: use TypeAlias with | operator
  • Point, IntPoint: explicit TypeAlias annotations added
  • ColorLike: uses TypeAlias with union syntax

63-65: LGTM! RectLike migrated to TypeAlias with union syntax.

The RectLike type alias properly uses TypeAlias and PEP 604 syntax throughout.

buildconfig/stubs/pygame/_sdl2/video.pyi (4)

2-2: LGTM! Import cleanup completed.

Optional and Union have been correctly removed from the typing imports.


29-40: LGTM! Function signatures migrated consistently.

Both functions have been updated to use PEP 604 syntax:

  • get_grabbed_window() return: Window | None
  • messagebox() window parameter: Window | None

42-102: LGTM! Texture and Image classes fully migrated.

All optional parameters and return types have been consistently updated to PEP 604 syntax:

  • Texture.__init__(): scale_quality: int | None
  • Texture.draw(): srcrect, dstrect, origin parameters
  • Texture.update(): area parameter
  • Image.__init__(): texture_or_image: Texture | Image, srcrect: RectLike | None
  • Image.draw(): both parameters use | None
  • Image.origin: Iterable[float] | None

128-170: LGTM! Renderer class fully migrated to union syntax.

All method signatures have been properly updated:

  • set_viewport(): area: RectLike | None
  • target property: Texture | None
  • blit(): source: Texture | Image, optional parameters with | None
  • to_surface(): both parameters use | None
buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1)

11-12: LGTM! Parameter type migrated to PEP 604 syntax.

The message parameter has been correctly updated from Optional[str] to str | None.

src_py/typing.py (4)

18-18: Import set looks right; keep Union for forward-ref case.

Union is still needed for _HasRectAttribute.rect. All good.


24-26: TypeAlias migration LGTM.

_PathLike and FileLike correctly use 3.10 unions.


63-65: RectLike alias migration LGTM.

Matches the stub shape and maintains nested SequenceLike[Point].


3-5: No issues found — files are properly duplicated.

The verification confirms src_py/typing.py and buildconfig/stubs/pygame/typing.pyi are byte-for-byte identical, meeting the duplication requirement noted in the code comment.

buildconfig/stubs/pygame/freetype.pyi (1)

21-26: Union-to-| migrations read well and are consistent with 3.10+.

Signatures for SysFont, Font.size, ctor, get_rect/render APIs, and Noneables are updated correctly.

Also applies to: 44-46, 137-142, 145-149, 158-166, 168-177, 179-186, 188-195

src_py/_data_classes.py (1)

6-7: Dataclass Noneable unions LGTM.

int | None replacements are correct.

buildconfig/stubs/pygame/mixer.pyi (1)

22-23: Mixer stubs: union updates LGTM.

devicename, soundfont, and Channel.set_endevent are correctly expressed as 3.10 unions.

Also applies to: 30-31, 44-45, 104-104

buildconfig/stubs/pygame/camera.pyi (1)

8-8: Camera stubs modernization LGTM.

init, get_image, and device unions are correct and consistent.

Also applies to: 27-27, 37-40, 52-52

buildconfig/stubs/pygame/geometry.pyi (3)

2-2: LGTM: add TypeAlias import for PEP 613.
Matches project-wide typing direction.


11-11: LGTM: property unions switched to PEP 604.
circle/line now return X | Callable[[], X]; clear and consistent.

Also applies to: 21-21


13-15: LGTM: union aliases rewritten as TypeAlias.
_CircleLike, _LineLike, _CanBeCollided, _CanBeIntersected correctly use pipe syntax.

Based on learnings

Also applies to: 23-25, 27-28

buildconfig/stubs/pygame/_render.pyi (4)

2-2: LGTM: typing surface imports (Protocol/final).
Consistent with stubs style.


26-28: LGTM: Renderer.blit union modernization.
Source/dest/area rewritten with PEP 604; matches broader RectLike usage.


44-44: LGTM: Renderer viewport/to_surface accept RectLike | None.
In line with related stubs.

Also applies to: 46-47


85-86: LGTM: Texture signatures migrated to pipe syntax.
scale_quality, draw, update all consistent with 3.10 typing.

Also applies to: 109-115, 144-144

buildconfig/stubs/pygame/mask.pyi (5)

2-2: LGTM: trimmed typing import to Any only.
Reflects removal of Optional/Union usage.


14-16: LGTM: from_threshold othersurface: Surface | None.
Accurate optional param typing.


26-26: LGTM: overlap return type -> tuple[int, int] | None.
Clearer optional return.


42-44: LGTM: convolve output param -> Mask | None.
Modern optional typing; defaults preserved.


50-57: LGTM: to_surface parameters migrated to PEP 604 unions.
surface/setsurface/unsetsurface/setcolor/unsetcolor/dest/area all consistent.

Based on learnings

buildconfig/stubs/pygame/font.pyi (6)

2-2: LGTM: typing imports slimmed to Literal.
Union/Optional usage removed from this module.


19-22: LGTM: match_font name typing widened using pipe syntax.
Iterable element unions simplified correctly.


24-29: LGTM: SysFont signature modernization.
name allows None; constructor typed as Callable[...] | None; matches freetype.


60-60: LGTM: Font.init filename -> FileLike | None.
Straight Optional→union migration.


63-68: LGTM: Font.render text/bgcolor unions updated.
text accepts str | bytes | None; bgcolor -> ColorLike | None.


69-69: LGTM: size/metrics parameters use str | bytes.
Union pipe syntax consistent.

Based on learnings

Also applies to: 77-77

buildconfig/stubs/pygame/rect.pyi (6)

19-19: LGTM: import EllipsisType from types.
Matches modern typeshed style.


141-147: LGTM: getitem/setitem slice/Ellipsis unions.
Pipe syntax applied; value union kept as float | RectLike.


158-158: LGTM: move_to kwargs typed as float | Point.
Clearer than Union in kw-only context.


206-216: LGTM: clipline overload returns normalized.
tuple[tuple[_N, _N], tuple[_N, _N]] | tuple[()] across variants; consistent.


244-244: LGTM: contains param union with RectLike | _N.
Override kept with type: ignore; mirrors prior intent.


272-276: LGTM: collideobjects/collidedict unions modernized.
key: Callable[...] | None; return types use | None.

Based on learnings

Also applies to: 282-282, 286-286

buildconfig/stubs/pygame/sprite.pyi (11)

31-31: PEP 604 unions for Protocol accessors look good.
rect/image now use FRect | Rect | None and Surface | None respectively. Clean, Python 3.10+ friendly.

Also applies to: 36-36


45-51: Sprite.image/rect getters/setters: union syntax + None support LGTM.
Consistent with property semantics and broader 3.10 stub style.


69-69: DirtySprite.source_rect union modernized.
PEP 604 union applied consistently.


77-78: Recursive aliases _GroupOrGroups / _SpriteOrSprites look correct.
Readable 3.10-style unions; appropriate for stubs.


81-82: AbstractGroup containers typed with modern unions.
spritedict and lostsprites annotations are clear and precise.


89-89: add_internal layer parameter migrated to int | None.
Straightforward syntax port; no behavior change.


99-101: AbstractGroup.draw/clear signatures updated cleanly.
Union syntax for bgd and precise return type list[FRect | Rect] look good.

Also applies to: 104-104


144-146: LayeredDirty draw/set_clip/get_clip: PEP 604 updates LGTM.
Signatures use modern unions and remain clear. Sticking strictly to syntax porting in this PR. Based on learnings.

Also applies to: 150-151


159-160: GroupSingle optional sprite and constructor default None look good.
Matches typical usage patterns; clear to users.


185-185: collide_mask supports/return types migrated correctly.
Readable unions and precise tuple[int, int] | None return.

Also applies to: 189-189


197-197: collide functions: predicate and return typings updated to PEP 604.*
Consistent None handling across spritecollide/groupcollide/spritecollideany.

Also applies to: 204-204, 209-210

Copy link
Contributor

@aatle aatle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeAlias annotation is missing from 11 variables in stubs:

  • cursors._Small_string
  • cursors._Big_string
  • image._from_buffer_format
  • image._to_buffer_format
  • image._from_bytes_format
  • pixelcopy._kind
  • sprite._GroupOrGroups
  • sprite._SpriteOrSprites
  • sprite._SupportsCollideCircle
  • sprite._SupportsCollideMask
  • surface._ViewKind

Additionally, those private type aliases should be renamed to fit the _PascalCase convention.

Regex used - module-level variables, and not __all__ or a TypeVar:

^(?!__all__)[a-zA-Z_][a-zA-Z0-9_]* = (?!TypeVar)

@aatle aatle added Code quality/robustness Code quality and resilience to changes dependencies labels Oct 18, 2025
@ankith26
Copy link
Member Author

I have fixed the missing TypeAlias on the types you mentioned, thanks for catching those.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
buildconfig/stubs/pygame/rwobject.pyi (1)

6-10: PEP 604 migration looks good; minor typing nuance for etype

  • Overloads and X | None conversions are correct.
  • Consider tightening etype to type[UnicodeError] | None since encode/decode errors derive from UnicodeError; it’s a closer fit to the default UnicodeEncodeError. Optional, non-blocking.
    Based on learnings.

Also applies to: 13-18

buildconfig/stubs/pygame/mixer.pyi (1)

104-104: End-event type union is consistent; consider a shared alias

int | Event is fine. Optionally introduce a local TypeAlias (e.g., EndEventArg = int | Event) and reuse across mixer and mixer_music for consistency.
Based on learnings.

buildconfig/stubs/pygame/_debug.pyi (1)

3-7: Signatures align with runtime; optional readability alias

  • str_from_tuple/print_debug_info unions look right.
  • attempt_import returning tuple[str, bool, Callable | None] matches usage.
    Optionally add a TypeAlias ImportResult = tuple[str, bool, Callable | None] to improve readability without reintroducing typing.Optional/Union.
    Based on learnings.
buildconfig/stubs/pygame/cursors.pyi (1)

82-89: getitem return type misses mask-tuples for bitmap cursors

For bitmap cursors, self.data[2] and self.data[3] are tuple[int, ...]. Include that in the union to mirror runtime and the data attribute.

-    def __getitem__(self, index: int) -> int | IntPoint | Surface: ...
+    def __getitem__(self, index: int) -> int | IntPoint | tuple[int, ...] | Surface: ...

Non-blocking for this PR; can be a follow-up. Based on learnings.

buildconfig/stubs/pygame/pixelarray.pyi (1)

2-3: LGTM: 3.10+ typing updates look correct.

  • Direct import of EllipsisType and union syntax are appropriate for 3.10+.
  • _PixelColor TypeAlias is clear and useful.

Optional refinement:

  • For indexing, prefer typing.SupportsIndex to accept ints and index-like types.

Suggested diff (typing-only):

-from typing import Any, TypeAlias, overload
+from typing import Any, SupportsIndex, TypeAlias, overload
@@
-    def __getitem__(self, index: int) -> PixelArray | int: ...
+    def __getitem__(self, index: SupportsIndex) -> PixelArray | int: ...

Also applies to: 9-9, 36-40

src_py/sprite.py (1)

113-114: Typings updated to X | None: looks good.

Optional: import Surface/Rect and use the imported names for consistency and readability.

-from pygame.rect import Rect
+from pygame.rect import Rect
+from pygame.surface import Surface
@@
-        self.__image: pygame.surface.Surface | None = None
+        self.__image: Surface | None = None
@@
-    def image(self, value: pygame.surface.Surface | None):
+    def image(self, value: Surface | None):
@@
-    def rect(self, value: pygame.rect.Rect | None):
+    def rect(self, value: Rect | None):

Based on learnings.

Also applies to: 123-124, 131-132

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4b6bb5e and 1f001e9.

⛔ Files ignored due to path filters (5)
  • src_c/doc/display_doc.h is excluded by !src_c/doc/*
  • src_c/doc/image_doc.h is excluded by !src_c/doc/*
  • src_c/doc/surface_doc.h is excluded by !src_c/doc/*
  • src_c/doc/system_doc.h is excluded by !src_c/doc/*
  • src_c/doc/window_doc.h is excluded by !src_c/doc/*
📒 Files selected for processing (37)
  • buildconfig/stubs/pygame/_debug.pyi (1 hunks)
  • buildconfig/stubs/pygame/_render.pyi (7 hunks)
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi (1 hunks)
  • buildconfig/stubs/pygame/_sdl2/touch.pyi (2 hunks)
  • buildconfig/stubs/pygame/_sdl2/video.pyi (7 hunks)
  • buildconfig/stubs/pygame/camera.pyi (4 hunks)
  • buildconfig/stubs/pygame/color.pyi (2 hunks)
  • buildconfig/stubs/pygame/cursors.pyi (3 hunks)
  • buildconfig/stubs/pygame/display.pyi (5 hunks)
  • buildconfig/stubs/pygame/draw.pyi (2 hunks)
  • buildconfig/stubs/pygame/event.pyi (2 hunks)
  • buildconfig/stubs/pygame/font.pyi (3 hunks)
  • buildconfig/stubs/pygame/freetype.pyi (7 hunks)
  • buildconfig/stubs/pygame/geometry.pyi (2 hunks)
  • buildconfig/stubs/pygame/image.pyi (7 hunks)
  • buildconfig/stubs/pygame/mask.pyi (4 hunks)
  • buildconfig/stubs/pygame/math.pyi (8 hunks)
  • buildconfig/stubs/pygame/midi.pyi (3 hunks)
  • buildconfig/stubs/pygame/mixer.pyi (4 hunks)
  • buildconfig/stubs/pygame/pixelarray.pyi (2 hunks)
  • buildconfig/stubs/pygame/pixelcopy.pyi (1 hunks)
  • buildconfig/stubs/pygame/rect.pyi (6 hunks)
  • buildconfig/stubs/pygame/rwobject.pyi (1 hunks)
  • buildconfig/stubs/pygame/scrap.pyi (1 hunks)
  • buildconfig/stubs/pygame/sprite.pyi (8 hunks)
  • buildconfig/stubs/pygame/surface.pyi (10 hunks)
  • buildconfig/stubs/pygame/system.pyi (3 hunks)
  • buildconfig/stubs/pygame/time.pyi (2 hunks)
  • buildconfig/stubs/pygame/transform.pyi (17 hunks)
  • buildconfig/stubs/pygame/typing.pyi (2 hunks)
  • buildconfig/stubs/pygame/window.pyi (5 hunks)
  • dev.py (2 hunks)
  • src_py/_data_classes.py (1 hunks)
  • src_py/_debug.py (0 hunks)
  • src_py/sprite.py (2 hunks)
  • src_py/typing.py (2 hunks)
💤 Files with no reviewable changes (1)
  • src_py/_debug.py
🚧 Files skipped from review as they are similar to previous changes (9)
  • buildconfig/stubs/pygame/system.pyi
  • buildconfig/stubs/pygame/_sdl2/sdl2.pyi
  • buildconfig/stubs/pygame/_sdl2/controller_old.pyi
  • buildconfig/stubs/pygame/_render.pyi
  • buildconfig/stubs/pygame/color.pyi
  • buildconfig/stubs/pygame/midi.pyi
  • buildconfig/stubs/pygame/time.pyi
  • buildconfig/stubs/pygame/_sdl2/touch.pyi
  • dev.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ankith26
PR: pygame-community/pygame-ce#3616
File: buildconfig/stubs/pygame/sprite.pyi:144-146
Timestamp: 2025-10-17T07:12:35.663Z
Learning: In PR #3616 (Drop python 3.9), the scope is strictly limited to porting type syntax from Python 3.9 to Python 3.10+ style (replacing Optional[X] with X | None, Union[X, Y] with X | Y, etc.). Implementation fixes or runtime signature mismatches should not be flagged in this PR and will be addressed in future PRs.
📚 Learning: 2025-10-17T07:12:35.663Z
Learnt from: ankith26
PR: pygame-community/pygame-ce#3616
File: buildconfig/stubs/pygame/sprite.pyi:144-146
Timestamp: 2025-10-17T07:12:35.663Z
Learning: In PR #3616 (Drop python 3.9), the scope is strictly limited to porting type syntax from Python 3.9 to Python 3.10+ style (replacing Optional[X] with X | None, Union[X, Y] with X | Y, etc.). Implementation fixes or runtime signature mismatches should not be flagged in this PR and will be addressed in future PRs.

Applied to files:

  • buildconfig/stubs/pygame/sprite.pyi
🧬 Code graph analysis (22)
buildconfig/stubs/pygame/window.pyi (2)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • get_grabbed_window (29-29)
src_c/window.c (1)
  • get_grabbed_window (119-133)
buildconfig/stubs/pygame/mixer.pyi (4)
buildconfig/stubs/pygame/_sdl2/audio.pyi (2)
  • devicename (42-42)
  • frequency (46-46)
src_c/mixer.c (1)
  • pre_init (609-644)
buildconfig/stubs/pygame/mixer_music.pyi (1)
  • set_endevent (25-25)
buildconfig/stubs/pygame/event.pyi (1)
  • Event (28-29)
src_py/sprite.py (3)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/sprite.pyi (6)
  • rect (32-32)
  • rect (50-50)
  • rect (52-52)
  • image (37-37)
  • image (46-46)
  • image (48-48)
buildconfig/stubs/pygame/rect.pyi (1)
  • Rect (300-300)
buildconfig/stubs/pygame/draw.pyi (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/rect.pyi (1)
  • Rect (300-300)
buildconfig/stubs/pygame/rect.pyi (3)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (32-32)
  • rect (50-50)
  • rect (52-52)
buildconfig/stubs/pygame/typing.pyi (2)
  • rect (57-57)
  • SequenceLike (31-39)
src_py/typing.py (3)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/typing.pyi (3)
  • rect (57-57)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-57)
buildconfig/stubs/pygame/sprite.pyi (1)
src_py/sprite.py (30)
  • rect (127-128)
  • rect (131-132)
  • image (119-120)
  • image (123-124)
  • visible (321-326)
  • visible (329-330)
  • Sprite (96-263)
  • DirtySprite (266-358)
  • AbstractGroup (361-636)
  • add_internal (170-176)
  • add_internal (395-406)
  • add_internal (758-793)
  • add_internal (1114-1134)
  • add_internal (1423-1427)
  • sprite (1441-1447)
  • sprite (1450-1451)
  • layer (238-251)
  • layer (254-263)
  • layer (333-341)
  • layer (344-353)
  • clear (585-608)
  • clear (1303-1309)
  • repaint_rect (1311-1322)
  • set_clip (1324-1334)
  • get_clip (1336-1342)
  • GroupSingle (1397-1464)
  • collide_mask (1662-1686)
  • spritecollide (1689-1723)
  • groupcollide (1726-1755)
  • spritecollideany (1758-1788)
buildconfig/stubs/pygame/_debug.pyi (1)
src_py/_debug.py (3)
  • str_from_tuple (13-26)
  • attempt_import (29-54)
  • print_debug_info (84-186)
buildconfig/stubs/pygame/camera.pyi (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/mixer.pyi (1)
  • init (17-24)
buildconfig/stubs/pygame/display.pyi (2)
buildconfig/stubs/pygame/window.pyi (2)
  • get_surface (349-366)
  • Window (9-498)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/cursors.pyi (1)
src_py/cursors.py (2)
  • copy (219-224)
  • Cursor (92-243)
buildconfig/stubs/pygame/font.pyi (1)
buildconfig/stubs/pygame/freetype.pyi (8)
  • name (58-58)
  • SysFont (20-26)
  • size (44-44)
  • size (46-46)
  • Font (42-195)
  • render (158-166)
  • bgcolor (128-128)
  • bgcolor (130-130)
buildconfig/stubs/pygame/pixelarray.pyi (4)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
src_py/__init__.py (2)
  • Surface (227-228)
  • PixelArray (253-254)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/typing.pyi (9)
buildconfig/stubs/pygame/_render.pyi (2)
  • color (96-96)
  • color (98-98)
buildconfig/stubs/pygame/_sdl2/video.pyi (4)
  • color (62-62)
  • color (64-64)
  • color (124-124)
  • color (126-126)
buildconfig/stubs/pygame/color.pyi (1)
  • Color (12-94)
buildconfig/stubs/pygame/draw.pyi (1)
  • rect (37-98)
buildconfig/stubs/pygame/sprite.pyi (3)
  • rect (32-32)
  • rect (50-50)
  • rect (52-52)
src_py/sprite.py (2)
  • rect (127-128)
  • rect (131-132)
src_py/typing.py (3)
  • rect (57-57)
  • SequenceLike (31-39)
  • _HasRectAttribute (53-57)
buildconfig/stubs/typing_sample_app.py (1)
  • rect (100-101)
buildconfig/stubs/pygame/rect.pyi (2)
  • FRect (301-301)
  • Rect (300-300)
buildconfig/stubs/pygame/image.pyi (1)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/freetype.pyi (1)
buildconfig/stubs/pygame/font.pyi (10)
  • name (33-33)
  • size (69-69)
  • bold (37-37)
  • bold (39-39)
  • italic (41-41)
  • italic (43-43)
  • Font (31-87)
  • get_default_font (16-16)
  • get_fonts (17-17)
  • match_font (18-22)
buildconfig/stubs/pygame/_sdl2/video.pyi (3)
buildconfig/stubs/pygame/window.pyi (2)
  • get_grabbed_window (7-7)
  • Window (9-498)
src_c/window.c (2)
  • get_grabbed_window (119-133)
  • window (1470-1523)
buildconfig/stubs/pygame/_render.pyi (9)
  • update (144-144)
  • Texture (76-144)
  • get_rect (143-143)
  • draw (12-12)
  • draw (107-115)
  • scale (61-61)
  • scale (63-63)
  • target (65-65)
  • target (67-67)
buildconfig/stubs/pygame/mask.pyi (3)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/_render.pyi (1)
  • to_surface (45-47)
buildconfig/stubs/pygame/_sdl2/video.pyi (1)
  • to_surface (168-170)
buildconfig/stubs/pygame/transform.pyi (2)
buildconfig/stubs/pygame/surface.pyi (1)
  • Surface (42-1051)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/geometry.pyi (3)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
test/geometry_test.py (2)
  • line (1663-1664)
  • line (1670-1671)
buildconfig/stubs/pygame/rect.pyi (2)
  • Rect (300-300)
  • FRect (301-301)
buildconfig/stubs/pygame/event.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
buildconfig/stubs/pygame/math.pyi (1)
buildconfig/stubs/pygame/typing.pyi (1)
  • SequenceLike (31-39)
🪛 Flake8 (7.3.0)
src_py/typing.py

[error] 57-57: undefined name 'Callable'

(F821)

🪛 Ruff (0.14.0)
src_py/typing.py

57-57: Undefined name Callable

(F821)

🔇 Additional comments (39)
buildconfig/stubs/pygame/mask.pyi (1)

2-2: LGTM! Clean migration to Python 3.10+ type syntax.

All type annotations have been correctly migrated to PEP 604 union syntax:

  • Optional[X]X | None conversions throughout
  • Union[RectLike, Point]RectLike | Point on line 55
  • Import statement appropriately simplified (removed unused Optional and Union)
  • Buffer protocol methods correctly guarded by sys.version_info >= (3, 12) check
  • MaskType deprecation properly applied using typing_extensions.deprecated

The changes are consistent with similar to_surface signatures in _render.pyi and _sdl2/video.pyi.

Also applies to: 14-14, 26-26, 42-42, 50-56, 58-60, 62-63

buildconfig/stubs/pygame/pixelcopy.pyi (1)

1-1: LGTM! TypeAlias syntax correctly applied.

The migration to Python 3.10+ TypeAlias syntax is properly implemented. Extracting the Literal type into a reusable _Kind alias improves type maintainability and makes the signature more self-documenting.

Also applies to: 6-6, 11-11

buildconfig/stubs/pygame/draw.pyi (2)

31-31: LGTM!

The import statement correctly retains overload (needed for aacircle overloads) while removing Union, which is no longer necessary with PEP 604 union syntax in Python 3.10+.


572-572: LGTM! Type annotation now matches the documented behavior.

The signature correctly uses PEP 604 union syntax (ColorLike | Surface). The addition of Surface to the type union aligns the stub with the existing docstring (lines 579-581), which already documents that the color parameter accepts "a pattern to fill with, as a Surface."

buildconfig/stubs/pygame/freetype.pyi (5)

1-2: LGTM!

Import changes correctly reflect the migration to PEP 604 union syntax—Optional and Union are no longer needed.


20-33: LGTM!

Both SysFont and match_font signatures correctly migrated to PEP 604 union syntax, with nested unions properly flattened.


42-46: LGTM!

The size property getter and setter correctly use PEP 604 union syntax.


135-142: LGTM!

The __init__ method's file parameter correctly uses PEP 604 union syntax.


143-195: LGTM!

All rendering methods (get_rect, render, render_to, render_raw, render_raw_to) correctly migrated their optional parameters to PEP 604 union syntax.

buildconfig/stubs/pygame/scrap.pyi (1)

11-11: Union-syntax migration LGTM

Return type modernized to bytes | None; matches prior Optional semantics. No further changes needed.
If you want, I can run a quick grep to ensure docs/tutorials don’t still show Optional here. Based on learnings.

buildconfig/stubs/pygame/mixer.pyi (2)

22-23: devicename: str | None is correct

Matches CPython ‘z’ parsing (None allowed). Looks good.

Also applies to: 30-31


44-45: Type signature is correct — no sequence support

Verification confirmed: all set_soundfont() callsites in the codebase use only str | None types. Test file shows paths are passed as semicolon-separated strings (e.g., "test1.sf2;test2.sf2"), not as sequences. The type stub matches the intended API design.

buildconfig/stubs/pygame/cursors.pyi (1)

7-11: TypeAlias introductions and renames look good

Aliases (_SmallString/_BigString) and updated constant annotations improve clarity and 3.10+ style.
Based on learnings.

Also applies to: 43-47

buildconfig/stubs/pygame/geometry.pyi (1)

2-2: LGTM! Clean migration to Python 3.10+ union syntax.

The file consistently migrates all type aliases to use TypeAlias and PEP 604 union syntax (|), removing legacy Union forms. The changes align perfectly with the PR objective.

Also applies to: 11-11, 13-15, 21-21, 23-25, 27-28

buildconfig/stubs/pygame/event.pyi (1)

1-1: LGTM! Consistent migration to PEP 604 syntax.

The _EventTypes alias and all function signatures correctly use TypeAlias and the | operator. The migration is complete and consistent.

Also applies to: 36-36, 40-40, 42-42, 46-47, 49-50

buildconfig/stubs/pygame/font.pyi (1)

2-2: LGTM! Complete migration to modern union syntax.

All function signatures and type annotations correctly use PEP 604 syntax (|). The Union and Optional imports have been properly removed.

Also applies to: 19-19, 24-24, 28-28, 60-60, 63-63, 66-66, 69-69, 77-77

buildconfig/stubs/pygame/typing.pyi (1)

18-18: LGTM! Migration complete and past issues resolved.

All type aliases now correctly use TypeAlias and PEP 604 union syntax (|). The Union import has been removed (line 18), and _HasRectAttribute.rect (line 57) now uses the | operator. The past review concerns have been fully addressed.

Also applies to: 24-24, 26-26, 46-46, 48-48, 50-50, 57-57, 60-62

buildconfig/stubs/pygame/sprite.pyi (1)

9-9: LGTM! Syntax migration complete.

All type annotations have been successfully migrated to PEP 604 union syntax (|), and TypeAlias declarations are properly used throughout. The syntax porting is consistent and complete.

Based on learnings.

Also applies to: 32-32, 37-37, 46-48, 50-52, 70-70, 78-79, 82-83, 90-90, 100-101, 105-105, 145-147, 151-152, 160-161, 171-171, 186-186, 190-190, 198-198, 205-205, 210-211

buildconfig/stubs/pygame/transform.pyi (1)

18-18: LGTM! Complete and consistent migration.

All function signatures have been successfully updated to use PEP 604 union syntax (|). The Union and Optional imports have been removed, leaving only Literal as needed.

Also applies to: 35-35, 53-54, 95-95, 114-114, 137-138, 195-195, 211-211, 237-237, 266-267, 290-290, 302-302, 314-314, 333-334, 359-367, 430-430, 466-466

buildconfig/stubs/pygame/math.pyi (1)

2-11: LGTM! Comprehensive migration complete.

The file has been thoroughly migrated to PEP 604 union syntax across _GenericVector, VectorElementwiseProxy, Vector2, and Vector3. All legacy Union and Optional forms have been replaced with the | operator. The migration is consistent and complete throughout.

Also applies to: 30-30, 36-39, 41-41, 51-52, 54-54, 61-61, 70-75, 77-77, 80-84, 86-92, 103-104, 110-189, 211-211, 222-222, 228-229, 276-277, 281-297, 321-322

src_py/_data_classes.py (1)

6-7: LGTM! Clean migration to PEP 604 syntax.

The battery_percent and battery_seconds fields now correctly use int | None instead of Optional[int]. The migration is complete and the Optional import has been removed.

buildconfig/stubs/pygame/window.pyi (1)

7-7: LGTM: unions align with the API and other stubs.

  • get_grabbed_window(): Window | None matches behavior.
  • position and mouse_rect unions are consistent with Point/RectLike aliases.

No action needed.

Also applies to: 94-95, 234-235, 248-249, 305-306

buildconfig/stubs/pygame/display.pyi (1)

55-55: LGTM: consistent union migration and overloads.

  • get_surface -> Surface | None, update() overloads with RectLike | None, set_caption icontitle: str | None, and message_box parameter unions all align with docs and 3.10 style.

No further changes needed.

Also applies to: 288-289, 307-309, 681-681, 839-845

buildconfig/stubs/pygame/camera.pyi (1)

2-2: LGTM: camera stubs match the 3.10 style.

  • backend: str | None, device: str | int, and get_image Surface | None are appropriate and consistent with other modules.

Also applies to: 8-8, 27-27, 37-37, 52-52

buildconfig/stubs/pygame/image.pyi (2)

65-82: LGTM! TypeAlias definitions are correct.

The migration to explicit TypeAlias annotations for format types is clean and follows Python 3.10+ conventions. The three format aliases properly distinguish buffer, bytes-to, and bytes-from formats.


183-183: LGTM! Type annotations correctly migrated.

All return types and parameters have been properly updated to use Python 3.10+ union syntax and the new TypeAlias definitions.

Also applies to: 212-212, 226-226, 281-281, 296-296, 330-330

buildconfig/stubs/pygame/surface.pyi (5)

2-2: LGTM! TypeAlias import and definition are correct.

The _ViewKind TypeAlias properly captures all the supported view types for Surface buffer access.

Also applies to: 15-40


128-128: LGTM! Parameter types correctly migrated.

The masks, dest, and area parameters have been properly updated to use the modern union syntax.

Also applies to: 142-143


196-206: Type migration correctly applied.

The union syntax migration from Optional to | is correct for this method signature. The tuple typing itself has a pre-existing issue (flagged in past reviews), but that's outside the scope of this type syntax migration PR.


258-258: LGTM! Type annotations correctly updated.

All method signatures have been properly migrated to use the Python 3.10+ union syntax.

Also applies to: 351-351, 421-421, 452-452


652-652: LGTM! Parameter type correctly migrated.

The rect parameter has been properly updated to use the modern union syntax.

src_py/typing.py (2)

18-18: LGTM! Path and file type aliases correctly migrated.

The TypeAlias import and definitions for _PathLike and FileLike properly use Python 3.10+ union syntax.

Also applies to: 24-26


46-50: LGTM! Type aliases correctly defined.

All type aliases (Point, IntPoint, ColorLike, RectLike) have been properly updated with explicit TypeAlias annotations and modern union syntax.

Also applies to: 60-62

buildconfig/stubs/pygame/rect.pyi (3)

19-19: LGTM! EllipsisType import and union types correctly updated.

The unconditional import from types is appropriate for Python 3.10+, and the union syntax in __getitem__ and __setitem__ overloads is correct.

Also applies to: 141-146


158-158: LGTM! Method signatures correctly migrated.

The move_to and clipline signatures have been properly updated to use Python 3.10+ union syntax.

Also applies to: 208-216


244-244: LGTM! Collision detection methods correctly migrated.

All method signatures have been properly updated to use the modern union syntax for optional types and union parameters.

Also applies to: 272-276, 282-286

buildconfig/stubs/pygame/_sdl2/video.pyi (3)

2-2: LGTM! Module-level function signatures correctly migrated.

The removal of Optional from imports and the updated function signatures for get_grabbed_window and messagebox properly use Python 3.10+ union syntax.

Also applies to: 29-33


51-51: LGTM! Texture and Image class signatures correctly migrated.

All method signatures and properties have been properly updated to use the modern union syntax, consistent with the corresponding definitions in _render.pyi.

Also applies to: 68-71, 102-102, 107-115


147-169: LGTM! Renderer class signatures correctly migrated.

All method signatures and properties, including target, set_viewport, blit, and to_surface, have been properly updated to use Python 3.10+ union syntax.

Copy link
Contributor

@aatle aatle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

note: once this is merged, other open PRs will need to update their stubs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code quality/robustness Code quality and resilience to changes dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants