Skip to content

Conversation

@HarukaMa
Copy link
Contributor

@HarukaMa HarukaMa commented Oct 28, 2023

Add type hinting for the current available methods.

Type hinting helps SDK users and static type checkers to know the expected arguments and their expected types for methods, as native extensions don't expose them.

It looks like this after adding the type hinting:
image
(The docstring comes directly from the Rust code as PyO3 correctly stored them in the extension)

This PR is based on the #17, as the methods here currently are strictly ordered like the Rust code.

@HarukaMa HarukaMa marked this pull request as draft October 28, 2023 09:14
@HarukaMa HarukaMa marked this pull request as ready for review October 28, 2023 09:15
@kpp
Copy link
Contributor

kpp commented Oct 30, 2023

Constructors and dunder methods are not covered. However I am not a Python developer, I don't know how it can affect the experience.

@HarukaMa
Copy link
Contributor Author

Most dunder methods should have their definitions in base types, like

class object:
	...
	def __eq__(self, __o: object) -> bool: ...

which can be found in the typeshed repo. Redefining them to stricter types won't actually work for static type checkers.

As for constructors, it seems only Account and PrivateKey have it defined and both are just def __new__(cls) -> Self, so it should work fine.

@kpp
Copy link
Contributor

kpp commented Nov 24, 2023

This PR is replaced by #22

@HarukaMa HarukaMa closed this Nov 24, 2023
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