Skip to content

add type hints for properties #703

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

Vipitis
Copy link
Contributor

@Vipitis Vipitis commented Apr 9, 2025

follow up to #697

goal is to add type annotations to properties in _classes.py via codegen.
A lot of properties resolve to simple int or str python types while others are enums.

Will look into expanding resolve_type where it's needed or find better workarounds for features/limits. I am not 100% sure how type hints get inherited from these stubs, as there have been changes every single python release.

}
name = pythonmap.get(name, name)

# Is this a case for which we need to recurse?
if name.startswith("sequence<") and name.endswith(">"):
if (name.startswith("sequence<") or name.startswith("FrozenArray<")) and name.endswith(">"):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the spec says this is not a sequence type: https://webidl.spec.whatwg.org/#idl-frozen-array but I believe in python it's list either way. Plus is is currently just used for GPUCompilationInfo which is unimplemented in wgpu-native

@@ -11,7 +11,10 @@
### Patching API for _classes.py
* Diffs for GPU: add enumerate_adapters_async, add enumerate_adapters_sync, change get_preferred_canvas_format, change request_adapter_async, change request_adapter_sync
* Diffs for GPUCanvasContext: add get_preferred_format, add present
* Error resolving type for GPUAdapter.limits: ('Encountered unknown IDL type: ', 'SupportedLimits')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the situation for Limits sounds more complex: gpuweb/gpuweb#4277
But I guess it will be set, maybe list eventually. We can also just not annotate it for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant