Mypy: Using unions in mapping types does not work as expected

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • Scout APM - Less time debugging, more time building
  • SaaSHub - Software Alternatives and Reviews
  • mypy

    Optional static typing for Python

    If you typed it as Mapping instead of dict then it would be theoretically be type safe but its actually not supported. See mypy issue #1114. Only the value type is covariant for now.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts