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 “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
ea1ab71f02
commit
4703c8506a
1 changed files with 20 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue