MCPcopy
hub / github.com/python/mypy / test_none

Method test_none

mypy/test/testtypes.py:1190–1216  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1188 self.assert_meet(self.fx.t, self.fx.s, UninhabitedType())
1189
1190 def test_none(self) -> None:
1191 self.assert_meet(NoneType(), NoneType(), NoneType())
1192
1193 self.assert_meet(NoneType(), self.fx.anyt, NoneType())
1194
1195 # Any type t joined with None results in None, unless t is Any.
1196 with state.strict_optional_set(False):
1197 for t in [
1198 self.fx.a,
1199 self.fx.o,
1200 UnboundType("x"),
1201 self.fx.t,
1202 self.tuple(),
1203 self.callable(self.fx.a, self.fx.b),
1204 ]:
1205 self.assert_meet(t, NoneType(), NoneType())
1206
1207 with state.strict_optional_set(True):
1208 self.assert_meet(self.fx.o, NoneType(), NoneType())
1209 for t in [
1210 self.fx.a,
1211 UnboundType("x"),
1212 self.fx.t,
1213 self.tuple(),
1214 self.callable(self.fx.a, self.fx.b),
1215 ]:
1216 self.assert_meet(t, NoneType(), UninhabitedType())
1217
1218 def test_unbound_type(self) -> None:
1219 self.assert_meet(UnboundType("x"), UnboundType("x"), self.fx.anyt)

Callers

nothing calls this directly

Calls 7

assert_meetMethod · 0.95
tupleMethod · 0.95
callableMethod · 0.95
NoneTypeClass · 0.90
UnboundTypeClass · 0.90
UninhabitedTypeClass · 0.90
strict_optional_setMethod · 0.80

Tested by

no test coverage detected