Refactor to meet mypy requirements
问题 I have a codebase which I would like to validate using mypy. In the current design, it is very common that a class may have a non-primitive member that can be set later after __init__ . So, in __init__ the member is initialized to None and its type becomes Optional accordingly. The problem is that now MyPy requires me to check that the member is not None every time it is being used. As a quick solution I can add assert self._member is not None # MyPy in all the relevant scopes, but it seems