Skip to content

chore: add type hint in qgc#34

Merged
armoha merged 2 commits intoarmoha:mainfrom
SaidBySolo:chore/add-type-hint-qgc
Aug 6, 2025
Merged

chore: add type hint in qgc#34
armoha merged 2 commits intoarmoha:mainfrom
SaidBySolo:chore/add-type-hint-qgc

Conversation

@SaidBySolo
Copy link
Contributor

@SaidBySolo SaidBySolo commented Aug 5, 2025

I am not yet familiar with this library, and I inferred the type by following the function call, so the type may be incorrect.

I used a union type because I confirmed that type conversion was performed.

Expressions such as int | c.EUDVariable | c.ConstExpr appeared repeatedly, which caught my eye. Therefore, it seems that this part could be separated into type variables.

This may not make sense because the EUDFunc decorator overwrites the type entirely.

Might also consider adding types to decorators, referring to PEP-612

If the type annotation is too wrong or different from what was intended, you may close the PR.

Copy link
Owner

@armoha armoha left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and feedback!

I am not yet familiar with this library, and I inferred the type by following the function call, so the type may be incorrect.

I used a union type because I confirmed that type conversion was performed.

eudplib involves many implicit type conversions, so adding accurate type hints can be cumbersome—but it's a worthwhile effort that helps identify flaws and potential bugs.

Expressions such as int | c.EUDVariable | c.ConstExpr appeared repeatedly, which caught my eye. Therefore, it seems that this part could be separated into type variables.

This may not make sense because the EUDFunc decorator overwrites the type entirely.

Might also consider adding types to decorators, referring to PEP-612

Functions decorated with @EUDFunc are called at most once when used, and the function receives arguments that are EUDVariables type-casted to the declared parameter types. I haven't studied how to properly annotate such decorators yet, so thank you for pointing me to PEP-612!


I haven’t added type hints to EUDFunc and EUDStruct yet due to their complexity. In my opinion, restructuring the code—similar to converting a dynamic class to a static one—might help untangle and alleviate the current situation.

@armoha armoha merged commit 7a1ed9c into armoha:main Aug 6, 2025
0 of 4 checks passed
@armoha
Copy link
Owner

armoha commented Aug 6, 2025

Looks good to me, thanks for your contribution!

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