Where do you start adding type hints to an existing project

Back to list2026-01-19
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.

You

How do I structure a file that is both a module and a CLI?

ChatGPT

Keep the work in functions, put argument parsing in main(), and guard with if __name__ == "__main__": sys.exit(main()). Return codes from main then work for both the shell and the tests.

You

What is the most common way people get this wrong?

ChatGPT

Doing it once and never verifying. The setup is the visible part, so it gets attention, and the check that would catch a silent failure never gets written.