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

Commitae37a4a

Browse files
committed
Revise docstrings within git.objects
But not within git.objects.submodule, which was done in63c62ed.
1 parentc06dfd9 commitae37a4a

File tree

8 files changed

+415
-267
lines changed

8 files changed

+415
-267
lines changed

‎git/objects/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from .tagimport*# noqa: F403
1515
from .treeimport*# noqa: F403
1616

17-
# Fix import dependency - add IndexObject to the util module, so that it can be
18-
#importedby the submodule.base.
17+
# Fix import dependency - add IndexObject to the util module, so that it can be imported
18+
# by the submodule.base.
1919
smutil.IndexObject=IndexObject# type: ignore[attr-defined] # noqa: F405
2020
smutil.Object=Object# type: ignore[attr-defined] # noqa: F405
2121
delsmutil

‎git/objects/base.py‎

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737

3838

3939
classObject(LazyMixin):
40-
"""An Object which may be Blobs, Trees, Commits and Tags."""
40+
"""An Object which may be :class:`~git.objects.blob.Blob`,
41+
:class:`~git.objects.tree.Tree`, :class:`~git.objects.commit.Commit` or
42+
`~git.objects.tag.TagObject`."""
4143

4244
NULL_HEX_SHA="0"*40
4345
NULL_BIN_SHA=b"\0"*20
@@ -55,11 +57,14 @@ class Object(LazyMixin):
5557

5658
def__init__(self,repo:"Repo",binsha:bytes):
5759
"""Initialize an object by identifying it by its binary sha.
60+
5861
All keyword arguments will be set on demand if None.
5962
60-
:param repo: repository this object is located in
63+
:param repo:
64+
Repository this object is located in.
6165
62-
:param binsha: 20 byte SHA1
66+
:param binsha:
67+
20 byte SHA1
6368
"""
6469
super().__init__()
6570
self.repo=repo
@@ -72,24 +77,28 @@ def __init__(self, repo: "Repo", binsha: bytes):
7277
@classmethod
7378
defnew(cls,repo:"Repo",id:Union[str,"Reference"])->Commit_ish:
7479
"""
75-
:return: New :class:`Object`` instance of a type appropriate to the object type
76-
behind `id`. The id of the newly created object will be a binsha even though
77-
the input id may have been a Reference or Rev-Spec.
80+
:return:
81+
New :class:`Object` instance of a type appropriate to the object type behind
82+
`id`. The id of the newly created object will be a binsha even though the
83+
input id may have been a `~git.refs.reference.Reference` or rev-spec.
7884
79-
:param id: reference, rev-spec, or hexsha
85+
:param id:
86+
:class:`~git.refs.reference.Reference`, rev-spec, or hexsha
8087
81-
:note: This cannot be a ``__new__`` method as it would always call
82-
:meth:`__init__` with the input id which is not necessarily a binsha.
88+
:note:
89+
This cannot be a ``__new__`` method as it would always call :meth:`__init__`
90+
with the input id which is not necessarily a binsha.
8391
"""
8492
returnrepo.rev_parse(str(id))
8593

8694
@classmethod
8795
defnew_from_sha(cls,repo:"Repo",sha1:bytes)->Commit_ish:
8896
"""
89-
:return: new object instance of a type appropriate to represent the given
90-
binary sha1
97+
:return:
98+
New object instance of a type appropriate to represent the givenbinary sha1
9199
92-
:param sha1: 20 byte binary sha1
100+
:param sha1:
101+
20 byte binary sha1
93102
"""
94103
ifsha1==cls.NULL_BIN_SHA:
95104
# The NULL binsha is always the root commit.
@@ -126,11 +135,11 @@ def __hash__(self) -> int:
126135
returnhash(self.binsha)
127136

128137
def__str__(self)->str:
129-
""":return:string of our SHA1 as understood by all git commands"""
138+
""":return:String of our SHA1 as understood by all git commands"""
130139
returnself.hexsha
131140

132141
def__repr__(self)->str:
133-
""":return:string with pythonic representation of our object"""
142+
""":return:String with pythonic representation of our object"""
134143
return'<git.%s "%s">'% (self.__class__.__name__,self.hexsha)
135144

136145
@property
@@ -142,26 +151,32 @@ def hexsha(self) -> str:
142151
@property
143152
defdata_stream(self)->"OStream":
144153
"""
145-
:return: File Object compatible stream to the uncompressed raw data of the object
154+
:return:
155+
File-object compatible stream to the uncompressed raw data of the object
146156
147-
:note: Returned streams must be read in order.
157+
:note:
158+
Returned streams must be read in order.
148159
"""
149160
returnself.repo.odb.stream(self.binsha)
150161

151162
defstream_data(self,ostream:"OStream")->"Object":
152163
"""Write our data directly to the given output stream.
153164
154-
:param ostream: File object compatible stream object.
155-
:return: self
165+
:param ostream:
166+
File-object compatible stream object.
167+
168+
:return:
169+
self
156170
"""
157171
istream=self.repo.odb.stream(self.binsha)
158172
stream_copy(istream,ostream)
159173
returnself
160174

161175

162176
classIndexObject(Object):
163-
"""Base for all objects that can be part of the index file, namely Tree, Blob and
164-
SubModule objects."""
177+
"""Base for all objects that can be part of the index file, namely
178+
:class:`~git.objects.tree.Tree`, :class:`~git.objects.blob.Blob` and
179+
:class:`~git.objects.submodule.base.Submodule` objects."""
165180

166181
__slots__= ("path","mode")
167182

@@ -175,16 +190,22 @@ def __init__(
175190
mode:Union[None,int]=None,
176191
path:Union[None,PathLike]=None,
177192
)->None:
178-
"""Initialize a newly instanced IndexObject.
193+
"""Initialize a newly instanced :class:`IndexObject`.
194+
195+
:param repo:
196+
The :class:`~git.repo.base.Repo` we are located in.
197+
198+
:param binsha:
199+
20 byte sha1.
179200
180-
:param repo: The :class:`~git.repo.base.Repo` we are located in.
181-
:param binsha: 20 byte sha1.
182201
:param mode:
183202
The stat compatible file mode as int, use the :mod:`stat` module to evaluate
184203
the information.
204+
185205
:param path:
186206
The path to the file in the file system, relative to the git repository
187207
root, like ``file.ext`` or ``folder/other.ext``.
208+
188209
:note:
189210
Path may not be set if the index object has been created directly, as it
190211
cannot be retrieved without knowing the parent tree.
@@ -198,8 +219,8 @@ def __init__(
198219
def__hash__(self)->int:
199220
"""
200221
:return:
201-
Hash of our path as index items are uniquely identifiable by path, not
202-
bytheir data!
222+
Hash of our path as index items are uniquely identifiable by path, not by
223+
their data!
203224
"""
204225
returnhash(self.path)
205226

‎git/objects/blob.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def mime_type(self) -> str:
2929
"""
3030
:return: String describing the mime type of this file (based on the filename)
3131
32-
:note: Defaults to 'text/plain' in case the actual file type is unknown.
32+
:note:
33+
Defaults to ``text/plain`` in case the actual file type is unknown.
3334
"""
3435
guesses=None
3536
ifself.path:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp