Forráskód Böngészése

Fix type for ShaFile.from_string() (#1714)

Jelmer Vernooij 1 hónapja
szülő
commit
e968d82411
1 módosított fájl, 7 hozzáadás és 1 törlés
  1. 7 1
      dulwich/objects.py

+ 7 - 1
dulwich/objects.py

@@ -26,6 +26,7 @@ import binascii
 import os
 import posixpath
 import stat
+import sys
 import zlib
 from collections import namedtuple
 from collections.abc import Callable, Iterable, Iterator
@@ -38,6 +39,11 @@ from typing import (
     Union,
 )
 
+if sys.version_info >= (3, 11):
+    from typing import Self
+else:
+    from typing_extensions import Self
+
 try:
     from typing import TypeGuard  # type: ignore
 except ImportError:
@@ -538,7 +544,7 @@ class ShaFile:
         return obj
 
     @classmethod
-    def from_string(cls, string: bytes) -> "ShaFile":
+    def from_string(cls, string: bytes) -> Self:
         """Create a ShaFile from a string."""
         obj = cls()
         obj.set_raw_string(string)