diff options
author | lovetox <philipp@hoerist.com> | 2020-03-11 19:03:50 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-03-11 21:00:54 +0300 |
commit | 9be1dfa2ccc14a8a24a052696ef863fac29d09a2 (patch) | |
tree | 5f1edb6f40d5fe97d3c98b8801ebd69068834500 /nbxmpp | |
parent | d64c941613c5a61301d61bbe58352fc015da9fb0 (diff) |
Fix pylint errors
- unidiomatic-typecheck
- bare-except
Diffstat (limited to 'nbxmpp')
-rw-r--r-- | nbxmpp/idlequeue.py | 2 | ||||
-rw-r--r-- | nbxmpp/old_dispatcher.py | 13 | ||||
-rw-r--r-- | nbxmpp/protocol.py | 18 | ||||
-rw-r--r-- | nbxmpp/simplexml.py | 2 |
4 files changed, 18 insertions, 17 deletions
diff --git a/nbxmpp/idlequeue.py b/nbxmpp/idlequeue.py index 8fe8efd..b4f3c56 100644 --- a/nbxmpp/idlequeue.py +++ b/nbxmpp/idlequeue.py @@ -185,7 +185,7 @@ class IdleCommand(IdleObject): self.idlequeue.unplug_idle(self.fd) try: self.pipe.close() - except: + except Exception: pass def pollend(self): diff --git a/nbxmpp/old_dispatcher.py b/nbxmpp/old_dispatcher.py index c416524..1e8d933 100644 --- a/nbxmpp/old_dispatcher.py +++ b/nbxmpp/old_dispatcher.py @@ -673,14 +673,13 @@ class XMPPDispatcher(PlugIn): sure stanzas get ID and from tag. """ ID = None - if type(stanza) != str: - if isinstance(stanza, Protocol): + if isinstance(stanza, Protocol): + ID = stanza.getID() + if ID is None: + stanza.setID(self.getAnID()) ID = stanza.getID() - if ID is None: - stanza.setID(self.getAnID()) - ID = stanza.getID() - if self._owner._registered_name and not stanza.getAttr('from'): - stanza.setAttr('from', self._owner._registered_name) + if self._owner._registered_name and not stanza.getAttr('from'): + stanza.setAttr('from', self._owner._registered_name) self._owner.Connection.send(stanza, now) diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py index 6b0a466..fabfec8 100644 --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -1021,8 +1021,10 @@ class Protocol(Node): self.setTo(self['to']) if self['from']: self.setFrom(self['from']) - if node and type(self) == type(node) and \ - self.__class__ == node.__class__ and 'id' in self.attrs: + if (node and + isinstance(node, Protocol) and + self.__class__ == node.__class__ + and 'id' in self.attrs): del self.attrs['id'] self.timestamp = None for d in self.getTags('delay', namespace=NS_DELAY2): @@ -1047,7 +1049,7 @@ class Protocol(Node): """ try: return self['to'] - except: + except Exception: pass return None @@ -1057,7 +1059,7 @@ class Protocol(Node): """ try: return self['from'] - except: + except Exception: pass return None @@ -1203,9 +1205,9 @@ class Protocol(Node): error = ErrorNode(_errorcodes[str(code)], text=error) else: error = ErrorNode(ERR_UNDEFINED_CONDITION, code=code, - typ='cancel', text=error) - elif type(error) == str: - error=ErrorNode(error) + typ='cancel', text=error) + elif isinstance(error, str): + error = ErrorNode(error) self.setType('error') self.addChild(node=error) @@ -1677,7 +1679,7 @@ class Hashes(Node): hl = None hash_ = None # file_string can be a string or a file - if type(file_string) == str: # if it is a string + if isinstance(file_string, str): if algo == 'sha-1': hl = hashlib.sha1() elif algo == 'md5': diff --git a/nbxmpp/simplexml.py b/nbxmpp/simplexml.py index 09890dd..8f67e09 100644 --- a/nbxmpp/simplexml.py +++ b/nbxmpp/simplexml.py @@ -305,7 +305,7 @@ class Node: """ try: return self.getTag(tag, namespace=namespace).attrs[attr] - except: + except Exception: return None def getTagData(self, tag): |