Commit 4703c850 authored by Maxime Buquet's avatar Maxime Buquet

Bookmark: Change jid property to getter/setter to ensure it stays a JID

It's not like static-type checking was a thing in Python nowadays..
(mypy I'm looking at you)
Signed-off-by: Maxime Buquet's avatarMaxime “pep” Buquet <pep@bouah.net>
parent ea1ab71f
Pipeline #2558 passed with stages
in 3 minutes and 48 seconds
......@@ -49,18 +49,34 @@ class Bookmark:
method='local') -> None:
try:
if isinstance(jid, JID):
self.jid = jid
self._jid = jid
else:
self.jid = JID(jid)
self._jid = JID(jid)
except InvalidJID:
log.debug('Invalid JID %r provided for bookmark %r', jid, name)
log.debug('Invalid JID %r provided for bookmark', jid)
raise
self.name = name or str(jid)
self.name = name or str(self.jid)
self.autojoin = autojoin
self.nick = nick
self.password = password
self._method = method
@property
def jid(self) -> JID:
"""Jid getter"""
return self._jid
@jid.setter
def jid(self, jid: JID) -> None:
try:
if isinstance(jid, JID):
self._jid = jid
else:
self._jid = JID(jid)
except InvalidJID:
log.debug('Invalid JID %r provided for bookmark', jid)
raise
@property
def method(self) -> str:
return self._method
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment