Просмотр исходного кода

Modernize collections imports to use specific imports

Jelmer Vernooij 2 месяцев назад
Родитель
Сommit
bb83caa9c0
3 измененных файлов с 8 добавлено и 8 удалено
  1. 2 2
      dulwich/gc.py
  2. 2 2
      dulwich/server.py
  3. 4 4
      dulwich/walk.py

+ 2 - 2
dulwich/gc.py

@@ -1,9 +1,9 @@
 """Git garbage collection implementation."""
 """Git garbage collection implementation."""
 
 
-import collections
 import logging
 import logging
 import os
 import os
 import time
 import time
+from collections import deque
 from collections.abc import Callable
 from collections.abc import Callable
 from dataclasses import dataclass, field
 from dataclasses import dataclass, field
 from typing import TYPE_CHECKING, Optional
 from typing import TYPE_CHECKING, Optional
@@ -54,7 +54,7 @@ def find_reachable_objects(
         Set of reachable object SHAs
         Set of reachable object SHAs
     """
     """
     reachable = set()
     reachable = set()
-    pending: collections.deque[ObjectID] = collections.deque()
+    pending: deque[ObjectID] = deque()
 
 
     # Start with all refs
     # Start with all refs
     for ref in refs_container.allkeys():
     for ref in refs_container.allkeys():

+ 2 - 2
dulwich/server.py

@@ -43,13 +43,13 @@ Currently supported capabilities:
  * symref
  * symref
 """
 """
 
 
-import collections
 import os
 import os
 import socket
 import socket
 import socketserver
 import socketserver
 import sys
 import sys
 import time
 import time
 import zlib
 import zlib
+from collections import deque
 from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
 from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
 from collections.abc import Set as AbstractSet
 from collections.abc import Set as AbstractSet
 from functools import partial
 from functools import partial
@@ -629,7 +629,7 @@ def _want_satisfied(
     Returns: True if the want is satisfied by the haves
     Returns: True if the want is satisfied by the haves
     """
     """
     o = store[want]
     o = store[want]
-    pending = collections.deque([o])
+    pending = deque([o])
     known = {want}
     known = {want}
     while pending:
     while pending:
         commit = pending.popleft()
         commit = pending.popleft()

+ 4 - 4
dulwich/walk.py

@@ -21,8 +21,8 @@
 
 
 """General implementation of walking commits and their contents."""
 """General implementation of walking commits and their contents."""
 
 
-import collections
 import heapq
 import heapq
+from collections import defaultdict, deque
 from collections.abc import Callable, Iterator, Sequence
 from collections.abc import Callable, Iterator, Sequence
 from itertools import chain
 from itertools import chain
 from typing import TYPE_CHECKING, Any, cast
 from typing import TYPE_CHECKING, Any, cast
@@ -338,7 +338,7 @@ class Walker:
 
 
         self._num_entries = 0
         self._num_entries = 0
         self._queue = queue_cls(self)
         self._queue = queue_cls(self)
-        self._out_queue: collections.deque[WalkEntry] = collections.deque()
+        self._out_queue: deque[WalkEntry] = deque()
 
 
     def _path_matches(self, changed_path: bytes | None) -> bool:
     def _path_matches(self, changed_path: bytes | None) -> bool:
         if changed_path is None:
         if changed_path is None:
@@ -481,9 +481,9 @@ def _topo_reorder(
     Returns: iterator over WalkEntry objects from entries in FIFO order, except
     Returns: iterator over WalkEntry objects from entries in FIFO order, except
         where a parent would be yielded before any of its children.
         where a parent would be yielded before any of its children.
     """
     """
-    todo: collections.deque[WalkEntry] = collections.deque()
+    todo: deque[WalkEntry] = deque()
     pending: dict[bytes, WalkEntry] = {}
     pending: dict[bytes, WalkEntry] = {}
-    num_children: dict[bytes, int] = collections.defaultdict(int)
+    num_children: dict[bytes, int] = defaultdict(int)
     for entry in entries:
     for entry in entries:
         todo.append(entry)
         todo.append(entry)
         for p in get_parents(entry.commit):
         for p in get_parents(entry.commit):