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