A str that also holds extra attributes.
| 110 | |
| 111 | |
| 112 | class _ScopedIP(str): |
| 113 | """ |
| 114 | A str that also holds extra attributes. |
| 115 | """ |
| 116 | __slots__ = ["scope"] |
| 117 | |
| 118 | def __init__(self, _: str) -> None: |
| 119 | self.scope = None |
| 120 | |
| 121 | def __repr__(self) -> str: |
| 122 | val = super(_ScopedIP, self).__repr__() |
| 123 | if self.scope is not None: |
| 124 | return "ScopedIP(%s, scope=%s)" % (val, repr(self.scope)) |
| 125 | return val |
| 126 | |
| 127 | |
| 128 | def ScopedIP(net: str, scope: Optional[Any] = None) -> _ScopedIP: |