Hacker News new | ask | show | jobs
by sinfulprogeny 615 days ago
> then fixing the types

man I wish my coworkers did this step

1 comments

Having CI hard fail definitely helps. I won’t pretend I’d be so judicious without it.
Sorry this is probably a stupid question - how do you make your CI hard fail if you don't have types? This sounds like the missing piece for me, someone who also prefers just to crack on without types and then add them later.
You can add `mypy` to your CI pipeline https://mypy.readthedocs.io/en/stable/running_mypy.html. Pyright is an alternative, and there are more.
I was referring more specifically to fixing the types. It looks like it's possible to enforce type-hinting with config files to mypy (but I've not tried it): https://stackoverflow.com/questions/55944201/python-type-hin...
CI generally has a pipeline, no? Or even at worse a shell script that you built? Just add the equivalent of “exit()” when mypy (or whatever typing linter you’re using fails), and then the dev gets notified he broke the build for everyone. That’ll get them to fixing and checking their code before it goes in to the main branch. Peer pressure is underestimated these days I think.
Run mypy in strict mode and make that check required.