Skip to content

Commit

Permalink
Remove explicit inheritance from object
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
EliahKagan committed Oct 22, 2023
1 parent e8343e2 commit f78587f
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def check_unsafe_options(cls, options: List[str], unsafe_options: List[str]) ->
f"{unsafe_option} is not allowed, use `allow_unsafe_options=True` to allow it."
)

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

# END auto interrupt

class CatFileContentStream(object):
class CatFileContentStream:
"""Object representing a sized read-only stream returning the contents of
an object.
Expand Down
6 changes: 3 additions & 3 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def decode_path(path: bytes, has_ab_prefix: bool = True) -> Optional[bytes]:
return path


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

__slots__ = ()

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

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


class Diff(object):
class Diff:
"""A Diff contains diff information between two Trees.
It contains two sides a and b of the diff, members are prefixed with
Expand Down
2 changes: 1 addition & 1 deletion git/index/typ.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# } END invariants


class BlobFilter(object):
class BlobFilter:
"""
Predicate to be used by iter_blobs allowing to filter only return blobs which
match the given list of directories or files.
Expand Down
2 changes: 1 addition & 1 deletion git/index/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# } END aliases


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

Expand Down
2 changes: 1 addition & 1 deletion git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def merge_sort(a: List[TreeCacheTup], cmp: Callable[[TreeCacheTup, TreeCacheTup]
k = k + 1


class TreeModifier(object):
class TreeModifier:
"""A utility class providing methods to alter the underlying cache in a list-like fashion.
Once all adjustments are complete, the _cache, which really is a reference to
Expand Down
2 changes: 1 addition & 1 deletion git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def parse_actor_and_date(line: str) -> Tuple[Actor, int, int]:
# { Classes


class ProcessStreamAdapter(object):
class ProcessStreamAdapter:
"""Class wiring all calls to the contained Process instance.
Use this type to hide the underlying process to provide access only to a specified
Expand Down
2 changes: 1 addition & 1 deletion git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _git_dir(repo: "Repo", path: Union[PathLike, None]) -> PathLike:
return repo.common_dir


class SymbolicReference(object):
class SymbolicReference:
"""Special case of a reference that is symbolic.
This does not point to a specific commit, but to another
Expand Down
2 changes: 1 addition & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class BlameEntry(NamedTuple):
orig_linenos: range


class Repo(object):
class Repo:
"""Represents a git repository and allows you to query references,
gather commit information, generate diffs, create and clone repositories query
the log.
Expand Down
10 changes: 5 additions & 5 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def remove_password_if_present(cmdline: Sequence[str]) -> List[str]:
# { Classes


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


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


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


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


class LockFile(object):
class LockFile:
"""Provides methods to obtain, check for, and release a file based lock which
should be used to handle concurrent access to the same file.
Expand Down

0 comments on commit f78587f

Please sign in to comment.