Type hints on a codebase that has none

Back to list2024-07-29
You

Where do you start adding type hints to an existing project?

ChatGPT

At the boundaries: function signatures on public modules first, internals never. Run the checker in non-blocking mode for a few weeks so the noise is visible without stopping anyone, then turn on strictness one module at a time.

You

Is shell=True ever acceptable?

ChatGPT

When the command genuinely is a shell pipeline you control end to end, and never with any value that came from outside the program. The list form avoids quoting entirely, which is both safer and easier to read.