Jelmer Vernooij 1 rok pred
rodič
commit
0a5c62b2b6

+ 2 - 6
dulwich/client.py

@@ -1329,8 +1329,8 @@ def find_git_command() -> List[str]:
     """Find command to run for system Git (usually C Git)."""
     if sys.platform == "win32":  # support .exe, .bat and .cmd
         try:  # to avoid overhead
-            import win32api
             import pywintypes
+            import win32api
         except ImportError:  # run through cmd.exe with some overhead
             return ["cmd", "/c", "git"]
         else:
@@ -2181,11 +2181,7 @@ class AbstractHttpGitClient(GitClient):
         return cls(urlunparse(parsedurl), **kwargs)
 
     def __repr__(self) -> str:
-        return "{}({!r}, dumb={!r})".format(
-            type(self).__name__,
-            self._base_url,
-            self.dumb,
-        )
+        return f"{type(self).__name__}({self._base_url!r}, dumb={self.dumb!r})"
 
 
 class Urllib3HttpGitClient(AbstractHttpGitClient):

+ 1 - 2
dulwich/cloud/gcs.py

@@ -38,8 +38,7 @@ class GcsObjectStore(BucketBasedObjectStore):
         self.subpath = subpath
 
     def __repr__(self) -> str:
-        return "{}({!r}, subpath={!r})".format(
-            type(self).__name__, self.bucket, self.subpath)
+        return f"{type(self).__name__}({self.bucket!r}, subpath={self.subpath!r})"
 
     def _remove_pack(self, name):
         self.bucket.delete_blobs([

+ 4 - 4
dulwich/graph.py

@@ -20,15 +20,15 @@
 
 """Implementation of merge-base following the approach of git."""
 
-from .lru_cache import LRUCache
+from heapq import heappop, heappush
 
-from heapq import heappush, heappop
+from .lru_cache import LRUCache
 
 
 # priority queue using builtin python minheap tools
 # why they do not have a builtin maxheap is simply ridiculous but
 # liveable with integer time stamps using negation
-class WorkList(object):
+class WorkList:
     def __init__(self):
         self.pq = []
 
@@ -108,7 +108,7 @@ def _find_lcas(lookup_parents, c1, c2s, lookup_stamp, min_stamp=0):
     # remove any duplicates and sort it so that earliest is first
     results = []
     for dt, cmt in cands:
-        if not ((cstates[cmt] & _DNC) == _DNC) and not (dt, cmt) in results:
+        if not ((cstates[cmt] & _DNC) == _DNC) and (dt, cmt) not in results:
             results.append((dt, cmt))
     results.sort(key=lambda x: x[0])
     lcas = [cmt for dt, cmt in results]

+ 1 - 5
dulwich/ignore.py

@@ -177,11 +177,7 @@ class Pattern:
         )
 
     def __repr__(self) -> str:
-        return "{}({!r}, {!r})".format(
-            type(self).__name__,
-            self.pattern,
-            self.ignorecase,
-        )
+        return f"{type(self).__name__}({self.pattern!r}, {self.ignorecase!r})"
 
     def match(self, path: bytes) -> bool:
         """Try to match a path against this ignore pattern.

+ 5 - 5
dulwich/lru_cache.py

@@ -131,31 +131,31 @@ class LRUCache(Generic[K, V]):
                 raise AssertionError(
                     "the _most_recently_used entry is not"
                     " supposed to have a previous entry"
-                    " {}".format(node)
+                    f" {node}"
                 )
         while node is not None:
             if node.next_key is _null_key:
                 if node is not self._least_recently_used:
                     raise AssertionError(
-                        "only the last node should have" " no next value: {}".format(node)
+                        "only the last node should have" f" no next value: {node}"
                     )
                 node_next = None
             else:
                 node_next = self._cache[node.next_key]
                 if node_next.prev is not node:
                     raise AssertionError(
-                        "inconsistency found, node.next.prev" " != node: {}".format(node)
+                        "inconsistency found, node.next.prev" f" != node: {node}"
                     )
             if node.prev is None:
                 if node is not self._most_recently_used:
                     raise AssertionError(
                         "only the _most_recently_used should"
-                        " not have a previous node: {}".format(node)
+                        f" not have a previous node: {node}"
                     )
             else:
                 if node.prev.next_key != node.key:
                     raise AssertionError(
-                        "inconsistency found, node.prev.next" " != node: {}".format(node)
+                        "inconsistency found, node.prev.next" f" != node: {node}"
                     )
             yield node
             node = node_next

+ 2 - 6
dulwich/patch.py

@@ -136,12 +136,8 @@ def unified_diff(
             started = True
             fromdate = f"\t{fromfiledate}" if fromfiledate else ""
             todate = f"\t{tofiledate}" if tofiledate else ""
-            yield "--- {}{}{}".format(
-                fromfile.decode(tree_encoding), fromdate, lineterm
-            ).encode(output_encoding)
-            yield "+++ {}{}{}".format(
-                tofile.decode(tree_encoding), todate, lineterm
-            ).encode(output_encoding)
+            yield f"--- {fromfile.decode(tree_encoding)}{fromdate}{lineterm}".encode(output_encoding)
+            yield f"+++ {tofile.decode(tree_encoding)}{todate}{lineterm}".encode(output_encoding)
 
         first, last = group[0], group[-1]
         file1_range = _format_range_unified(first[1], last[2])

+ 1 - 3
dulwich/tests/test_client.py

@@ -1037,9 +1037,7 @@ class HttpGitClientTests(TestCase):
         original_password = "Ya#1$2%3"
         quoted_password = urlquote(original_password)
 
-        url = "https://{username}:{password}@github.com/jelmer/dulwich".format(
-            username=quoted_username, password=quoted_password
-        )
+        url = f"https://{quoted_username}:{quoted_password}@github.com/jelmer/dulwich"
 
         c = HttpGitClient.from_parsedurl(urlparse(url))
         self.assertEqual(original_username, c._username)

+ 1 - 1
dulwich/tests/test_graph.py

@@ -21,7 +21,7 @@
 
 from dulwich.tests import TestCase
 
-from ..graph import _find_lcas, can_fast_forward, WorkList
+from ..graph import WorkList, _find_lcas, can_fast_forward
 from ..repo import MemoryRepo
 from .utils import make_commit
 

+ 1 - 4
dulwich/tests/test_walk.py

@@ -39,10 +39,7 @@ class TestWalkEntry:
         self.changes = changes
 
     def __repr__(self) -> str:
-        return "<TestWalkEntry commit={}, changes={!r}>".format(
-            self.commit.id,
-            self.changes,
-        )
+        return f"<TestWalkEntry commit={self.commit.id}, changes={self.changes!r}>"
 
     def __eq__(self, other):
         if not isinstance(other, WalkEntry) or self.commit != other.commit:

+ 1 - 4
dulwich/walk.py

@@ -117,10 +117,7 @@ class WalkEntry:
         return self._changes[path_prefix]
 
     def __repr__(self) -> str:
-        return "<WalkEntry commit={}, changes={!r}>".format(
-            self.commit.id,
-            self.changes(),
-        )
+        return f"<WalkEntry commit={self.commit.id}, changes={self.changes()!r}>"
 
 
 class _CommitTimeQueue:

+ 0 - 6
setup.py

@@ -7,12 +7,6 @@ import sys
 
 from setuptools import Extension, setup
 
-if sys.version_info < (3, 7):
-    raise Exception(
-        'Dulwich only supports Python 3.6 and later. '
-        'For 2.7 support, please install a version prior to 0.20')
-
-
 if sys.platform == 'darwin' and os.path.exists('/usr/bin/xcodebuild'):
     # XCode 4.0 dropped support for ppc architecture, which is hardcoded in
     # distutils.sysconfig