We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 52b1ff9 commit 888299fCopy full SHA for 888299f
pep-0484.txt
@@ -860,6 +860,20 @@ ellipsis::
860
861
stream = ... # type: IO[str]
862
863
+In non-stub code, there is a similar special case:
864
+
865
+ from typing import IO
866
867
+ stream = None # type: IO[str]
868
869
+Type checkers should not complain about this (despite the value
870
+``None`` not matching the given type), nor should they change the
871
+inferred type to ``Optional[...]`` (despite the rule that does this
872
+for annotated arguments with a default value of ``None``). The
873
+assumption here is that other code will ensure that the variable is
874
+given a value of the proper type, and all uses can assume that the
875
+variable has the given type.
876
877
The ``# type: ignore`` comment should be put on the line that the
878
error refers to::
879
0 commit comments