-
Notifications
You must be signed in to change notification settings - Fork 40
Fix pyray stubs to match runtime exports #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Some (maybe all????) of the constants you have added were already present. For example, you added ARROWS_SIZE but it's already there as GuiScrollBarProperty.ARROWS_SIZE. |
|
thanks, i'll narrow this pr to non-deprecated module-level constants and drop the blanket enum parity behavior, so deprecated shorthand names like ARROWS_SIZE won’t be newly typed. converting to draft for now. |
|
thanks again for the quick feedback, and sorry for the initial overreach here. i misunderstood the intended direction and typed far too many top-level names in my first pass. i've now narrowed this pr to match what I think is the existing policy:
if this still doesn’t match your intended API/stub direction, i can trim it further, including reducing mostly coming here because i got hundreds of typecheck errors from ty for what i think is acceptable valid usage. some of them might be wrong deprecated usage, but im sure some are legitimately missing. |
|
i switched usages to enum-qualified forms (e.g. after that cleanup, the only unresolved names left are these six
so this no longer depends on typing broad top-level enum shorthand. it looks like a narrow missing-constants case for |
|
Those are defined in |
|
OK I'm pretty sure the way to fix this is as I suggested (but it would require me to do a little more processing to get the pyi format right from defines.py.) However doing that means adding quite a few entries into the pyray toplevel namespace that pops up in Pycharm IDE autocomplete. That's not very nice, so I'm not sure if it's a good idea. Another solution is just to |
|
thanks, this is very helpful context. i looked into this a bit more and i think the remaining these constants are defined in that could explain why i think this leaves us with two options: keep i don't have a strong preference here, i mainly want to align with your intended vision and direction for the api. |
Summary
This PR aligns
pyraytype stubs with what the module actually exports at runtime.Changes included:
create_stub_pyray.pyfrom enum values +raylib.definesTexture2D = Texture)pyray/__init__.pyiwith top-level names users access in practice (for example:BLEND_ALPHA,MOUSE_BUTTON_LEFT,RL_QUADS,RL_SRC_ALPHA,TEXTURE_FILTER_POINT)tests/run_tests.shandtests/run_tests_dynamic.shtychecks optional in runners (only executed when thetyCLI is available)PYRAY_STUB_PATHMotivation
Runtime exports and
pyray/__init__.pyihad drifted, which produced false positives in type checkers for valid API usage.In particular, this showed up in
tyas unresolved module attributes andTexture/Texture2Dassignability issues, despite runtime behavior being correct.Validation
uv run --with pytest python -m pytest tests/test_pyray_stub_parity.pyuv run ty check tests/typing/pyray_stub_smoke.pyuv run --with mypy mypy tests/typing/pyray_stub_smoke.pybash -n tests/run_tests.shbash -n tests/run_tests_dynamic.sh