Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit018ebaf

Browse files
committed
Further revise docstrings within git.repo
1 parenta5a1b2c commit018ebaf

File tree

2 files changed

+44
-38
lines changed

2 files changed

+44
-38
lines changed

‎git/repo/base.py

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class BlameEntry(NamedTuple):
102102

103103

104104
classRepo:
105-
"""Represents a git repository and allows you to query references,
106-
gathercommit information, generate diffs, create and clone repositories, and query
107-
thelog.
105+
"""Represents a git repository and allows you to query references, father
106+
commit information, generate diffs, create and clone repositories, and query the
107+
log.
108108
109109
The following attributes are worth using:
110110
@@ -188,16 +188,18 @@ def __init__(
188188
repo = Repo(R"C:\Users\mtrier\Development\git-python\.git")
189189
190190
- In *Cygwin*, `path` may be a ``cygdrive/...`` prefixed path.
191-
- If `path` is None or an empty string, :envvar:`GIT_DIR` is used. If that
192-
environment variable is absent or empty, the current directory is used.
191+
- If `path` is ``None`` or an empty string, :envvar:`GIT_DIR` is used. If
192+
that environment variable is absent or empty, the current directory is
193+
used.
193194
194195
:param odbt:
195196
Object DataBase type - a type which is constructed by providing the
196197
directory containing the database objects, i.e. ``.git/objects``. It will be
197-
used to access all object data
198+
used to access all object data.
198199
199200
:param search_parent_directories:
200-
If True, all parent directories will be searched for a valid repo as well.
201+
If ``True``, all parent directories will be searched for a valid repo as
202+
well.
201203
202204
Please note that this was the default behaviour in older versions of
203205
GitPython, which is considered a bug though.
@@ -372,7 +374,7 @@ def working_tree_dir(self) -> Optional[PathLike]:
372374
"""
373375
:return:
374376
The working tree directory of our git repository.
375-
If this is a bare repository, None is returned.
377+
If this is a bare repository,``None`` is returned.
376378
"""
377379
returnself._working_tree_dir
378380

@@ -387,7 +389,7 @@ def common_dir(self) -> PathLike:
387389

388390
@property
389391
defbare(self)->bool:
390-
""":return: True if the repository is bare"""
392+
""":return:``True`` if the repository is bare"""
391393
returnself._bare
392394

393395
@property
@@ -450,7 +452,7 @@ def remotes(self) -> "IterableList[Remote]":
450452
defremote(self,name:str="origin")->"Remote":
451453
""":return: The remote with the specified name
452454
453-
:raise ValueError
455+
:raise ValueError:
454456
If no remote with such a name exists.
455457
"""
456458
r=Remote(self,name)
@@ -494,10 +496,13 @@ def create_submodule(self, *args: Any, **kwargs: Any) -> Submodule:
494496
returnSubmodule.add(self,*args,**kwargs)
495497

496498
defiter_submodules(self,*args:Any,**kwargs:Any)->Iterator[Submodule]:
497-
"""An iterator yielding Submodule instances, see Traversable interface
498-
for a description of args and kwargs.
499+
"""An iterator yielding Submodule instances.
499500
500-
:return: Iterator
501+
See the `~git.objects.util.Traversable` interface for a description of `args`
502+
and `kwargs`.
503+
504+
:return:
505+
Iterator
501506
"""
502507
returnRootModule(self).traverse(*args,**kwargs)
503508

@@ -554,7 +559,8 @@ def create_head(
554559
)->"Head":
555560
"""Create a new head within the repository.
556561
557-
:note: For more documentation, please see the
562+
:note:
563+
For more documentation, please see the
558564
:meth:`Head.create <git.refs.head.Head.create>` method.
559565
560566
:return:
@@ -648,7 +654,7 @@ def config_reader(
648654
configuration files.
649655
650656
:param config_level:
651-
For possible values, see the :meth:`config_writer` method. If None, all
657+
For possible values, see the :meth:`config_writer` method. If``None``, all
652658
applicable levels will be used. Specify a level in case you know which file
653659
you wish to read to prevent reading multiple files.
654660
@@ -744,7 +750,7 @@ def iter_commits(
744750
745751
:param rev:
746752
Revision specifier, see ``git rev-parse`` for viable options.
747-
If None, the active branch will be used.
753+
If``None``, the active branch will be used.
748754
749755
:param paths:
750756
An optional path or a list of paths. If set, only commits that include the
@@ -759,7 +765,7 @@ def iter_commits(
759765
``"revA...revB"`` revision specifier.
760766
761767
:return:
762-
Iterator of:class:`~git.objects.commit.Commit` objects
768+
Iterator of :class:`~git.objects.commit.Commit` objects
763769
"""
764770
ifrevisNone:
765771
rev=self.head.commit
@@ -819,7 +825,7 @@ def is_ancestor(self, ancestor_rev: "Commit", rev: "Commit") -> bool:
819825
Rev to test against `ancestor_rev`.
820826
821827
:return:
822-
True if `ancestor_rev` is an ancestor to `rev`.
828+
``True`` if `ancestor_rev` is an ancestor to `rev`.
823829
"""
824830
try:
825831
self.git.merge_base(ancestor_rev,rev,is_ancestor=True)
@@ -923,9 +929,9 @@ def is_dirty(
923929
)->bool:
924930
"""
925931
:return:
926-
True if the repository is considered dirty. By default it will react like a
927-
git-status without untracked files, hence it is dirty if the index or the
928-
working copy have changes.
932+
``True`` if the repository is considered dirty. By default it will react
933+
like agit-status without untracked files, hence it is dirty if the index or
934+
theworking copy have changes.
929935
"""
930936
ifself._bare:
931937
# Bare repositories with no associated working directory are
@@ -1036,9 +1042,9 @@ def blame_incremental(self, rev: str | HEAD | None, file: str, **kwargs: Any) ->
10361042
stream of :class:`BlameEntry` tuples.
10371043
10381044
:param rev:
1039-
Revision specifier. If None, the blame will include all the latest
1040-
uncommitted changes. Otherwise, anything successfully parsed by ``git
1041-
rev-parse`` is a valid option.
1045+
Revision specifier. If``None``, the blame will include all the latest
1046+
uncommitted changes. Otherwise, anything successfully parsed by
1047+
``gitrev-parse`` is a valid option.
10421048
10431049
:return:
10441050
Lazy iterator of :class:`BlameEntry` tuples, where the commit indicates the
@@ -1132,9 +1138,9 @@ def blame(
11321138
"""The blame information for the given file at the given revision.
11331139
11341140
:param rev:
1135-
Revision specifier. If None, the blame will include all the latest
1141+
Revision specifier. If``None``, the blame will include all the latest
11361142
uncommitted changes. Otherwise, anything successfully parsed by
1137-
git-rev-parse is a valid option.
1143+
``gitrev-parse`` is a valid option.
11381144
11391145
:return:
11401146
list: [git.Commit, list: [<line>]]
@@ -1286,9 +1292,9 @@ def init(
12861292
"""Initialize a git repository at the given path if specified.
12871293
12881294
:param path:
1289-
The full path to the repo (traditionally ends with ``/<name>.git``).
1290-
OrNone, in which case the repository will be created in the current working
1291-
directory.
1295+
The full path to the repo (traditionally ends with ``/<name>.git``). Or
1296+
``None``, in which case the repository will be created in the current
1297+
workingdirectory.
12921298
12931299
:param mkdir:
12941300
If specified, will create the repository directory if it doesn't already
@@ -1445,7 +1451,7 @@ def clone(
14451451
Allow unsafe options to be used, like ``--upload-pack``.
14461452
14471453
:param kwargs:
1448-
* odbt = ObjectDatabase Type, allowing to determine the object database
1454+
*``odbt`` = ObjectDatabase Type, allowing to determine the object database
14491455
implementation used by the returned Repo instance.
14501456
* All remaining keyword arguments are given to the ``git clone`` command.
14511457
@@ -1547,9 +1553,9 @@ def archive(
15471553
:param kwargs:
15481554
Additional arguments passed to ``git archive``:
15491555
1550-
* Use the'format' argument to define the kind of format. Use specialized
1556+
* Use the``format`` argument to define the kind of format. Use specialized
15511557
ostreams to write any format supported by Python.
1552-
* You may specify the special**path** keyword, which may either be a
1558+
* You may specify the special``path`` keyword, which may either be a
15531559
repository-relative path to a directory or file to place into the archive,
15541560
or a list or tuple of multiple paths.
15551561
@@ -1581,7 +1587,7 @@ def has_separate_working_tree(self) -> bool:
15811587
to.
15821588
15831589
:note:
1584-
Bare repositories will always return False here.
1590+
Bare repositories will always return``False`` here.
15851591
"""
15861592
ifself.bare:
15871593
returnFalse
@@ -1601,7 +1607,7 @@ def currently_rebasing_on(self) -> Commit | None:
16011607
:return:
16021608
The commit which is currently being replayed while rebasing.
16031609
1604-
None if we are not currently rebasing.
1610+
``None`` if we are not currently rebasing.
16051611
"""
16061612
ifself.git_dir:
16071613
rebase_head_file=osp.join(self.git_dir,"REBASE_HEAD")

‎git/repo/fun.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def find_submodule_git_dir(d: "PathLike") -> Optional["PathLike"]:
128128
defshort_to_long(odb:"GitCmdObjectDB",hexsha:str)->Optional[bytes]:
129129
"""
130130
:return:
131-
Long hexadecimal sha1 from the given less than 40 byte hexsha or None if no
131+
Long hexadecimal sha1 from the given less than 40 byte hexsha, or``None`` if no
132132
candidate could be found.
133133
134134
:param hexsha:
@@ -150,7 +150,7 @@ def name_to_object(
150150
references are supported.
151151
152152
:param return_ref:
153-
If True, and name specifies a reference, we will return the reference
153+
If``True``, and name specifies a reference, we will return the reference
154154
instead of the object. Otherwise it will raise `~gitdb.exc.BadObject` o
155155
`~gitdb.exc.BadName`.
156156
"""
@@ -202,7 +202,7 @@ def name_to_object(
202202

203203

204204
defderef_tag(tag:"Tag")->"TagObject":
205-
"""Recursively dereference a tag and return the resulting object"""
205+
"""Recursively dereference a tag and return the resulting object."""
206206
whileTrue:
207207
try:
208208
tag=tag.object
@@ -213,7 +213,7 @@ def deref_tag(tag: "Tag") -> "TagObject":
213213

214214

215215
defto_commit(obj:Object)->Union["Commit","TagObject"]:
216-
"""Convert the given object to a commit if possible and return it"""
216+
"""Convert the given object to a commit if possible and return it."""
217217
ifobj.type=="tag":
218218
obj=deref_tag(obj)
219219

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp