فهرست منبع

Use dissolve's remove_in attribute

Jelmer Vernooij 2 ماه پیش
والد
کامیت
200c1fe397
5فایلهای تغییر یافته به همراه20 افزوده شده و 17 حذف شده
  1. 15 12
      dulwich/__init__.py
  2. 2 2
      dulwich/objects.py
  3. 1 1
      dulwich/pack.py
  4. 1 1
      dulwich/porcelain.py
  5. 1 1
      pyproject.toml

+ 15 - 12
dulwich/__init__.py

@@ -32,22 +32,25 @@ try:
 except ModuleNotFoundError:
     # if dissolve is not installed, then just provide a basic implementation
     # of its replace_me decorator
-    def replace_me(since=None):
+    def replace_me(since=None, remove_in=None):
         def decorator(func):
             import warnings
 
-            if since is not None:
-                warnings.warn(
-                    f"{func.__name__} is deprecated since {since}; use 'dissolve migrate' to update your code",
-                    DeprecationWarning,
-                    stacklevel=2,
-                )
+            m = f"{func.__name__} is deprecated"
+            if since is not None and remove_in is not None:
+                m += f" since {since} and will be removed in {remove_in}"
+            elif since is not None:
+                m += f" since {since}"
+            elif remove_in is not None:
+                m += f" and will be removed in {remove_in}"
             else:
-                warnings.warn(
-                    f"{func.__name__} is deprecated; use 'dissolve migrate' to update your code",
-                    DeprecationWarning,
-                    stacklevel=2,
-                )
+                m += " and will be removed in a future version"
+
+            warnings.warn(
+                m,
+                DeprecationWarning,
+                stacklevel=2,
+            )
             return func
 
         return decorator

+ 2 - 2
dulwich/objects.py

@@ -1320,7 +1320,7 @@ def format_time_entry(person, time, timezone_info):
     )
 
 
-@replace_me(since="0.21.0")
+@replace_me(since="0.21.0", remove_in="0.24.0")
 def parse_commit(chunks):
     """Parse a commit object from chunks.
 
@@ -1616,7 +1616,7 @@ class Commit(ShaFile):
         doc="Parents of this commit, by their SHA1.",
     )
 
-    @replace_me(since="0.21.0")
+    @replace_me(since="0.21.0", remove_in="0.24.0")
     def _get_extra(self):
         """Return extra settings of this commit."""
         return self._extra

+ 1 - 1
dulwich/pack.py

@@ -485,7 +485,7 @@ class PackIndex:
         """
         raise NotImplementedError(self.get_pack_checksum)
 
-    @replace_me(since="0.21.0")
+    @replace_me(since="0.21.0", remove_in="0.23.0")
     def object_index(self, sha: bytes) -> int:
         return self.object_offset(sha)
 

+ 1 - 1
dulwich/porcelain.py

@@ -2210,7 +2210,7 @@ def reset_file(repo, file_path: str, target: bytes = b"HEAD", symlink_fn=None) -
     build_file_from_blob(blob, mode, full_path, symlink_fn=symlink_fn)
 
 
-@replace_me(since="0.22.9")
+@replace_me(since="0.22.9", remove_in="0.24.0")
 def checkout_branch(repo, target: Union[bytes, str], force: bool = False) -> None:
     """Switch branches or restore working tree files.
 

+ 1 - 1
pyproject.toml

@@ -43,7 +43,7 @@ paramiko = ["paramiko"]
 dev = [
     "ruff==0.11.11",
     "mypy==1.15.0",
-    "dissolve"
+    "dissolve>=0.1.1"
 ]
 merge = ["merge3"]