Skip to content

Commit

Permalink
change pathtype name to StrOrBytesPath
Browse files Browse the repository at this point in the history
  • Loading branch information
DinhHuy2010 committed Dec 30, 2024
1 parent 6ab13f7 commit 5dca60a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pygit2/packbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from ._pygit2 import Oid
from .errors import check_error
from .ffi import C, ffi
from .utils import StrOrBytesOrPathLike, buffer_to_bytes, to_bytes
from .utils import StrOrBytesPath, buffer_to_bytes, to_bytes

if TYPE_CHECKING:
from .repository import BaseRepository
Expand Down Expand Up @@ -75,7 +75,7 @@ def add_recur(self, oid: Oid):
def set_threads(self, n_threads: int):
return C.git_packbuilder_set_threads(self._packbuilder, n_threads)

def write(self, path: StrOrBytesOrPathLike | None = None):
def write(self, path: StrOrBytesPath | None = None):
resolved_path = ffi.NULL if path is None else to_bytes(path)
err = C.git_packbuilder_write(
self._packbuilder, resolved_path, 0, ffi.NULL, ffi.NULL
Expand Down
8 changes: 4 additions & 4 deletions pygit2/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from _typeshed import SupportsLenAndGetItem

_T = TypeVar('_T')
StrOrBytesOrPathLike: TypeAlias = str | bytes | os.PathLike[str] | os.PathLike[bytes]
StrOrBytesPath: TypeAlias = str | bytes | os.PathLike[str] | os.PathLike[bytes]


def maybe_string(ptr: CData | Any) -> str | None:
Expand All @@ -57,11 +57,11 @@ def maybe_string(ptr: CData | Any) -> str | None:
@overload
def to_bytes(s: CData | None) -> CData: ...
@overload
def to_bytes(s: StrOrBytesOrPathLike) -> bytes: ...
def to_bytes(s: StrOrBytesPath) -> bytes: ...


def to_bytes(
s: StrOrBytesOrPathLike | CData | None,
s: StrOrBytesPath | CData | None,
encoding: str = 'utf-8',
errors: str = 'strict',
) -> bytes | CData:
Expand All @@ -77,7 +77,7 @@ def to_bytes(
return cast(str, s).encode(encoding, errors)


def to_str(s: StrOrBytesOrPathLike) -> str:
def to_str(s: StrOrBytesPath) -> str:
if hasattr(s, '__fspath__'):
s = os.fspath(s)

Expand Down

0 comments on commit 5dca60a

Please sign in to comment.