Unexpected errors about ‘None’ and/or ‘Optional’ types
Starting from mypy 0.600, mypy usesstrict optional checking by default,and the None
value is not compatible with non-optional types.It’s easy to switch back to the older behavior where None
wascompatible with arbitrary types (see Disabling strict optional checking).You can also fall back to this behavior if strict optionalchecking would require a large number of assert foo is not None
checks to be inserted, and you want to minimize the numberof code changes required to get a clean mypy run.