# HG changeset patch # User Mads Kiilerich # Date 2019-11-23 21:21:28 # Node ID 280c8767e5773266faf38c25309f58f641eb17f7 # Parent 529917d3132031965765163f709d33aaba583480 cleanup: use isinstance instead of comparing types From 2to3 idioms. diff --git a/kallithea/lib/rcmail/response.py b/kallithea/lib/rcmail/response.py --- a/kallithea/lib/rcmail/response.py +++ b/kallithea/lib/rcmail/response.py @@ -422,7 +422,7 @@ def header_to_mime_encoding(value, not_e return "" encoder = Charset(DEFAULT_ENCODING) - if type(value) == list: + if isinstance(value, list): return separator.join(properly_encode_header( v, encoder, not_email) for v in value) else: diff --git a/kallithea/model/db.py b/kallithea/model/db.py --- a/kallithea/model/db.py +++ b/kallithea/model/db.py @@ -205,7 +205,7 @@ class Setting(Base, BaseDbModel): @validates('_app_settings_value') def validate_settings_value(self, key, val): - assert type(val) == unicode + assert isinstance(val, unicode) return val @hybrid_property diff --git a/kallithea/tests/vcs/test_git.py b/kallithea/tests/vcs/test_git.py --- a/kallithea/tests/vcs/test_git.py +++ b/kallithea/tests/vcs/test_git.py @@ -590,17 +590,17 @@ class TestGitChangeset(object): def test_commit_message_is_unicode(self): for cs in self.repo: - assert type(cs.message) == unicode + assert isinstance(cs.message, unicode) def test_changeset_author_is_unicode(self): for cs in self.repo: - assert type(cs.author) == unicode + assert isinstance(cs.author, unicode) def test_repo_files_content_is_unicode(self): changeset = self.repo.get_changeset() for node in changeset.get_node('/'): if node.is_file(): - assert type(node.content) == unicode + assert isinstance(node.content, unicode) def test_wrong_path(self): # There is 'setup.py' in the root dir but not there: diff --git a/kallithea/tests/vcs/test_hg.py b/kallithea/tests/vcs/test_hg.py --- a/kallithea/tests/vcs/test_hg.py +++ b/kallithea/tests/vcs/test_hg.py @@ -538,17 +538,17 @@ class TestMercurialChangeset(object): def test_commit_message_is_unicode(self): for cm in self.repo: - assert type(cm.message) == unicode + assert isinstance(cm.message, unicode) def test_changeset_author_is_unicode(self): for cm in self.repo: - assert type(cm.author) == unicode + assert isinstance(cm.author, unicode) def test_repo_files_content_is_unicode(self): test_changeset = self.repo.get_changeset(100) for node in test_changeset.get_node('/'): if node.is_file(): - assert type(node.content) == unicode + assert isinstance(node.content, unicode) def test_wrong_path(self): # There is 'setup.py' in the root dir but not there: