Skip to content

Commit c572905

Browse files
committed
Complete some argument default values/type hints in _pygit2
1 parent 602b894 commit c572905

5 files changed

Lines changed: 25 additions & 26 deletions

File tree

pygit2/_pygit2.pyi

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ class Diff:
278278
@staticmethod
279279
def from_c(diff, repo) -> Diff: ...
280280
@staticmethod
281-
def parse_diff(git_diff: str) -> Diff: ...
281+
def parse_diff(git_diff: str | bytes) -> Diff: ...
282282
def __getitem__(self, index: int) -> Patch: ... # Diff_getitem
283283
def __iter__(self) -> Iterator[Patch]: ... # -> DiffIter
284284
def __len__(self) -> int: ...
@@ -332,7 +332,7 @@ class Mailmap:
332332
def __init__(self, *args) -> None: ...
333333
def add_entry(self, real_name: str = ..., real_email: str = ..., replace_name: str = ..., replace_email: str = ...) -> None: ...
334334
@staticmethod
335-
def from_buffer(buffer: str) -> Mailmap: ...
335+
def from_buffer(buffer: str | bytes) -> Mailmap: ...
336336
@staticmethod
337337
def from_repository(repository: Repository) -> Mailmap: ...
338338
def resolve(self, name: str, email: str) -> tuple[str,str]: ...
@@ -342,7 +342,7 @@ class Note:
342342
annotated_id: Oid
343343
id: Oid
344344
message: str
345-
def remove(self, author: Signature, committer: Signature, ref: str = ...) -> None: ...
345+
def remove(self, author: Signature, committer: Signature, ref: str = "refs/notes/commits") -> None: ...
346346

347347
class Odb:
348348
backends: Iterator[OdbBackend] = ...
@@ -449,8 +449,8 @@ class Repository:
449449
def _disown(self, *args, **kwargs) -> None: ...
450450
def _from_c(self, *args, **kwargs) -> None: ...
451451
def add_worktree(self, name: str, path: str, ref: Reference = ...) -> Worktree: ...
452-
def applies(self, diff: Diff, location: int = ...) -> bool: ...
453-
def apply(self, diff: Diff, location: int = ...) -> None: ...
452+
def applies(self, diff: Diff, location: int = GIT_APPLY_LOCATION_INDEX) -> bool: ...
453+
def apply(self, diff: Diff, location: int = GIT_APPLY_LOCATION_WORKDIR) -> None: ...
454454
def cherrypick(self, id: _OidArg) -> None: ...
455455
def compress_references(self) -> None: ...
456456
def create_blob(self, data: bytes) -> Oid: ...
@@ -459,7 +459,7 @@ class Repository:
459459
def create_blob_fromworkdir(self, path: str) -> Oid: ...
460460
def create_branch(self, name: str, commit: Commit, force = ...) -> Branch: ...
461461
def create_commit(self, reference_name: str, author: Signature, committer: Signature, message: str, tree: _OidArg, parents: list[_OidArg], encoding: str = ...) -> Oid: ...
462-
def create_note(self, message: str, author: Signature, committer: Signature, annotated_id: str, ref: str = ..., force: bool = ...) -> Oid: ...
462+
def create_note(self, message: str, author: Signature, committer: Signature, annotated_id: str, ref: str = "refs/notes/commits", force: bool = False) -> Oid: ...
463463
def create_reference_direct(self, name: str, target, force = ..., message: str = ...) -> Reference: ...
464464
def create_reference_symbolic(self, name, source, force, message = ...) -> Reference: ...
465465
def create_tag(self, name: str, oid: _OidArg, type: int, tagger: Signature, message: str) -> Oid: ...
@@ -469,13 +469,13 @@ class Repository:
469469
def git_object_lookup_prefix(self, oid: _OidArg) -> Object: ...
470470
def init_submodules(self, submodules: list[pygit2.Submodule] = ..., overwrite = ...) -> None: ...
471471
def list_worktrees(self) -> list[str]: ...
472-
def listall_branches(self, flag: int = ...) -> list[str]: ...
472+
def listall_branches(self, flag: int = GIT_BRANCH_LOCAL) -> list[str]: ...
473473
def listall_reference_objects(self) -> list[Reference]: ...
474474
def listall_references(self) -> list[str]: ...
475475
def listall_stashes(self) -> list[Stash]: ...
476476
def listall_submodules(self) -> list[str]: ...
477-
def lookup_branch(self, branch_name: str, branch_type: int = ...) -> Branch: ...
478-
def lookup_note(self, annotated_id: str, ref: str = ...) -> Note: ...
477+
def lookup_branch(self, branch_name: str, branch_type: int = GIT_BRANCH_LOCAL) -> Branch: ...
478+
def lookup_note(self, annotated_id: str, ref: str = "refs/notes/commits") -> Note: ...
479479
def lookup_reference(self, name: str) -> Reference: ...
480480
def lookup_reference_dwim(self, name: str) -> Reference: ...
481481
def lookup_worktree(self, name: str) -> Worktree: ...
@@ -486,7 +486,7 @@ class Repository:
486486
def merge_base_octopus(self, oids: list[_OidArg]) -> Oid: ...
487487
def notes(self) -> Iterator[Note]: ...
488488
def path_is_ignored(self, path: str) -> bool: ...
489-
def raw_listall_branches(self, flag: int = ...) -> list[bytes]: ...
489+
def raw_listall_branches(self, flag: int = GIT_BRANCH_LOCAL) -> list[bytes]: ...
490490
def raw_listall_references(self) -> list[bytes]: ...
491491
def reset(self, oid: _OidArg, reset_type: int) -> None: ...
492492
def revparse(self, revspec: str) -> RevSpec: ...
@@ -496,7 +496,7 @@ class Repository:
496496
def set_refdb(self, refdb: Refdb) -> None: ...
497497
def status(self) -> dict[str,int]: ...
498498
def status_file(self, path: str) -> int: ...
499-
def walk(self, oid: _OidArg | None, sort_mode: int = ...) -> Walker: ...
499+
def walk(self, oid: _OidArg | None, sort_mode: int = GIT_SORT_NONE) -> Walker: ...
500500

501501
class RevSpec:
502502
flags: int
@@ -574,13 +574,12 @@ class Worktree:
574574
path: str
575575
def prune(self, force = ...) -> None: ...
576576

577-
def discover_repository(path: str, across_fs: bool = ..., ceiling_dirs: str = ...) -> str: ...
577+
def discover_repository(path: str, across_fs: bool = False, ceiling_dirs: str = ...) -> str: ...
578578
def hash(data: bytes) -> Oid: ...
579579
def hashfile(path: str) -> Oid: ...
580-
def init_file_backend(path: str, flags: int = ...) -> object: ...
580+
def init_file_backend(path: str, flags: int = 0) -> object: ...
581581
def option(*args, **kwargs) -> None: ...
582582
def reference_is_valid_name(refname: str) -> bool: ...
583583
def tree_entry_cmp(a: Object, b: Object) -> int: ...
584584

585585
_OidArg = str | Oid
586-

src/diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ Diff_stats__get__(Diff *self)
10091009
}
10101010

10111011
PyDoc_STRVAR(Diff_parse_diff__doc__,
1012-
"parse_diff(git_diff: str) -> Diff\n"
1012+
"parse_diff(git_diff: str | bytes) -> Diff\n"
10131013
"\n"
10141014
"Parses a git unified diff into a diff object without a repository");
10151015

src/note.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
extern PyTypeObject SignatureType;
3838

3939
PyDoc_STRVAR(Note_remove__doc__,
40-
"remove(author: Signature, committer: Signature, ref: str = ...)\n"
40+
"remove(author: Signature, committer: Signature, ref: str = \"refs/notes/commits\")\n"
4141
"\n"
4242
"Removes a note for an annotated object");
4343

src/pygit2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extern PyTypeObject StashType;
8282

8383

8484
PyDoc_STRVAR(discover_repository__doc__,
85-
"discover_repository(path: str, across_fs: bool = ..., ceiling_dirs: str = ...) -> str\n"
85+
"discover_repository(path: str, across_fs: bool = False, ceiling_dirs: str = ...) -> str\n"
8686
"\n"
8787
"Look for a git repository and return its path. If not found returns None.");
8888

@@ -177,7 +177,7 @@ hash(PyObject *self, PyObject *args)
177177

178178

179179
PyDoc_STRVAR(init_file_backend__doc__,
180-
"init_file_backend(path: str, flags: int = ...) -> object\n"
180+
"init_file_backend(path: str, flags: int = 0) -> object\n"
181181
"\n"
182182
"Open repo backend given path.");
183183
PyObject *

src/repository.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Repository_git_object_lookup_prefix(Repository *self, PyObject *key)
307307

308308

309309
PyDoc_STRVAR(Repository_lookup_branch__doc__,
310-
"lookup_branch(branch_name: str, branch_type: int = ...) -> Branch\n"
310+
"lookup_branch(branch_name: str, branch_type: int = GIT_BRANCH_LOCAL) -> Branch\n"
311311
"\n"
312312
"Returns the Git reference for the given branch name (local or remote).\n"
313313
"If branch_type is GIT_BRANCH_REMOTE, you must include the remote name\n"
@@ -792,7 +792,7 @@ Repository_cherrypick(Repository *self, PyObject *py_oid)
792792
}
793793

794794
PyDoc_STRVAR(Repository_walk__doc__,
795-
"walk(oid: Oid | None, sort_mode: int = ...) -> Walker\n"
795+
"walk(oid: Oid | None, sort_mode: int = GIT_SORT_NONE) -> Walker\n"
796796
"\n"
797797
"Start traversing the history from the given commit.\n"
798798
"The following types of sorting could be used to control traversing\n"
@@ -1350,7 +1350,7 @@ Repository_listall_branches_impl(Repository *self, PyObject *args, PyObject *(*i
13501350
}
13511351

13521352
PyDoc_STRVAR(Repository_listall_branches__doc__,
1353-
"listall_branches(flag: int = ...) -> list[str]\n"
1353+
"listall_branches(flag: int = GIT_BRANCH_LOCAL) -> list[str]\n"
13541354
"\n"
13551355
"Return a list with all the branches in the repository.\n"
13561356
"\n"
@@ -1367,7 +1367,7 @@ Repository_listall_branches(Repository *self, PyObject *args)
13671367
}
13681368

13691369
PyDoc_STRVAR(Repository_raw_listall_branches__doc__,
1370-
"raw_listall_branches(flag: int = ...) -> list[bytes]\n"
1370+
"raw_listall_branches(flag: int = GIT_BRANCH_LOCAL) -> list[bytes]\n"
13711371
"\n"
13721372
"Return a list with all the branches in the repository.\n"
13731373
"\n"
@@ -1881,7 +1881,7 @@ Repository_notes(Repository *self, PyObject *args)
18811881

18821882

18831883
PyDoc_STRVAR(Repository_create_note__doc__,
1884-
"create_note(message: str, author: Signature, committer: Signature, annotated_id: str, ref: str = ..., force: bool = ...) -> Oid\n"
1884+
"create_note(message: str, author: Signature, committer: Signature, annotated_id: str, ref: str = \"refs/notes/commits\", force: bool = False) -> Oid\n"
18851885
"\n"
18861886
"Create a new note for an object, return its SHA-ID."
18871887
"If no ref is given 'refs/notes/commits' will be used.");
@@ -1917,7 +1917,7 @@ Repository_create_note(Repository *self, PyObject* args)
19171917

19181918

19191919
PyDoc_STRVAR(Repository_lookup_note__doc__,
1920-
"lookup_note(annotated_id: str, ref: str = ...) -> Note\n"
1920+
"lookup_note(annotated_id: str, ref: str = \"refs/notes/commits\") -> Note\n"
19211921
"\n"
19221922
"Lookup a note for an annotated object in a repository.");
19231923

@@ -2109,7 +2109,7 @@ Repository_list_worktrees(Repository *self, PyObject *args)
21092109
}
21102110

21112111
PyDoc_STRVAR(Repository_apply__doc__,
2112-
"apply(diff: Diff, location: int = ...)\n"
2112+
"apply(diff: Diff, location: int = GIT_APPLY_LOCATION_WORKDIR)\n"
21132113
"\n"
21142114
"Applies the given Diff object to HEAD, writing the results into the\n"
21152115
"working directory, the index, or both.\n"
@@ -2146,7 +2146,7 @@ Repository_apply(Repository *self, PyObject *args, PyObject *kwds)
21462146
}
21472147

21482148
PyDoc_STRVAR(Repository_applies__doc__,
2149-
"applies(diff: Diff, location: int = ...) -> bool\n"
2149+
"applies(diff: Diff, location: int = GIT_APPLY_LOCATION_INDEX) -> bool\n"
21502150
"\n"
21512151
"Tests if the given patch will apply to HEAD, without writing it.\n"
21522152
"\n"

0 commit comments

Comments
 (0)