From 5ff46d6245a54bb351cd6fce9f74ca8caef1d402 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sun, 7 Mar 2021 21:12:22 +0100 Subject: JID: add some forgotten type hints --- slixmpp/jid.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'slixmpp/jid.py') diff --git a/slixmpp/jid.py b/slixmpp/jid.py index c84b4aa0..ee5ef987 100644 --- a/slixmpp/jid.py +++ b/slixmpp/jid.py @@ -5,12 +5,16 @@ # Part of Slixmpp: The Slick XMPP Library # :copyright: (c) 2011 Nathanael C. Fritz # :license: MIT, see LICENSE for more details +from __future__ import annotations + import re import socket -from copy import deepcopy from functools import lru_cache -from typing import Optional +from typing import ( + Optional, + Union, +) 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. @lru_cache(maxsize=1024) -def _parse_jid(data): +def _parse_jid(data: str): """ Parse string data into the node, domain, and resource components of a JID, if possible. @@ -305,7 +309,7 @@ class JID: __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: self._node = '' self._domain = '' @@ -347,23 +351,23 @@ class JID: else self._bare) @property - def node(self): + def node(self) -> str: return self._node @property - def domain(self): + def domain(self) -> str: return self._domain @property - def resource(self): + def resource(self) -> str: return self._resource @property - def bare(self): + def bare(self) -> str: return self._bare @property - def full(self): + def full(self) -> str: return self._full @node.setter -- cgit v1.2.3