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 annotations #892

Open
sebastinas opened this issue Apr 6, 2021 · 17 comments
Open

Add type annotations #892

sebastinas opened this issue Apr 6, 2021 · 17 comments

Comments

@sebastinas
Copy link
Contributor

Some parts of the code are already annotated with types. Let's add to the remaining parts as well.

@Mayur619
Copy link

Hi @sebastinas, I would like to work on this

@sebastinas
Copy link
Contributor Author

@Mayur619 Feel free to start with any file that does not already have type annotations. Easiest is probably to start with a module that only imports stuff from the standard library. For others, we probably need stubs or type annotations in our dependencies.

@supremestdoggo
Copy link
Contributor

Hi! Can I help?

@sebastinas
Copy link
Contributor Author

Yes, you can! As said above, pick a file and start with annotating it. Note that for some dependencies, type annotations are still missing. This can be fixed in the dependencies directly or adding stubs in bpython.

@victoroliveirab
Copy link

Hey, @sebastinas, are there any more files needing help?

@sebastinas
Copy link
Contributor Author

@victoroliveirab Yes, there are. You can start by running mypy on the bpython source tree and start from there.

@Frostmaine
Copy link
Contributor

Hi can I help? @sebastinas

@thomasballinger
Copy link
Member

@Frostmaine adding types to more modules would be great.

If you check out the code, install it with pip install . and install mypy, then run mypy in the directory, there should be no errors. If there are, let's improve the documentation of how to run mypy. Then pick a file (start with a small one), and add these two lines at the top:

# mypy: disallow_untyped_defs=True
# mypy: disallow_untyped_calls=True

Now when you run mypy again, you might get some errors. Add types to the file to fix them. Once there are no errors, make a PR and we can see if things should be typed differently.

@Ben-Reg
Copy link
Contributor

Ben-Reg commented Jan 2, 2022

Hi - I'm new and this looks like a good place to start. Can I start by working on formatter.py?

@thomasballinger
Copy link
Member

@Ben-Reg that sounds good, thanks for taking a shot at this!

@Ben-Reg
Copy link
Contributor

Ben-Reg commented Jan 3, 2022

@thomasballinger, if I have questions, is this the best place to post them? One of the variables in formatter.py is used in a way that makes assigning a type difficult. I'm unsure whether I should rewrite it to allow for stricter typing, or just use the Any type.

@thomasballinger
Copy link
Member

@Ben-Reg opening an in-progress pull request might be the best way to ask since the context will be right there, but you can ask here too.

Which variable is it? Even though the file is short I'm having trouble guessing, so I can't suggest something specific. Starting with any sounds good to me, and we can discuss more as code review.

@Ben-Reg
Copy link
Contributor

Ben-Reg commented Jan 4, 2022

Thanks @thomasballinger, I opened pull request #947 to add the context. The issue is with the line token = token.parent

@spotted-cat
Copy link

Heya I would like to help!? @sebastinas

@thomasballinger
Copy link
Member

@spotted-cat Great! The process is described above, do you have any questions about it? Go right ahead, looking forward to a pull request.

@RCReddyN
Copy link
Contributor

Hi! I would like to help.

@thomasballinger
Copy link
Member

@RCReddyN Great — choose a file and take a shot at it, and open a PR. To anyone else, there's no need to post to say you want to help, just go ahead :)

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

No branches or pull requests

9 participants