Skip to content

Make Mypy more restrictive #665

@bokelley

Description

@bokelley

Tighten up Mypy:

Our current config (lenient, incremental adoption):

  • ✅ show_error_codes = True - MATCHES Wolt
  • ❌ warn_return_any = False - Wolt: True
  • ❌ disallow_untyped_defs = False - Wolt: True (most important!)
  • ❌ check_untyped_defs = False - Wolt: True
  • ❌ no_implicit_optional = False - Wolt: True
  • ❌ ignore_missing_imports = True - Wolt recommends disallow_any_unimported = True

Current status: We're at 0 mypy errors with lenient settings. This is excellent progress!

Recommendation: Now that we have 0 errors, we should gradually tighten strictness:

Phase 1 (next PR):

  1. Enable no_implicit_optional = True - explicit Optional annotations
  2. Enable warn_return_any = True - catch Any leakage
  3. Enable check_untyped_defs = True - check untyped function bodies

Phase 2 (future):
4. Enable disallow_untyped_defs = True - require type hints (biggest impact)
5. Replace ignore_missing_imports = True with disallow_any_unimported = True

The key insight from Wolt: start strict for new code, be lenient with legacy. We could enable strict
settings globally and use per-module overrides for existing code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions