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

Class TCPAddress

traitlets/traitlets.py:4130–4193  ·  view source on GitHub ↗

A trait for an (ip, port) tuple. This allows for both IPv4 IP addresses as well as hostnames.

Source from the content-addressed store, hash-verified

4128
4129
4130class TCPAddress(TraitType[G, S]):
4131 """A trait for an (ip, port) tuple.
4132
4133 This allows for both IPv4 IP addresses as well as hostnames.
4134 """
4135
4136 default_value = ("127.0.0.1", 0)
4137 info_text = "an (ip, port) tuple"
4138
4139 if t.TYPE_CHECKING:
4140
4141 @t.overload
4142 def __init__(
4143 self: TCPAddress[tuple[str, int], tuple[str, int]],
4144 default_value: bool | Sentinel = ...,
4145 allow_none: Literal[False] = ...,
4146 read_only: bool | None = ...,
4147 help: str | None = ...,
4148 config: t.Any = ...,
4149 **kwargs: t.Any,
4150 ) -> None:
4151 ...
4152
4153 @t.overload
4154 def __init__(
4155 self: TCPAddress[tuple[str, int] | None, tuple[str, int] | None],
4156 default_value: bool | None | Sentinel = ...,
4157 allow_none: Literal[True] = ...,
4158 read_only: bool | None = ...,
4159 help: str | None = ...,
4160 config: t.Any = ...,
4161 **kwargs: t.Any,
4162 ) -> None:
4163 ...
4164
4165 def __init__(
4166 self: TCPAddress[tuple[str, int] | None, tuple[str, int] | None]
4167 | TCPAddress[tuple[str, int], tuple[str, int]],
4168 default_value: bool | None | Sentinel = Undefined,
4169 allow_none: Literal[True, False] = False,
4170 read_only: bool | None = None,
4171 help: str | None = None,
4172 config: t.Any = None,
4173 **kwargs: t.Any,
4174 ) -> None:
4175 ...
4176
4177 def validate(self, obj: t.Any, value: t.Any) -> G:
4178 if isinstance(value, tuple):
4179 if len(value) == 2:
4180 if isinstance(value[0], str) and isinstance(value[1], int):
4181 port = value[1]
4182 if port >= 0 and port <= 65535:
4183 return value # type:ignore[return-value]
4184 self.error(obj, value)
4185
4186 def from_string(self, s: str) -> G:
4187 if self.allow_none and s == "None":

Callers 2

TCPAddressTraitClass · 0.90
TClass · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…