Skip to content

Commit 3415e08

Browse files
authored
Merge pull request #81 from hugovk/master
Add support for Python 3.10 and 3.11
2 parents 2ce0e31 + 7a68270 commit 3415e08

21 files changed

+50
-96
lines changed

.github/workflows/pythonpackage.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
18+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1919

2020
steps:
21-
- uses: actions/checkout@v2
21+
- uses: actions/checkout@v3
2222
with:
2323
fetch-depth: 1000
2424
- name: Set up Python ${{ matrix.python-version }}
25-
uses: actions/setup-python@v2
25+
uses: actions/setup-python@v4
2626
with:
2727
python-version: ${{ matrix.python-version }}
2828
- name: Install dependencies

.travis.yml

-20
This file was deleted.

doc/source/conf.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# GitDB documentation build configuration file, created by
43
# sphinx-quickstart on Wed Jun 30 00:01:32 2010.
@@ -38,8 +37,8 @@
3837
master_doc = 'index'
3938

4039
# General information about the project.
41-
project = u'GitDB'
42-
copyright = u'2011, Sebastian Thiel'
40+
project = 'GitDB'
41+
copyright = '2011, Sebastian Thiel'
4342

4443
# The version info for the project you're documenting, acts as replacement for
4544
# |version| and |release|, also used in various other places throughout the
@@ -172,8 +171,8 @@
172171
# Grouping the document tree into LaTeX files. List of tuples
173172
# (source start file, target name, title, author, documentclass [howto/manual]).
174173
latex_documents = [
175-
('index', 'GitDB.tex', u'GitDB Documentation',
176-
u'Sebastian Thiel', 'manual'),
174+
('index', 'GitDB.tex', 'GitDB Documentation',
175+
'Sebastian Thiel', 'manual'),
177176
]
178177

179178
# The name of an image file (relative to this directory) to place at the top of

gitdb/db/base.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__all__ = ('ObjectDBR', 'ObjectDBW', 'FileDBBase', 'CompoundDB', 'CachingDB')
2323

2424

25-
class ObjectDBR(object):
25+
class ObjectDBR:
2626

2727
"""Defines an interface for object database lookup.
2828
Objects are identified either by their 20 byte bin sha"""
@@ -63,7 +63,7 @@ def sha_iter(self):
6363
#} END query interface
6464

6565

66-
class ObjectDBW(object):
66+
class ObjectDBW:
6767

6868
"""Defines an interface to create objects in the database"""
6969

@@ -105,7 +105,7 @@ def store(self, istream):
105105
#} END edit interface
106106

107107

108-
class FileDBBase(object):
108+
class FileDBBase:
109109

110110
"""Provides basic facilities to retrieve files of interest, including
111111
caching facilities to help mapping hexsha's to objects"""
@@ -117,7 +117,7 @@ def __init__(self, root_path):
117117
**Note:** The base will not perform any accessablity checking as the base
118118
might not yet be accessible, but become accessible before the first
119119
access."""
120-
super(FileDBBase, self).__init__()
120+
super().__init__()
121121
self._root_path = root_path
122122

123123
#{ Interface
@@ -133,7 +133,7 @@ def db_path(self, rela_path):
133133
#} END interface
134134

135135

136-
class CachingDB(object):
136+
class CachingDB:
137137

138138
"""A database which uses caches to speed-up access"""
139139

@@ -176,7 +176,7 @@ def _set_cache_(self, attr):
176176
elif attr == '_db_cache':
177177
self._db_cache = dict()
178178
else:
179-
super(CompoundDB, self)._set_cache_(attr)
179+
super()._set_cache_(attr)
180180

181181
def _db_query(self, sha):
182182
""":return: database containing the given 20 byte sha

gitdb/db/git.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class GitDB(FileDBBase, ObjectDBW, CompoundDB):
3939

4040
def __init__(self, root_path):
4141
"""Initialize ourselves on a git objects directory"""
42-
super(GitDB, self).__init__(root_path)
42+
super().__init__(root_path)
4343

4444
def _set_cache_(self, attr):
4545
if attr == '_dbs' or attr == '_loose_db':
@@ -68,7 +68,7 @@ def _set_cache_(self, attr):
6868
# finally set the value
6969
self._loose_db = loose_db
7070
else:
71-
super(GitDB, self)._set_cache_(attr)
71+
super()._set_cache_(attr)
7272
# END handle attrs
7373

7474
#{ ObjectDBW interface

gitdb/db/loose.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW):
7575
new_objects_mode = int("644", 8)
7676

7777
def __init__(self, root_path):
78-
super(LooseObjectDB, self).__init__(root_path)
78+
super().__init__(root_path)
7979
self._hexsha_to_file = dict()
8080
# Additional Flags - might be set to 0 after the first failure
8181
# Depending on the root, this might work for some mounts, for others not, which
@@ -151,7 +151,7 @@ def set_ostream(self, stream):
151151
""":raise TypeError: if the stream does not support the Sha1Writer interface"""
152152
if stream is not None and not isinstance(stream, Sha1Writer):
153153
raise TypeError("Output stream musst support the %s interface" % Sha1Writer.__name__)
154-
return super(LooseObjectDB, self).set_ostream(stream)
154+
return super().set_ostream(stream)
155155

156156
def info(self, sha):
157157
m = self._map_loose_object(sha)

gitdb/db/mem.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class MemoryDB(ObjectDBR, ObjectDBW):
3737
exists in the target storage before introducing actual IO"""
3838

3939
def __init__(self):
40-
super(MemoryDB, self).__init__()
40+
super().__init__()
4141
self._db = LooseObjectDB("path/doesnt/matter")
4242

4343
# maps 20 byte shas to their OStream objects

gitdb/db/pack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PackedDB(FileDBBase, ObjectDBR, CachingDB, LazyMixin):
3939
_sort_interval = 500
4040

4141
def __init__(self, root_path):
42-
super(PackedDB, self).__init__(root_path)
42+
super().__init__(root_path)
4343
# list of lists with three items:
4444
# * hits - number of times the pack was hit with a request
4545
# * entity - Pack entity instance

gitdb/db/ref.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ class ReferenceDB(CompoundDB):
2020
ObjectDBCls = None
2121

2222
def __init__(self, ref_file):
23-
super(ReferenceDB, self).__init__()
23+
super().__init__()
2424
self._ref_file = ref_file
2525

2626
def _set_cache_(self, attr):
2727
if attr == '_dbs':
2828
self._dbs = list()
2929
self._update_dbs_from_ref_file()
3030
else:
31-
super(ReferenceDB, self)._set_cache_(attr)
31+
super()._set_cache_(attr)
3232
# END handle attrs
3333

3434
def _update_dbs_from_ref_file(self):
@@ -44,7 +44,7 @@ def _update_dbs_from_ref_file(self):
4444
try:
4545
with codecs.open(self._ref_file, 'r', encoding="utf-8") as f:
4646
ref_paths = [l.strip() for l in f]
47-
except (OSError, IOError):
47+
except OSError:
4848
pass
4949
# END handle alternates
5050

@@ -79,4 +79,4 @@ def _update_dbs_from_ref_file(self):
7979
def update_cache(self, force=False):
8080
# re-read alternates and update databases
8181
self._update_dbs_from_ref_file()
82-
return super(ReferenceDB, self).update_cache(force)
82+
return super().update_cache(force)

gitdb/fun.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def delta_chunk_apply(dc, bbuf, write):
113113
# END handle chunk mode
114114

115115

116-
class DeltaChunk(object):
116+
class DeltaChunk:
117117

118118
"""Represents a piece of a delta, it can either add new data, or copy existing
119119
one from a source buffer"""

gitdb/pack.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def write_stream_to_pack(read, write, zstream, base_crc=None):
170170
#} END utilities
171171

172172

173-
class IndexWriter(object):
173+
class IndexWriter:
174174

175175
"""Utility to cache index information, allowing to write all information later
176176
in one go to the given stream
@@ -257,7 +257,7 @@ class PackIndexFile(LazyMixin):
257257
index_version_default = 2
258258

259259
def __init__(self, indexpath):
260-
super(PackIndexFile, self).__init__()
260+
super().__init__()
261261
self._indexpath = indexpath
262262

263263
def close(self):

gitdb/stream.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ def read(self, size=-1):
219219
# END clamp size
220220

221221
if size == 0:
222-
return bytes()
222+
return b''
223223
# END handle depletion
224224

225225
# deplete the buffer, then just continue using the decompress object
226226
# which has an own buffer. We just need this to transparently parse the
227227
# header from the zlib stream
228-
dat = bytes()
228+
dat = b''
229229
if self._buf:
230230
if self._buflen >= size:
231231
# have enough data
@@ -553,7 +553,7 @@ def size(self):
553553

554554
#{ W Streams
555555

556-
class Sha1Writer(object):
556+
class Sha1Writer:
557557

558558
"""Simple stream writer which produces a sha whenever you like as it degests
559559
everything it is supposed to write"""
@@ -650,7 +650,7 @@ class FDCompressedSha1Writer(Sha1Writer):
650650
exc = IOError("Failed to write all bytes to filedescriptor")
651651

652652
def __init__(self, fd):
653-
super(FDCompressedSha1Writer, self).__init__()
653+
super().__init__()
654654
self.fd = fd
655655
self.zip = zlib.compressobj(zlib.Z_BEST_SPEED)
656656

@@ -677,7 +677,7 @@ def close(self):
677677
#} END stream interface
678678

679679

680-
class FDStream(object):
680+
class FDStream:
681681

682682
"""A simple wrapper providing the most basic functions on a file descriptor
683683
with the fileobject interface. Cannot use os.fdopen as the resulting stream
@@ -711,7 +711,7 @@ def close(self):
711711
close(self._fd)
712712

713713

714-
class NullStream(object):
714+
class NullStream:
715715

716716
"""A stream that does nothing but providing a stream interface.
717717
Use it like /dev/null"""

gitdb/test/db/test_ref.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def make_alt_file(self, alt_path, alt_list):
2323
The list can be empty"""
2424
with open(alt_path, "wb") as alt_file:
2525
for alt in alt_list:
26-
alt_file.write(alt.encode("utf-8") + "\n".encode("ascii"))
26+
alt_file.write(alt.encode("utf-8") + b"\n")
2727

2828
@with_rw_directory
2929
def test_writing(self, path):

gitdb/test/lib.py

+3-18
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TestBase(unittest.TestCase):
4040
@classmethod
4141
def setUpClass(cls):
4242
try:
43-
super(TestBase, cls).setUpClass()
43+
super().setUpClass()
4444
except AttributeError:
4545
pass
4646

@@ -58,21 +58,6 @@ def setUpClass(cls):
5858

5959
#{ Decorators
6060

61-
def skip_on_travis_ci(func):
62-
"""All tests decorated with this one will raise SkipTest when run on travis ci.
63-
Use it to workaround difficult to solve issues
64-
NOTE: copied from bcore (https://github.com/Byron/bcore)"""
65-
@wraps(func)
66-
def wrapper(self, *args, **kwargs):
67-
if 'TRAVIS' in os.environ:
68-
import pytest
69-
pytest.skip("Cannot run on travis-ci")
70-
# end check for travis ci
71-
return func(self, *args, **kwargs)
72-
# end wrapper
73-
return wrapper
74-
75-
7661
def with_rw_directory(func):
7762
"""Create a temporary directory which can be written to, remove it if the
7863
test succeeds, but leave it otherwise to aid additional debugging"""
@@ -85,7 +70,7 @@ def wrapper(self):
8570
try:
8671
return func(self, path)
8772
except Exception:
88-
sys.stderr.write("Test {}.{} failed, output is at {!r}\n".format(type(self).__name__, func.__name__, path))
73+
sys.stderr.write(f"Test {type(self).__name__}.{func.__name__} failed, output is at {path!r}\n")
8974
keep = True
9075
raise
9176
finally:
@@ -176,7 +161,7 @@ def make_memory_file(size_in_bytes, randomize=False):
176161
#{ Stream Utilities
177162

178163

179-
class DummyStream(object):
164+
class DummyStream:
180165

181166
def __init__(self):
182167
self.was_read = False

gitdb/test/performance/test_pack.py

-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# This module is part of GitDB and is released under
44
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
55
"""Performance tests for object store"""
6-
from __future__ import print_function
76

87
from gitdb.test.performance.lib import (
98
TestBigRepoR
@@ -17,7 +16,6 @@
1716
from gitdb.typ import str_blob_type
1817
from gitdb.exc import UnsupportedOperation
1918
from gitdb.db.pack import PackedDB
20-
from gitdb.test.lib import skip_on_travis_ci
2119

2220
import sys
2321
import os
@@ -26,7 +24,6 @@
2624

2725
class TestPackedDBPerformance(TestBigRepoR):
2826

29-
@skip_on_travis_ci
3027
def test_pack_random_access(self):
3128
pdb = PackedDB(os.path.join(self.gitrepopath, "objects/pack"))
3229

@@ -79,7 +76,6 @@ def test_pack_random_access(self):
7976
print("PDB: Obtained %i streams by sha and read all bytes totallying %i KiB ( %f KiB / s ) in %f s ( %f streams/s )" %
8077
(max_items, total_kib, total_kib / (elapsed or 1), elapsed, max_items / (elapsed or 1)), file=sys.stderr)
8178

82-
@skip_on_travis_ci
8379
def test_loose_correctness(self):
8480
"""based on the pack(s) of our packed object DB, we will just copy and verify all objects in the back
8581
into the loose object db (memory).
@@ -106,7 +102,6 @@ def test_loose_correctness(self):
106102
mdb._cache.clear()
107103
# end for each sha to copy
108104

109-
@skip_on_travis_ci
110105
def test_correctness(self):
111106
pdb = PackedDB(os.path.join(self.gitrepopath, "objects/pack"))
112107
# disabled for now as it used to work perfectly, checking big repositories takes a long time

0 commit comments

Comments
 (0)