Skip to content

Add support for Python 3.10 and 3.11 #81

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -15,14 +15,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1000
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

9 changes: 4 additions & 5 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# GitDB documentation build configuration file, created by
# sphinx-quickstart on Wed Jun 30 00:01:32 2010.
@@ -38,8 +37,8 @@
master_doc = 'index'

# General information about the project.
project = u'GitDB'
copyright = u'2011, Sebastian Thiel'
project = 'GitDB'
copyright = '2011, Sebastian Thiel'

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

# The name of an image file (relative to this directory) to place at the top of
12 changes: 6 additions & 6 deletions gitdb/db/base.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
__all__ = ('ObjectDBR', 'ObjectDBW', 'FileDBBase', 'CompoundDB', 'CachingDB')


class ObjectDBR(object):
class ObjectDBR:

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


class ObjectDBW(object):
class ObjectDBW:

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

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


class FileDBBase(object):
class FileDBBase:

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

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


class CachingDB(object):
class CachingDB:

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

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

def _db_query(self, sha):
""":return: database containing the given 20 byte sha
4 changes: 2 additions & 2 deletions gitdb/db/git.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class GitDB(FileDBBase, ObjectDBW, CompoundDB):

def __init__(self, root_path):
"""Initialize ourselves on a git objects directory"""
super(GitDB, self).__init__(root_path)
super().__init__(root_path)

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

#{ ObjectDBW interface
4 changes: 2 additions & 2 deletions gitdb/db/loose.py
Original file line number Diff line number Diff line change
@@ -75,7 +75,7 @@ class LooseObjectDB(FileDBBase, ObjectDBR, ObjectDBW):
new_objects_mode = int("644", 8)

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

def info(self, sha):
m = self._map_loose_object(sha)
2 changes: 1 addition & 1 deletion gitdb/db/mem.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ class MemoryDB(ObjectDBR, ObjectDBW):
exists in the target storage before introducing actual IO"""

def __init__(self):
super(MemoryDB, self).__init__()
super().__init__()
self._db = LooseObjectDB("path/doesnt/matter")

# maps 20 byte shas to their OStream objects
2 changes: 1 addition & 1 deletion gitdb/db/pack.py
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ class PackedDB(FileDBBase, ObjectDBR, CachingDB, LazyMixin):
_sort_interval = 500

def __init__(self, root_path):
super(PackedDB, self).__init__(root_path)
super().__init__(root_path)
# list of lists with three items:
# * hits - number of times the pack was hit with a request
# * entity - Pack entity instance
8 changes: 4 additions & 4 deletions gitdb/db/ref.py
Original file line number Diff line number Diff line change
@@ -20,15 +20,15 @@ class ReferenceDB(CompoundDB):
ObjectDBCls = None

def __init__(self, ref_file):
super(ReferenceDB, self).__init__()
super().__init__()
self._ref_file = ref_file

def _set_cache_(self, attr):
if attr == '_dbs':
self._dbs = list()
self._update_dbs_from_ref_file()
else:
super(ReferenceDB, self)._set_cache_(attr)
super()._set_cache_(attr)
# END handle attrs

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

@@ -79,4 +79,4 @@ def _update_dbs_from_ref_file(self):
def update_cache(self, force=False):
# re-read alternates and update databases
self._update_dbs_from_ref_file()
return super(ReferenceDB, self).update_cache(force)
return super().update_cache(force)
2 changes: 1 addition & 1 deletion gitdb/fun.py
Original file line number Diff line number Diff line change
@@ -113,7 +113,7 @@ def delta_chunk_apply(dc, bbuf, write):
# END handle chunk mode


class DeltaChunk(object):
class DeltaChunk:

"""Represents a piece of a delta, it can either add new data, or copy existing
one from a source buffer"""
4 changes: 2 additions & 2 deletions gitdb/pack.py
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ def write_stream_to_pack(read, write, zstream, base_crc=None):
#} END utilities


class IndexWriter(object):
class IndexWriter:

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

def __init__(self, indexpath):
super(PackIndexFile, self).__init__()
super().__init__()
self._indexpath = indexpath

def close(self):
12 changes: 6 additions & 6 deletions gitdb/stream.py
Original file line number Diff line number Diff line change
@@ -219,13 +219,13 @@ def read(self, size=-1):
# END clamp size

if size == 0:
return bytes()
return b''
# END handle depletion

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

#{ W Streams

class Sha1Writer(object):
class Sha1Writer:

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

def __init__(self, fd):
super(FDCompressedSha1Writer, self).__init__()
super().__init__()
self.fd = fd
self.zip = zlib.compressobj(zlib.Z_BEST_SPEED)

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


class FDStream(object):
class FDStream:

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


class NullStream(object):
class NullStream:

"""A stream that does nothing but providing a stream interface.
Use it like /dev/null"""
2 changes: 1 addition & 1 deletion gitdb/test/db/test_ref.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ def make_alt_file(self, alt_path, alt_list):
The list can be empty"""
with open(alt_path, "wb") as alt_file:
for alt in alt_list:
alt_file.write(alt.encode("utf-8") + "\n".encode("ascii"))
alt_file.write(alt.encode("utf-8") + b"\n")

@with_rw_directory
def test_writing(self, path):
21 changes: 3 additions & 18 deletions gitdb/test/lib.py
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ class TestBase(unittest.TestCase):
@classmethod
def setUpClass(cls):
try:
super(TestBase, cls).setUpClass()
super().setUpClass()
except AttributeError:
pass

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

#{ Decorators

def skip_on_travis_ci(func):
"""All tests decorated with this one will raise SkipTest when run on travis ci.
Use it to workaround difficult to solve issues
NOTE: copied from bcore (https://github.com/Byron/bcore)"""
@wraps(func)
def wrapper(self, *args, **kwargs):
if 'TRAVIS' in os.environ:
import pytest
pytest.skip("Cannot run on travis-ci")
# end check for travis ci
return func(self, *args, **kwargs)
# end wrapper
return wrapper


def with_rw_directory(func):
"""Create a temporary directory which can be written to, remove it if the
test succeeds, but leave it otherwise to aid additional debugging"""
@@ -85,7 +70,7 @@ def wrapper(self):
try:
return func(self, path)
except Exception:
sys.stderr.write("Test {}.{} failed, output is at {!r}\n".format(type(self).__name__, func.__name__, path))
sys.stderr.write(f"Test {type(self).__name__}.{func.__name__} failed, output is at {path!r}\n")
keep = True
raise
finally:
@@ -176,7 +161,7 @@ def make_memory_file(size_in_bytes, randomize=False):
#{ Stream Utilities


class DummyStream(object):
class DummyStream:

def __init__(self):
self.was_read = False
5 changes: 0 additions & 5 deletions gitdb/test/performance/test_pack.py
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
# This module is part of GitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
"""Performance tests for object store"""
from __future__ import print_function

from gitdb.test.performance.lib import (
TestBigRepoR
@@ -17,7 +16,6 @@
from gitdb.typ import str_blob_type
from gitdb.exc import UnsupportedOperation
from gitdb.db.pack import PackedDB
from gitdb.test.lib import skip_on_travis_ci

import sys
import os
@@ -26,7 +24,6 @@

class TestPackedDBPerformance(TestBigRepoR):

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

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

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

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