()
| 402 | |
| 403 | @pytest.mark.mypy_testing |
| 404 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…