summaryrefslogtreecommitdiff
path: root/git/objects
diff options
context:
space:
mode:
authorHugo <hugovk@users.noreply.github.com>2018-03-18 21:33:18 +0200
committerHugo <hugovk@users.noreply.github.com>2018-03-18 22:26:31 +0200
commitac4f7d34f8752ab78949efcaa9f0bd938df33622 (patch)
tree0c7acd1d3c1e0012d26d610c7a9fe81197e28a5e /git/objects
parent14582df679a011e8c741eb5dcd8126f883e1bc71 (diff)
downloadgitpython-ac4f7d34f8752ab78949efcaa9f0bd938df33622.tar.gz
Rewrite unnecessary dict/list/tuple calls as literals
Diffstat (limited to 'git/objects')
-rw-r--r--git/objects/blob.py2
-rw-r--r--git/objects/commit.py4
-rw-r--r--git/objects/fun.py10
-rw-r--r--git/objects/submodule/base.py4
-rw-r--r--git/objects/submodule/root.py4
-rw-r--r--git/objects/tree.py2
-rw-r--r--git/objects/util.py6
7 files changed, 16 insertions, 16 deletions
diff --git a/git/objects/blob.py b/git/objects/blob.py
index 322f6992..897f892b 100644
--- a/git/objects/blob.py
+++ b/git/objects/blob.py
@@ -20,7 +20,7 @@ class Blob(base.IndexObject):
file_mode = 0o100644
link_mode = 0o120000
- __slots__ = tuple()
+ __slots__ = ()
@property
def mime_type(self):
diff --git a/git/objects/commit.py b/git/objects/commit.py
index f29fbaa2..b7d27d92 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -316,7 +316,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
parent_commits = [repo.head.commit]
except ValueError:
# empty repositories have no head commit
- parent_commits = list()
+ parent_commits = []
# END handle parent commits
else:
for p in parent_commits:
@@ -450,7 +450,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
readline = stream.readline
self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '')
- self.parents = list()
+ self.parents = []
next_line = None
while True:
parent_line = readline()
diff --git a/git/objects/fun.py b/git/objects/fun.py
index d5b3f902..38dce0a5 100644
--- a/git/objects/fun.py
+++ b/git/objects/fun.py
@@ -50,7 +50,7 @@ def tree_entries_from_data(data):
space_ord = ord(' ')
len_data = len(data)
i = 0
- out = list()
+ out = []
while i < len_data:
mode = 0
@@ -132,18 +132,18 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix):
:param path_prefix: a prefix to be added to the returned paths on this level,
set it '' for the first iteration
:note: The ordering of the returned items will be partially lost"""
- trees_data = list()
+ trees_data = []
nt = len(tree_shas)
for tree_sha in tree_shas:
if tree_sha is None:
- data = list()
+ data = []
else:
data = tree_entries_from_data(odb.stream(tree_sha).read())
# END handle muted trees
trees_data.append(data)
# END for each sha to get data for
- out = list()
+ out = []
out_append = out.append
# find all matching entries and recursively process them together if the match
@@ -193,7 +193,7 @@ def traverse_tree_recursive(odb, tree_sha, path_prefix):
* [1] mode as int
* [2] path relative to the repository
:param path_prefix: prefix to prepend to the front of all returned paths"""
- entries = list()
+ entries = []
data = tree_entries_from_data(odb.stream(tree_sha).read())
# unpacking/packing is faster than accessing individual items
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index b53ce3ec..f37da34a 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -60,7 +60,7 @@ class UpdateProgress(RemoteProgress):
CLONE, FETCH, UPDWKTREE = [1 << x for x in range(RemoteProgress._num_op_codes, RemoteProgress._num_op_codes + 3)]
_num_op_codes = RemoteProgress._num_op_codes + 3
- __slots__ = tuple()
+ __slots__ = ()
BEGIN = UpdateProgress.BEGIN
@@ -139,7 +139,7 @@ class Submodule(IndexObject, Iterable, Traversable):
try:
return type(self).list_items(item.module())
except InvalidGitRepositoryError:
- return list()
+ return []
# END handle intermediate items
@classmethod
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index fbd658d7..f2035e5b 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -22,7 +22,7 @@ class RootUpdateProgress(UpdateProgress):
1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)]
_num_op_codes = UpdateProgress._num_op_codes + 4
- __slots__ = tuple()
+ __slots__ = ()
BEGIN = RootUpdateProgress.BEGIN
@@ -38,7 +38,7 @@ class RootModule(Submodule):
"""A (virtual) Root of all submodules in the given repository. It can be used
to more easily traverse all submodules of the master repository"""
- __slots__ = tuple()
+ __slots__ = ()
k_root_name = '__ROOT__'
diff --git a/git/objects/tree.py b/git/objects/tree.py
index ed7c2435..d6134e30 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -189,7 +189,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
def _get_intermediate_items(cls, index_object):
if index_object.type == "tree":
return tuple(index_object._iter_convert_to_object(index_object._cache))
- return tuple()
+ return ()
def _set_cache_(self, attr):
if attr == "_cache":
diff --git a/git/objects/util.py b/git/objects/util.py
index 5c085aec..f630f966 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -153,7 +153,7 @@ def parse_date(string_date):
offset = utctz_to_altz(offset)
# now figure out the date and time portion - split time
- date_formats = list()
+ date_formats = []
splitter = -1
if ',' in string_date:
date_formats.append("%a, %d %b %Y")
@@ -248,7 +248,7 @@ class Traversable(object):
into one direction.
Subclasses only need to implement one function.
Instances of the Subclass must be hashable"""
- __slots__ = tuple()
+ __slots__ = ()
@classmethod
def _get_intermediate_items(cls, item):
@@ -344,7 +344,7 @@ class Traversable(object):
class Serializable(object):
"""Defines methods to serialize and deserialize objects from and into a data stream"""
- __slots__ = tuple()
+ __slots__ = ()
def _serialize(self, stream):
"""Serialize the data of this object into the given data stream