How would you add type hints to a 5,000-line untyped automation codebase without stopping feature work?
AdvancedScenarioTesting, CI/CD, packaging & services
Answer
Situation read → Gradual typing.
What I'd do →
- Add mypy to CI with a permissive baseline (
ignore_missing_imports, nostrict), so it runs and passes. - Enable stricter settings per module with
[[tool.mypy.overrides]], starting with core modules and new code (disallow_untyped_defs). - Add
boto3-stubsandtypes-requests/types-PyYAMLfor library types. - Type function signatures first; inference handles most locals.
- Ratchet: new modules must be strict.
Why → Gradual adoption delivers value immediately without a big-bang rewrite.
Interview tip → Mention per-module overrides; it is how real teams do it.
More on Testing, CI/CD, packaging & services
You join a team whose Python automation repo has no tests. Where do you start?BeginnerYour pytest suite takes 12 minutes. How do you speed it up?IntermediateA test passes locally but fails in CI only when run with the rest of the suite. What do you suspect?IntermediateYou want a reusable CI pipeline for 15 Python tool repos. What goes in it?IntermediateYour Python Docker image is 1.1 GB. How do you shrink it?IntermediateYou want to distribute an internal CLI to 200 engineers. What are your options?Intermediate