Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
a4d0ad81 by lovetox at 2022-01-01T21:03:13+01:00
JID: Correct bare return type
bare can never be None, its at least the domain.
- - - - -
adbf272e by lovetox at 2022-01-01T23:18:24+01:00
Discovery: Add type annotations
- - - - -
daf9c92c by lovetox at 2022-01-01T23:18:36+01:00
Structs: Add type annoations
- - - - -
3 changed files:
- nbxmpp/modules/discovery.py
- nbxmpp/protocol.py
- nbxmpp/structs.py
Changes:
=====================================
nbxmpp/modules/discovery.py
=====================================
@@ -15,6 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.
+from __future__ import annotations
+
+from typing import Any
+from typing import Optional
+
import time
import logging
@@ -78,7 +83,8 @@ class Discovery(BaseModule):
-def parse_disco_info(stanza, timestamp=None):
+def parse_disco_info(stanza: Any,
+ timestamp: Optional[float] = None) -> DiscoInfo:
idenities = []
features = []
dataforms = []
=====================================
nbxmpp/protocol.py
=====================================
@@ -683,7 +683,7 @@ class JID:
return idna_encode(self.domain)
@property
- def bare(self) -> Optional[str]:
+ def bare(self) -> str:
if self.localpart is not None:
return f'{self.localpart}(a){self.domain}'
return self.domain
=====================================
nbxmpp/structs.py
=====================================
@@ -379,7 +379,7 @@ class RosterItem:
subscription=attrs.get('subscription'),
groups=groups)
- def asdict(self):
+ def asdict(self) -> dict[str, Any]:
return {'jid': self.jid,
'name': self.name,
'ask': self.ask,
@@ -751,7 +751,7 @@ class CommonError:
self._text[lang] = text
@classmethod
- def from_string(cls, node_string):
+ def from_string(cls, node_string: Union[bytes, str]) -> CommonError:
return cls(Protocol(node=node_string))
def get_text(self, pref_lang=None):
@@ -783,7 +783,7 @@ class CommonError:
text = ' - %s' % text
return 'Error from %s: %s%s' % (self.jid, condition, text)
- def serialize(self):
+ def serialize(self) -> str:
return str(Protocol(name=self._stanza_name,
frm=self.jid,
xmlns=Namespace.CLIENT,
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/8d8c8f22394007bfeb4356a…
--
View it on GitLab: https://dev.gajim.org/gajim/python-nbxmpp/-/compare/8d8c8f22394007bfeb4356a…
You're receiving this email because of your account on dev.gajim.org.