2Tests the handling of builtins.None in a type annotation.
5# Specification: https://typing.readthedocs.io/en/latest/spec/special-types.html#none
7from types import NoneType
8from typing import Hashable, Iterable, assert_type
11# > When used in a type hint, the expression None is considered equivalent to type(None).
14def func1(val1: None) -> None:
15 assert_type(val1, None)
[invalid-argument-type] Argument to function `func1` is incorrect: Expected `None`, found `<class 'NoneType'>`
24none1: Hashable = None # OK
27none2: Iterable = None # E: not iterable
[invalid-assignment] Object of type `None` is not assignable to `Iterable[Unknown]`
35def func2(val1: type[None]):
36 assert_type(val1, type[None])
39func2(None.__class__) # OK
41func2(None) # E: not compatible
[invalid-argument-type] Argument to function `func2` is incorrect: Expected `<class 'NoneType'>`, found `None`