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

Consider adding types via mypy #2722

Open
WesleyAC opened this issue Mar 9, 2023 · 3 comments · May be fixed by #2897
Open

Consider adding types via mypy #2722

WesleyAC opened this issue Mar 9, 2023 · 3 comments · May be fixed by #2897

Comments

@WesleyAC
Copy link
Member

WesleyAC commented Mar 9, 2023

I find that Python is significantly easier to write and maintain when it's statically typed via mypy. It's fairly easy to add types incrementally. Here's a good post on how Zulip started using it (also a Django project, albeit larger than Bookwyrm) talking about benefits and approaches to migrating.

The steps for this would probably look like:

  • Get mypy running on the codebase without annotations, using # type: ignore where needed
  • Add mypy to test script / CI
  • Require type annotations, but exempt all existing code on a per-module basis. This will require new modules to be typed, without requiring huge changes all at once.
  • Slowly, over time, add type annotations for existing modules, and remove the exemptions as we do so.

I'd be happy to drive this if it's something people are open to.

@mouse-reeve
Copy link
Member

I'd be really happy to have this! I think there are a couple extremely disparate places with type annotations already.

@jderuiter
Copy link
Contributor

Does anybody already happen to be working on this? Otherwise I'd be happy to have a look at it to see if I can help get this started.

@mouse-reeve
Copy link
Member

As far as I know, nobody is currently working on this. Go for it!

@jderuiter jderuiter linked a pull request Jul 9, 2023 that will close this issue
3 tasks
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 a pull request may close this issue.

3 participants