JID: add some forgotten type hints
This commit is contained in:
parent
c1a598c34b
commit
5ff46d6245
@ -5,12 +5,16 @@
|
|||||||
# Part of Slixmpp: The Slick XMPP Library
|
# Part of Slixmpp: The Slick XMPP Library
|
||||||
# :copyright: (c) 2011 Nathanael C. Fritz
|
# :copyright: (c) 2011 Nathanael C. Fritz
|
||||||
# :license: MIT, see LICENSE for more details
|
# :license: MIT, see LICENSE for more details
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from copy import deepcopy
|
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
from typing import Optional
|
from typing import (
|
||||||
|
Optional,
|
||||||
|
Union,
|
||||||
|
)
|
||||||
|
|
||||||
from slixmpp.stringprep import nodeprep, resourceprep, idna, StringprepError
|
from slixmpp.stringprep import nodeprep, resourceprep, idna, StringprepError
|
||||||
|
|
||||||
@ -42,7 +46,7 @@ JID_UNESCAPE_TRANSFORMATIONS = {'\\20': ' ',
|
|||||||
|
|
||||||
# TODO: Find the best cache size for a standard usage.
|
# TODO: Find the best cache size for a standard usage.
|
||||||
@lru_cache(maxsize=1024)
|
@lru_cache(maxsize=1024)
|
||||||
def _parse_jid(data):
|
def _parse_jid(data: str):
|
||||||
"""
|
"""
|
||||||
Parse string data into the node, domain, and resource
|
Parse string data into the node, domain, and resource
|
||||||
components of a JID, if possible.
|
components of a JID, if possible.
|
||||||
@ -305,7 +309,7 @@ class JID:
|
|||||||
|
|
||||||
__slots__ = ('_node', '_domain', '_resource', '_bare', '_full')
|
__slots__ = ('_node', '_domain', '_resource', '_bare', '_full')
|
||||||
|
|
||||||
def __init__(self, jid: Optional[str] = None):
|
def __init__(self, jid: Optional[Union[str, 'JID']] = None):
|
||||||
if not jid:
|
if not jid:
|
||||||
self._node = ''
|
self._node = ''
|
||||||
self._domain = ''
|
self._domain = ''
|
||||||
@ -347,23 +351,23 @@ class JID:
|
|||||||
else self._bare)
|
else self._bare)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def node(self):
|
def node(self) -> str:
|
||||||
return self._node
|
return self._node
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def domain(self):
|
def domain(self) -> str:
|
||||||
return self._domain
|
return self._domain
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def resource(self):
|
def resource(self) -> str:
|
||||||
return self._resource
|
return self._resource
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def bare(self):
|
def bare(self) -> str:
|
||||||
return self._bare
|
return self._bare
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full(self):
|
def full(self) -> str:
|
||||||
return self._full
|
return self._full
|
||||||
|
|
||||||
@node.setter
|
@node.setter
|
||||||
|
Loading…
Reference in New Issue
Block a user