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 type hints #2000

Closed
RobertCraigie opened this issue Feb 6, 2022 · 2 comments · Fixed by #2003
Closed

Add type hints #2000

RobertCraigie opened this issue Feb 6, 2022 · 2 comments · Fixed by #2003

Comments

@RobertCraigie
Copy link
Contributor

RobertCraigie commented Feb 6, 2022

Is your feature request related to a problem? Please describe.

Type hints are just a general improvement :)

Describe the solution you'd like

Provide in-line type hints and mark the package as providing types by including a py.typed file in the distribution.

Additional context

You could also provide type stubs as pyright can automatically generate them for you, removing some of the work required for this:

pyright --createstub locust
@cyberw
Copy link
Collaborator

cyberw commented Feb 6, 2022

Oh, are they not visible when doing a package install? (as opposed to a source install)

Or do you mean a type hint for a specific thing?

Either way, PRs welcome!

@RobertCraigie
Copy link
Contributor Author

Ah sorry I should've clarified my situation. I use pyright which complains if a library doesn't provide in-line type hints or type stubs. Pyright only considers a library to provide in-line type hints if it has a py.typed file in the root directory of the library because of PEP 561.

I also ran into some parts of the public API that didn't have type hints (like @task) which pyright also doesn't like because I'm using strict mode.

I fixed these errors by running pyright --createstub locust and then manually adding some missing type hints to the parts of the interface that I'm using.

I'll have a look through the code base and if I have time I'll create a PR to add some missing type hints and provide the py.typed file :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants