iiasa / ixmp

The ix modeling platform for integrated and cross-cutting scenario analysis
https://docs.messageix.org/ixmp
Apache License 2.0
38 stars 112 forks source link

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

Closed khaeru closed 1 year ago

khaeru commented 2 years ago

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:

As a fix: