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 typing information #68

Closed
wants to merge 3 commits into from

Conversation

DorianCzichotzki
Copy link

@DorianCzichotzki DorianCzichotzki commented Jul 26, 2021

Greate work on tree-sitter and the python binding. The only issue I found was, that there are no type hints. That makes it very hard to work with the package.

I created this PR to add a stub file containing the type definitions for the C extension. This should help tools like mypy and IDEs to show docstrings and provide better code completion support.
I hope the definitions are complete.

@maxbrunsfeld
Copy link
Contributor

This is great. Is there a command we can run on CI that checks that the tests conform to the types declared in this file?

@lunixbochs
Copy link
Collaborator

Note there's another type stub I linked in this issue: #58

@DorianCzichotzki
Copy link
Author

@lunixbochs Sry did not see that.

@maxbrunsfeld I added mypy to check the test_tree_sitter.py module.

@DorianCzichotzki
Copy link
Author

I had to remove the mypy test for pypy. The typed-ast package is not able to build under pypy3.7 (see python/typed_ast#111).

@maxbrunsfeld
Copy link
Contributor

Ok, I approved it so it's running and we can see if the CI passes.

@lunixbochs You're more familiar with Python tooling. Do you like this solution for adding types? I'm cool with it, since it seems to pass on CI.

@DorianCzichotzki
Copy link
Author

Is there something missing or anything I can do to get it merged?

@lunixbochs
Copy link
Collaborator

@DorianCzichotzki were these manually written? I believe you don't need the ... if you also have a docstring.

@NorthIsUp
Copy link
Contributor

what is needed for this to merge, it would be super helpful!

@lunixbochs
Copy link
Collaborator

I just need to find some time to merge the two approaches and update the stubs.

@rorybyrne
Copy link

Any update on this PR? I'd also like to use it :)

@Akuli
Copy link
Contributor

Akuli commented Aug 19, 2022

I added tree-sitter stubs to typeshed. Run pip install types-tree-sitter to use them.

It would still be preferable to have them here, but it's a relatively small package, so typeshed maintainers will also do a good job of maintaining the stubs if the types never make it to py-tree-sitter.

@amaanq
Copy link
Member

amaanq commented Sep 5, 2023

Superseded by #150

@amaanq amaanq closed this Sep 5, 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.

7 participants