Looking at PEP 484, specifically the section on type comments (the precursor to variable annotations) this does indeed seem like a bug with PyCharm’s checker.
Quoting from the PEP:
In non-stub code, there is a similar special case:
from typing import IO stream = None # type: IO[str]Type checkers should not complain about this (despite the value
Nonenot matching the given type), nor should they change the inferred type toOptional[...](despite the rule that does this for annotated arguments with a default value of None ). The assumption here is that other code will ensure that the variable is given a value of the proper type, and all uses can assume that the variable has the given type.
So, in a similar fashion, type-checkers (as mypy currently does), should not complain about the fact that the initializing value you provide doesn’t strictly match the annotation.