Skip to content

Commit f78587f

Browse files
committed
Remove explicit inheritance from object
Within the git module. In Python 2, it was necessary to inherit from object to have a new-style class. In Python 3, all classes are new-style classes, and inheritance from object is implied. Usually, removing explicit inheritance from object is only a small clarity benefit while modernizing Python codebases. However, in GitPython, the benefit is greater, because it is possible to confuse object (the root of the Python class hierarchy) with Object (the root of the GitPython subhierarchy of classes representing things in the git object model).
1 parent e8343e2 commit f78587f

File tree

9 files changed

+16
-16
lines changed

9 files changed

+16
-16
lines changed

git/cmd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def check_unsafe_options(cls, options: List[str], unsafe_options: List[str]) ->
490490
f"{unsafe_option} is not allowed, use `allow_unsafe_options=True` to allow it."
491491
)
492492

493-
class AutoInterrupt(object):
493+
class AutoInterrupt:
494494
"""Process wrapper that terminates the wrapped process on finalization.
495495
496496
This kills/interrupts the stored process instance once this instance goes out of
@@ -602,7 +602,7 @@ def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> byte
602602

603603
# END auto interrupt
604604

605-
class CatFileContentStream(object):
605+
class CatFileContentStream:
606606
"""Object representing a sized read-only stream returning the contents of
607607
an object.
608608

git/diff.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def decode_path(path: bytes, has_ab_prefix: bool = True) -> Optional[bytes]:
7979
return path
8080

8181

82-
class Diffable(object):
82+
class Diffable:
8383
"""Common interface for all objects that can be diffed against another object of
8484
compatible type.
8585
@@ -90,7 +90,7 @@ class Diffable(object):
9090

9191
__slots__ = ()
9292

93-
class Index(object):
93+
class Index:
9494
"""Stand-in indicating you want to diff against the index."""
9595

9696
def _process_diff_args(
@@ -252,7 +252,7 @@ def iter_change_type(self, change_type: Lit_change_type) -> Iterator[T_Diff]:
252252
# END for each diff
253253

254254

255-
class Diff(object):
255+
class Diff:
256256
"""A Diff contains diff information between two Trees.
257257
258258
It contains two sides a and b of the diff, members are prefixed with

git/index/typ.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# } END invariants
3333

3434

35-
class BlobFilter(object):
35+
class BlobFilter:
3636
"""
3737
Predicate to be used by iter_blobs allowing to filter only return blobs which
3838
match the given list of directories or files.

git/index/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# } END aliases
3434

3535

36-
class TemporaryFileSwap(object):
36+
class TemporaryFileSwap:
3737
"""Utility class moving a file to a temporary location within the same directory
3838
and moving it back on to where on object deletion."""
3939

git/objects/tree.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def merge_sort(a: List[TreeCacheTup], cmp: Callable[[TreeCacheTup, TreeCacheTup]
102102
k = k + 1
103103

104104

105-
class TreeModifier(object):
105+
class TreeModifier:
106106
"""A utility class providing methods to alter the underlying cache in a list-like fashion.
107107
108108
Once all adjustments are complete, the _cache, which really is a reference to

git/objects/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def parse_actor_and_date(line: str) -> Tuple[Actor, int, int]:
337337
# { Classes
338338

339339

340-
class ProcessStreamAdapter(object):
340+
class ProcessStreamAdapter:
341341
"""Class wiring all calls to the contained Process instance.
342342
343343
Use this type to hide the underlying process to provide access only to a specified

git/refs/symbolic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _git_dir(repo: "Repo", path: Union[PathLike, None]) -> PathLike:
5555
return repo.common_dir
5656

5757

58-
class SymbolicReference(object):
58+
class SymbolicReference:
5959
"""Special case of a reference that is symbolic.
6060
6161
This does not point to a specific commit, but to another

git/repo/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class BlameEntry(NamedTuple):
108108
orig_linenos: range
109109

110110

111-
class Repo(object):
111+
class Repo:
112112
"""Represents a git repository and allows you to query references,
113113
gather commit information, generate diffs, create and clone repositories query
114114
the log.

git/util.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ def remove_password_if_present(cmdline: Sequence[str]) -> List[str]:
516516
# { Classes
517517

518518

519-
class RemoteProgress(object):
519+
class RemoteProgress:
520520
"""
521521
Handler providing an interface to parse progress information emitted by git-push
522522
and git-fetch and to dispatch callbacks allowing subclasses to react to the progress.
@@ -723,7 +723,7 @@ def update(self, *args: Any, **kwargs: Any) -> None:
723723
self._callable(*args, **kwargs)
724724

725725

726-
class Actor(object):
726+
class Actor:
727727
"""Actors hold information about a person acting on the repository. They
728728
can be committers and authors or anything with a name and an email as
729729
mentioned in the git log entries."""
@@ -847,7 +847,7 @@ def author(cls, config_reader: Union[None, "GitConfigParser", "SectionConstraint
847847
return cls._main_actor(cls.env_author_name, cls.env_author_email, config_reader)
848848

849849

850-
class Stats(object):
850+
class Stats:
851851
"""
852852
Represents stat information as presented by git at the end of a merge. It is
853853
created from the output of a diff operation.
@@ -908,7 +908,7 @@ def _list_from_string(cls, repo: "Repo", text: str) -> "Stats":
908908
return Stats(hsh["total"], hsh["files"])
909909

910910

911-
class IndexFileSHA1Writer(object):
911+
class IndexFileSHA1Writer:
912912
"""Wrapper around a file-like object that remembers the SHA1 of
913913
the data written to it. It will write a sha when the stream is closed
914914
or if the asked for explicitly using write_sha.
@@ -942,7 +942,7 @@ def tell(self) -> int:
942942
return self.f.tell()
943943

944944

945-
class LockFile(object):
945+
class LockFile:
946946
"""Provides methods to obtain, check for, and release a file based lock which
947947
should be used to handle concurrent access to the same file.
948948

0 commit comments

Comments
 (0)