Skip to content
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

Improve generated type hints and defaults #606

Merged
merged 8 commits into from
Oct 1, 2024
Merged

Conversation

almarklein
Copy link
Member

@almarklein almarklein commented Sep 27, 2024

  • The logic in codegen that produces the method signatures is improved:
    • It produces type annotations without quotes.
    • The annotation is wrapped in Optional[..] if needed.
    • It takes the optional keyword in idl into account.
    • It no longer has None as a default value in cases where it should not.
    • It also generates type hints for methods that do not only consist of a descriptor.
  • Can enable one lint rule that we disabled earlier.
    • TBH this was the reason I started this. Thought it was a quick fix, but ended up improving codegen for consistency with IDL quite a bit :)
  • Apply check_struct() in a few more places, because the above fixes made the checker detect more cases.
  • Enable making some args optional, even though IDL says they're not.
    • In practice this means that this PR does not introduce any backwards incompatible changes.
    • The cases where we apply this, include e.g. the depth_stencil arg in create_render_pipeline(). It's odd that IDL makes that field mandatory, because it means one cannot create a render pipeline without a depth-stencil attachment? We will have to look into this deeper when we implement the JS backend. It could well be an oversight in the IDL.

@almarklein almarklein marked this pull request as ready for review September 30, 2024 09:50
@almarklein almarklein requested a review from Korijn as a code owner September 30, 2024 09:50
@almarklein almarklein merged commit af9f091 into main Oct 1, 2024
20 checks passed
@almarklein almarklein deleted the codegen-type-hints branch October 1, 2024 19:18
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.

2 participants