iiasa / ixmp

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

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

Closed khaeru closed 8 months ago

khaeru commented 1 year 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: