Skip to content

Commit 4a7e852

Browse files
committed
Increase minimum required python version
1 parent b55a772 commit 4a7e852

File tree

10 files changed

+63
-76
lines changed

10 files changed

+63
-76
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
python-version: [3.6, 3.7, 3.8, 3.9]
11+
python-version: ["3.8", "3.9", "3.10"]
1212
os: [ubuntu-latest, macOS-latest]
1313

1414
steps:
1515
- uses: actions/checkout@v1
16-
- name: Setup msys2
17-
if: ${{ matrix.os == 'windows-latest' }}
18-
run: |
19-
echo "C:\msys64\usr\bin" >> $GITHUB_PATH
2016
- name: Set up Python ${{ matrix.python-version }}
2117
uses: actions/setup-python@v1
2218
with:
2319
python-version: ${{ matrix.python-version }}
2420
- name: Install tox
2521
run: |
2622
python -m pip install --upgrade pip
27-
pip install tox
28-
- name: Run tox
29-
run: |
30-
tox --skip-missing-interpreters true
23+
pip install tox tox-gh-actions
24+
- name: Test with tox
25+
run: tox
26+
env:
27+
PLATFORM: ${{ matrix.os }}

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

gitrevise/merge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
unmodified trees and blobs when possible.
1111
"""
1212

13+
from __future__ import annotations
14+
1315
from typing import Iterator, Optional, Tuple, TypeVar
1416
from pathlib import Path
1517
from subprocess import CalledProcessError
@@ -365,7 +367,7 @@ class ConflictParseFailed(Exception):
365367

366368
def normalize_conflict(
367369
lines: Iterator[bytes],
368-
hasher: Optional["hashlib._Hash"],
370+
hasher: Optional[hashlib._Hash],
369371
) -> bytes:
370372
cur_hunk: Optional[bytes] = b""
371373
other_hunk: Optional[bytes] = None

gitrevise/odb.py

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Helper classes for reading cached objects from Git's Object Database.
33
"""
44

5+
from __future__ import annotations
6+
57
import hashlib
68
import re
79
import os
@@ -48,18 +50,18 @@ class Oid(bytes):
4850

4951
__slots__ = ()
5052

51-
def __new__(cls, b: bytes) -> "Oid":
53+
def __new__(cls, b: bytes) -> Oid:
5254
if len(b) != 20:
5355
raise ValueError("Expected 160-bit SHA1 hash")
5456
return super().__new__(cls, b) # type: ignore
5557

5658
@classmethod
57-
def fromhex(cls, instr: str) -> "Oid":
59+
def fromhex(cls, instr: str) -> Oid:
5860
"""Parse an ``Oid`` from a hexadecimal string"""
5961
return Oid(bytes.fromhex(instr))
6062

6163
@classmethod
62-
def null(cls) -> "Oid":
64+
def null(cls) -> Oid:
6365
"""An ``Oid`` consisting of entirely 0s"""
6466
return cls(b"\0" * 20)
6567

@@ -68,7 +70,7 @@ def short(self) -> str:
6870
return str(self)[:12]
6971

7072
@classmethod
71-
def for_object(cls, tag: str, body: bytes) -> "Oid":
73+
def for_object(cls, tag: str, body: bytes) -> Oid:
7274
"""Hash an object with the given type tag and body to determine its Oid"""
7375
hasher = hashlib.sha1()
7476
hasher.update(tag.encode() + b" " + str(len(body)).encode() + b"\0" + body)
@@ -149,7 +151,7 @@ class Repository:
149151
default_committer: Signature
150152
"""committer used by default for new commits"""
151153

152-
index: "Index"
154+
index: Index
153155
"""current index state"""
154156

155157
sign_commits: bool
@@ -158,7 +160,7 @@ class Repository:
158160
gpg: bytes
159161
"""path to GnuPG binary"""
160162

161-
_objects: Dict[int, Dict[Oid, "GitObj"]]
163+
_objects: Dict[int, Dict[Oid, GitObj]]
162164
_catfile: Popen
163165
_tempdir: Optional[TemporaryDirectory]
164166

@@ -257,7 +259,7 @@ def int_config(self, config: str, default: T) -> Union[int, T]:
257259
except CalledProcessError:
258260
return default
259261

260-
def __enter__(self) -> "Repository":
262+
def __enter__(self) -> Repository:
261263
return self
262264

263265
def __exit__(
@@ -287,12 +289,12 @@ def git_path(self, path: Union[str, Path]) -> Path:
287289

288290
def new_commit(
289291
self,
290-
tree: "Tree",
291-
parents: Sequence["Commit"],
292+
tree: Tree,
293+
parents: Sequence[Commit],
292294
message: bytes,
293295
author: Optional[Signature] = None,
294296
committer: Optional[Signature] = None,
295-
) -> "Commit":
297+
) -> Commit:
296298
"""Directly create an in-memory commit object, without persisting it.
297299
If a commit object with these properties already exists, it will be
298300
returned instead."""
@@ -343,7 +345,7 @@ def sign_buffer(self, buffer: bytes) -> bytes:
343345
signature += b" " + line + b"\n"
344346
return signature
345347

346-
def new_tree(self, entries: Mapping[bytes, "Entry"]) -> "Tree":
348+
def new_tree(self, entries: Mapping[bytes, Entry]) -> Tree:
347349
"""Directly create an in-memory tree object, without persisting it.
348350
If a tree object with these entries already exists, it will be
349351
returned instead."""
@@ -361,7 +363,7 @@ def entry_key(pair: Tuple[bytes, Entry]) -> bytes:
361363
body += cast(bytes, entry.mode.value) + b" " + name + b"\0" + entry.oid
362364
return Tree(self, body)
363365

364-
def get_obj(self, ref: Union[Oid, str]) -> "GitObj":
366+
def get_obj(self, ref: Union[Oid, str]) -> GitObj:
365367
"""Get the identified git object from this repository. If given an
366368
:class:`Oid`, the cache will be checked before asking git."""
367369
if isinstance(ref, Oid):
@@ -414,40 +416,40 @@ def get_obj(self, ref: Union[Oid, str]) -> "GitObj":
414416
assert obj.oid == oid, "miscomputed oid"
415417
return obj
416418

417-
def get_commit(self, ref: Union[Oid, str]) -> "Commit":
419+
def get_commit(self, ref: Union[Oid, str]) -> Commit:
418420
"""Like :py:meth:`get_obj`, but returns a :class:`Commit`"""
419421
obj = self.get_obj(ref)
420422
if isinstance(obj, Commit):
421423
return obj
422424
raise ValueError(f"{type(obj).__name__} {ref} is not a Commit!")
423425

424-
def get_tree(self, ref: Union[Oid, str]) -> "Tree":
426+
def get_tree(self, ref: Union[Oid, str]) -> Tree:
425427
"""Like :py:meth:`get_obj`, but returns a :class:`Tree`"""
426428
obj = self.get_obj(ref)
427429
if isinstance(obj, Tree):
428430
return obj
429431
raise ValueError(f"{type(obj).__name__} {ref} is not a Tree!")
430432

431-
def get_blob(self, ref: Union[Oid, str]) -> "Blob":
433+
def get_blob(self, ref: Union[Oid, str]) -> Blob:
432434
"""Like :py:meth:`get_obj`, but returns a :class:`Blob`"""
433435
obj = self.get_obj(ref)
434436
if isinstance(obj, Blob):
435437
return obj
436438
raise ValueError(f"{type(obj).__name__} {ref} is not a Blob!")
437439

438-
def get_obj_ref(self, ref: str) -> "Reference[GitObj]":
440+
def get_obj_ref(self, ref: str) -> Reference[GitObj]:
439441
"""Get a :class:`Reference` to a :class:`GitObj`"""
440442
return Reference(GitObj, self, ref)
441443

442-
def get_commit_ref(self, ref: str) -> "Reference[Commit]":
444+
def get_commit_ref(self, ref: str) -> Reference[Commit]:
443445
"""Get a :class:`Reference` to a :class:`Commit`"""
444446
return Reference(Commit, self, ref)
445447

446-
def get_tree_ref(self, ref: str) -> "Reference[Tree]":
448+
def get_tree_ref(self, ref: str) -> Reference[Tree]:
447449
"""Get a :class:`Reference` to a :class:`Tree`"""
448450
return Reference(Tree, self, ref)
449451

450-
def get_blob_ref(self, ref: str) -> "Reference[Blob]":
452+
def get_blob_ref(self, ref: str) -> Reference[Blob]:
451453
"""Get a :class:`Reference` to a :class:`Blob`"""
452454
return Reference(Blob, self, ref)
453455

@@ -573,11 +575,11 @@ def _parse_body(self) -> None:
573575
elif key == b"gpgsig":
574576
self.gpgsig = value
575577

576-
def tree(self) -> "Tree":
578+
def tree(self) -> Tree:
577579
"""``tree`` object corresponding to this commit"""
578580
return self.repo.get_tree(self.tree_oid)
579581

580-
def parent_tree(self) -> "Tree":
582+
def parent_tree(self) -> Tree:
581583
"""``tree`` object corresponding to the first parent of this commit,
582584
or the null tree if this is a root commit"""
583585
if self.is_root:
@@ -589,11 +591,11 @@ def is_root(self) -> bool:
589591
"""Whether this commit has no parents"""
590592
return not self.parent_oids
591593

592-
def parents(self) -> Sequence["Commit"]:
594+
def parents(self) -> Sequence[Commit]:
593595
"""List of parent commits"""
594596
return [self.repo.get_commit(parent) for parent in self.parent_oids]
595597

596-
def parent(self) -> "Commit":
598+
def parent(self) -> Commit:
597599
"""Helper method to get the single parent of a commit. Raises
598600
:class:`ValueError` if the incorrect number of parents are
599601
present."""
@@ -609,7 +611,7 @@ def summary(self) -> str:
609611
)
610612
return " ".join(summary_paragraph.splitlines())
611613

612-
def rebase(self, parent: Optional["Commit"]) -> "Commit":
614+
def rebase(self, parent: Optional[Commit]) -> Commit:
613615
"""Create a new commit with the same changes, except with ``parent``
614616
as its parent. If ``parent`` is ``None``, this becomes a root commit."""
615617
from .merge import rebase # pylint: disable=import-outside-toplevel
@@ -618,12 +620,12 @@ def rebase(self, parent: Optional["Commit"]) -> "Commit":
618620

619621
def update(
620622
self,
621-
tree: Optional["Tree"] = None,
622-
parents: Optional[Sequence["Commit"]] = None,
623+
tree: Optional[Tree] = None,
624+
parents: Optional[Sequence[Commit]] = None,
623625
message: Optional[bytes] = None,
624626
author: Optional[Signature] = None,
625627
recommit: bool = False,
626-
) -> "Commit":
628+
) -> Commit:
627629
"""Create a new commit with specific properties updated or replaced"""
628630
# Compute parameters used to create the new object.
629631
if tree is None:
@@ -683,7 +685,7 @@ class Mode(Enum):
683685
def is_file(self) -> bool:
684686
return self in (Mode.REGULAR, Mode.EXEC)
685687

686-
def comparable_to(self, other: "Mode") -> bool:
688+
def comparable_to(self, other: Mode) -> bool:
687689
return self == other or (self.is_file() and other.is_file())
688690

689691

@@ -706,7 +708,7 @@ def __init__(self, repo: Repository, mode: Mode, oid: Oid) -> None:
706708
self.mode = mode
707709
self.oid = oid
708710

709-
def blob(self) -> "Blob":
711+
def blob(self) -> Blob:
710712
"""Get the data for this entry as a :class:`Blob`"""
711713
if self.mode in (Mode.REGULAR, Mode.EXEC):
712714
return self.repo.get_blob(self.oid)
@@ -718,7 +720,7 @@ def symlink(self) -> bytes:
718720
return self.repo.get_blob(self.oid).body
719721
return b"<non-symlink>"
720722

721-
def tree(self) -> "Tree":
723+
def tree(self) -> Tree:
722724
"""Get the data for this entry as a :class:`Tree`"""
723725
if self.mode == Mode.DIR:
724726
return self.repo.get_tree(self.oid)
@@ -760,7 +762,7 @@ def _persist_deps(self) -> None:
760762
for entry in self.entries.values():
761763
entry.persist()
762764

763-
def to_index(self, path: Path, skip_worktree: bool = False) -> "Index":
765+
def to_index(self, path: Path, skip_worktree: bool = False) -> Index:
764766
"""Read tree into a temporary index. If skip_workdir is ``True``, every
765767
entry in the index will have its "Skip Workdir" bit set."""
766768

gitrevise/todo.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import re
24
from enum import Enum
35
from typing import List, Optional
@@ -18,7 +20,7 @@ def __str__(self) -> str:
1820
return str(self.value)
1921

2022
@staticmethod
21-
def parse(instr: str) -> "StepKind":
23+
def parse(instr: str) -> StepKind:
2224
if "pick".startswith(instr):
2325
return StepKind.PICK
2426
if "fixup".startswith(instr):
@@ -47,7 +49,7 @@ def __init__(self, kind: StepKind, commit: Commit) -> None:
4749
self.message = None
4850

4951
@staticmethod
50-
def parse(repo: Repository, instr: str) -> "Step":
52+
def parse(repo: Repository, instr: str) -> Step:
5153
parsed = re.match(r"(?P<command>\S+)\s+(?P<hash>\S+)", instr)
5254
if not parsed:
5355
raise ValueError(

gitrevise/tui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import Optional, List
24
from argparse import ArgumentParser, Namespace
35
from subprocess import CalledProcessError

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[mypy]
2-
python_version = 3.6
2+
python_version = 3.8
33
warn_return_any = True
44
warn_unused_configs = True
55

readthedocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ build:
22
image: latest
33

44
python:
5-
version: 3.6
5+
version: 3.8
66

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name="git-revise",
1010
version=gitrevise.__version__,
1111
packages=["gitrevise"],
12-
python_requires=">=3.6",
12+
python_requires=">=3.8",
1313
entry_points={"console_scripts": ["git-revise = gitrevise.tui:main"]},
1414
data_files=[("share/man/man1", ["git-revise.1"])],
1515
author="Nika Layzell",
@@ -28,9 +28,9 @@
2828
"Topic :: Software Development :: Version Control :: Git",
2929
"License :: OSI Approved :: MIT License",
3030
"Programming Language :: Python :: 3",
31-
"Programming Language :: Python :: 3.6",
32-
"Programming Language :: Python :: 3.7",
3331
"Programming Language :: Python :: 3.8",
32+
"Programming Language :: Python :: 3.9",
33+
"Programming Language :: Python :: 3.10",
3434
],
3535
project_urls={
3636
"Bug Tracker": "https://github.com/mystor/git-revise/issues/",

0 commit comments

Comments
 (0)