MCPcopy Create free account
hub / github.com/ipython/traitlets / mypy_tcp_typing

Function mypy_tcp_typing

tests/test_typing.py:404–430  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

402
403@pytest.mark.mypy_testing
404def mypy_tcp_typing() -> None:
405 class T(HasTraits):
406 tcp = TCPAddress()
407 otcp = TCPAddress(None, allow_none=True)
408
409 t = T()
410 reveal_type(t.tcp) # R: tuple[builtins.str, builtins.int]
411 reveal_type(
412 T.tcp # R: traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
413 )
414 reveal_type(
415 T.tcp.tag( # R:traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int], tuple[builtins.str, builtins.int]]
416 sync=True
417 )
418 )
419 reveal_type(t.otcp) # R: tuple[builtins.str, builtins.int] | None
420 reveal_type(
421 T.otcp # R: traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int] | None, tuple[builtins.str, builtins.int] | None]
422 )
423 reveal_type(
424 T.otcp.tag( # R: traitlets.traitlets.TCPAddress[tuple[builtins.str, builtins.int] | None, tuple[builtins.str, builtins.int] | None]
425 sync=True
426 )
427 )
428 t.tcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "tuple[str, int]") [assignment]
429 t.otcp = "foo" # E: Incompatible types in assignment (expression has type "str", variable has type "tuple[str, int] | None") [assignment]
430 t.tcp = None # E: Incompatible types in assignment (expression has type "None", variable has type "tuple[str, int]") [assignment]
431
432
433@pytest.mark.mypy_testing

Callers

nothing calls this directly

Calls 3

TClass · 0.85
reveal_typeFunction · 0.85
tagMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…