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

Add sudachipy.pyi #149

Merged

Conversation

mh-northlander
Copy link
Collaborator

@mh-northlander mh-northlander commented Oct 26, 2021

Fixes #147

Add pyi file for type hints. sudachipy.pyi is enough to cover all classes.
I used mypy's stubgen cli tool to generate base of pyi file.

Also fix type signatures. The annotation for positional-only parameters was wrong.
ref: PEP570

@mh-northlander mh-northlander added the python Python binding-related label Oct 26, 2021
@mh-northlander mh-northlander added this to the 0.6 milestone Oct 26, 2021
@eiennohito
Copy link
Collaborator

eiennohito commented Oct 27, 2021

Some questions:

  1. How difficult is to sync .pyi with the Rust code? E.g. when adding new functions.
  2. IDEs usually show documentations from Python docstrings, how .pyi interact with Rust comments? Are they shown in IDEs? (Checking both PyCharm and VS Code is sufficient).

@mh-northlander
Copy link
Collaborator Author

  1. How difficult is to sync .pyi with the Rust code? E.g. when adding new functions.

Currently it is handmade. We need to update pyi manually.

  1. IDEs usually show documentations from Python docstrings, how .pyi interact with Rust comments? Are they shown in IDEs? (Checking both PyCharm and VS Code is sufficient).

a. PyCharm
Editor shows rust comments (I guess it shows __doc__). If we add comments to pyi, it overwrites rust comments.

b. VSCode
Rust comments are not visible from the editor. If we add comments to pyi, they're shown.

@eiennohito
Copy link
Collaborator

OK, let's go the manual path until the API surface becomes too large to support.

So, Rust comments on the API should be reflected in .pyi file, probably copying them verbatim will do.

@mh-northlander mh-northlander merged commit 0e34628 into WorksApplications:develop Oct 27, 2021
@mh-northlander mh-northlander deleted the 147-add-type-hints branch October 27, 2021 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Python binding-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide type hints for Python API
2 participants