Interview Prep/Python for DevOps/Testing, CI/CD, packaging & services

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 →

  1. Add mypy to CI with a permissive baseline (ignore_missing_imports, no strict), so it runs and passes.
  2. Enable stricter settings per module with [[tool.mypy.overrides]], starting with core modules and new code (disallow_untyped_defs).
  3. Add boto3-stubs and types-requests/types-PyYAML for library types.
  4. Type function signatures first; inference handles most locals.
  5. 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.

All Python for DevOps questions Roadmap: Python for automation

More on Testing, CI/CD, packaging & services