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

Typing annotations and typechecking with mypy or pyright? #385

Open
moy opened this issue Feb 9, 2022 · 3 comments
Open

Typing annotations and typechecking with mypy or pyright? #385

moy opened this issue Feb 9, 2022 · 3 comments
Labels
easy? Probably easy to implement, or WIP almost complete

Comments

@moy
Copy link
Collaborator

moy commented Feb 9, 2022

We already have basic static analysis with flake8 (and the underlying pyflakes), but using typing annotations and a static typechecker may 1) find more bugs, 2) help our users by providing completion and other smart features in their IDE.

mypy is the historical typechecker, pyright is a more recent one which in my (very limited) experience works better (it's also the tool behind the new Python mode of VSCode). So I'd suggest pyright if we don't have arguments to choose mypy.

For now, neither tool can typecheck the project without error, so a first step would be to add the necessary annotations to get an error-free pyright check.

@moy moy added the easy? Probably easy to implement, or WIP almost complete label Feb 9, 2022
@hemberger
Copy link
Contributor

Great suggestion! I'm 100% on board with adding type annotations. I'll let this sit for a while in case anyone wants to use this as a way to get involved with MechanicalSoup, but if there are no takers for a while (a month? a year?) then I'd be happy to add them myself.

@gophra
Copy link

gophra commented May 7, 2022

I want to get involved with this issue. What I should do?

@hemberger
Copy link
Contributor

@gophra Thanks for offering to get involved! As far as I understand, type annotations can be added incrementally, so I think getting some infrastructure for testing the type annotations would be important. I see a lot of unofficial GitHub Actions for both pyright and mypy, so it'd be really useful to get something like that set up.

Alternatively, if you aren't comfortable working with GitHub Actions, starting to typehint a few functions would still be a great start. How you contribute is totally up to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy? Probably easy to implement, or WIP almost complete
Projects
None yet
Development

No branches or pull requests

3 participants