wp1 icon indicating copy to clipboard operation
wp1 copied to clipboard

Use Python type hinting

Open audiodude opened this issue 3 months ago • 3 comments

It's 2025 and the Python world has now embraced type hinting. I won't lay out the case for this practice in general, because plenty has been written about it.

For WP1, the most immediate benefits I see are:

  1. Knowing when you're working with b'bytes' from the DB (as opposed to a 'string', because the DB stores only bytes for legacy reasons
  2. Knowing when you're dealing with a UUID versus a "regular" string.

audiodude avatar Sep 24 '25 17:09 audiodude

@benoit74 @rgaudin Would love to get your opinions on this. I think it would definitely be beneficial, but might be a lot of work. But I have done typing migrations in the past (Javascript -> Typescript) and I've actually found that you can find some bugs when you do this work.

Not sure if it's worth the effort though.

audiodude avatar Oct 03 '25 15:10 audiodude

There is definitely a huge added value, this is our default requirement for new projet.

Regarding whether if it is worth the effort, it is a bit hard to say since it depends on the effort which depends on current WP1 code.

We've done the migration of python-scraperlib for instance and some parts have required very significant changes but even that was deemed worth the effort (and I'm still sure it is) because it allows to trap so many mistakes and errors, especially as code evolves.

benoit74 avatar Oct 05 '25 07:10 benoit74

I can only encourage you to implement this issue!

kelson42 avatar Oct 05 '25 08:10 kelson42