iiasa/ixmp

Adjust for mypy `--no-implicit-optional`

khaeru opened this issue · 0 comments

As of mypy 0.990 (or 0.980, unclear), --implicit-optional is disabled by default. This results in type checking failures downstream, e.g. here in message_data (private) with many messages like:

ixmp/ixmp/core/platform.py:61: error: Incompatible default for argument "name" (default has type "None", argument has type "str")  [assignment]
ixmp/ixmp/core/platform.py:61: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
ixmp/ixmp/core/platform.py:61: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase

As mitigation:

  • Give --implicit-optional explicitly when type checking, e.g. in "lint" CI workflows for ixmp or downstream packages.

As a fix: