[PATCH] Use isinstance instead of type == type

Christian Ebert blacktrash at gmx.net
Fri Jul 6 05:03:11 CDT 2007


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1183716163 -7200
# Node ID c8ec4e79340e98b134aeefb6133c00c7fc5f4a14
# Parent  13cb25bb760782dddb7cb7a5d28df5e8d0bd9b3d
Use isinstance instead of type == type

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -64,7 +64,7 @@ def revnavgen(pos, pagelen, limit, nodef
 
 class hgweb(object):
     def __init__(self, repo, name=None):
-        if type(repo) == type(""):
+        if isinstance(repo, str):
             self.repo = hg.repository(ui.ui(report_untrusted=False), repo)
         else:
             self.repo = repo
diff --git a/tests/coverage.py b/tests/coverage.py
--- a/tests/coverage.py
+++ b/tests/coverage.py
@@ -504,7 +504,7 @@ class coverage:
     def get_suite_spots(self, tree, spots):
         import symbol, token
         for i in range(1, len(tree)):
-            if type(tree[i]) == type(()):
+            if isinstance(tree[i], tuple):
                 if tree[i][0] == symbol.suite:
                     # Found a suite, look back for the colon and keyword.
                     lineno_colon = lineno_word = None


More information about the Mercurial-devel mailing list