Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

random fixes #1332

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
55bc286
add some rules to ruff
DinhHuy2010 Dec 21, 2024
2c06530
ignore unused imports
DinhHuy2010 Dec 21, 2024
484886a
Initial formatting and liniting fix of all files
DinhHuy2010 Dec 21, 2024
6330d4b
add type checking configuration (use pyright)
DinhHuy2010 Dec 21, 2024
325891b
add _libgit2.pyi
DinhHuy2010 Dec 21, 2024
aa37e2d
mega fix _pygit2.pyi
DinhHuy2010 Dec 21, 2024
b53b9a7
fix stubs
DinhHuy2010 Dec 21, 2024
c70241d
change lib to Any
DinhHuy2010 Dec 21, 2024
42b5129
fix pyright config
DinhHuy2010 Dec 21, 2024
5f6657e
fix _pygit2.pyi again
DinhHuy2010 Dec 21, 2024
4b3878b
fix enums.py
DinhHuy2010 Dec 21, 2024
49bc71b
add FilterSource
DinhHuy2010 Dec 21, 2024
7433683
yet another fix the _pygit2.pyi
DinhHuy2010 Dec 21, 2024
3aabbc7
add typing to credentials.py
DinhHuy2010 Dec 21, 2024
9a1affc
add typing to errors.py
DinhHuy2010 Dec 21, 2024
735ba5a
fix pyproject again
DinhHuy2010 Dec 21, 2024
5fc3b70
add filter_* functions to _pygit2.pyi
DinhHuy2010 Dec 21, 2024
95b003f
add typing to utils.py
DinhHuy2010 Dec 21, 2024
e71d03b
fix ffi.py
DinhHuy2010 Dec 21, 2024
9b68da8
initial commit of pygit2 __init__
DinhHuy2010 Dec 21, 2024
7afd694
remove pygit2 star imports
DinhHuy2010 Dec 22, 2024
b2680c3
fix pyproject again
DinhHuy2010 Dec 22, 2024
4970a94
fix pyproject
DinhHuy2010 Dec 22, 2024
40f44c1
fix pyproject again
DinhHuy2010 Dec 22, 2024
e3ed43f
initial commit of pygit2 callbacks.py
DinhHuy2010 Dec 22, 2024
35fb5e1
typing fix for __init__.py
DinhHuy2010 Dec 22, 2024
c3b01f8
fix typing for _build.py and _run.py
DinhHuy2010 Dec 24, 2024
0fe1aac
fix pyproject.toml
DinhHuy2010 Dec 25, 2024
58b88c2
add typing for packbuilder.py
DinhHuy2010 Dec 25, 2024
d8755fb
fix typing for utils
DinhHuy2010 Dec 25, 2024
8114f2b
hotfix for packbuilder.py
DinhHuy2010 Dec 25, 2024
071df9d
fix _pygit2.pyi
DinhHuy2010 Dec 25, 2024
9a10a41
initial stub for repository.py
DinhHuy2010 Dec 25, 2024
5f2d9ae
add typing for branches.py
DinhHuy2010 Dec 29, 2024
720881e
add typing to blob.py and fix _pygit2.pyi
DinhHuy2010 Dec 30, 2024
0e55fb3
add typing for blame.py and add _ctyping
DinhHuy2010 Dec 30, 2024
6ab13f7
Resolve confilcts from 'upstream/master'
DinhHuy2010 Dec 30, 2024
5dca60a
change pathtype name to StrOrBytesPath
DinhHuy2010 Dec 30, 2024
599f2b7
fix _ctyping
DinhHuy2010 Dec 30, 2024
d3be17a
fix _ctyping again
DinhHuy2010 Dec 30, 2024
dddd720
add maybe_bytes
DinhHuy2010 Dec 30, 2024
f019420
add typing to config.py
DinhHuy2010 Jan 13, 2025
86c62cd
Merge branch 'master' of https://github.com/libgit2/pygit2 into typec…
DinhHuy2010 Jan 13, 2025
b0da06b
fix typing
DinhHuy2010 Jan 13, 2025
0fab374
Solve confilcts
DinhHuy2010 Feb 17, 2025
8b46dec
Merge branch 'master' into typecheck
DinhHuy2010 Feb 17, 2025
48e0dce
fix config
DinhHuy2010 Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change pathtype name to StrOrBytesPath
DinhHuy2010 committed Dec 30, 2024
commit 5dca60a00ec6690f278922f37afec82af9f3434c
4 changes: 2 additions & 2 deletions pygit2/packbuilder.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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
8 changes: 4 additions & 4 deletions pygit2/utils.py
Original file line number Diff line number Diff line change
@@ -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:
@@ -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:
@@ -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)