Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/iterative/py-template",
"commit": "9d27491d231f3c4eaba286d81dc838f8bbc73d37",
"commit": "b003476266a25fc6bc648aecdbe6c8ed82009236",
"context": {
"cookiecutter": {
"project_name": "scmrepo",
Expand Down
15 changes: 7 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ default_language_version:
python: python3
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 22.12.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -30,21 +30,20 @@ repos:
- id: codespell
additional_dependencies: ["tomli"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-broken-line==0.6.0
- flake8-bugbear==22.10.27
- flake8-bugbear==23.1.20
- flake8-comprehensions==3.10.1
- flake8-debugger==4.1.2
- flake8-string-format==0.3.0
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[tool.setuptools_scm]

[tool.black]
line-length = 79
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
Expand All @@ -25,7 +25,7 @@ exclude = '''
[tool.isort]
profile = "black"
known_first_party = ["scmrepo"]
line_length = 79
line_length = 88

[tool.pytest.ini_options]
addopts = "-ra"
Expand Down Expand Up @@ -80,6 +80,9 @@ module = [
]
ignore_missing_imports = true

[tool.pylint.format]
max-line-length = 88

[tool.pylint.master]
extension-pkg-whitelist = ["pygit2"]

Expand Down
14 changes: 9 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ scmrepo = py.typed

[flake8]
ignore=
E203, # Whitespace before ':'
E266, # Too many leading '#' for block comment
W503, # Line break occurred before a binary operator
P1, # unindexed parameters in the str.format, see:
# Whitespace before ':'
E203
# Too many leading '#' for block comment
E266
# Line break occurred before a binary operator
W503
# unindexed parameters in the str.format, see:
# https://pypi.org/project/flake8-string-format/
max_line_length = 79
P1
max_line_length = 88
max-complexity = 15
select = B,C,E,F,W,T4,B902,T,P
show_source = true
Expand Down
25 changes: 5 additions & 20 deletions src/scmrepo/fs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import errno
import os
import posixpath
from typing import (
TYPE_CHECKING,
Any,
BinaryIO,
Callable,
Dict,
Optional,
Tuple,
)
from typing import TYPE_CHECKING, Any, BinaryIO, Callable, Dict, Optional, Tuple

from fsspec.spec import AbstractFileSystem

Expand Down Expand Up @@ -89,8 +81,7 @@ def dirname(self, path):
def parents(self, path):
parts = self.parts(path)
return tuple(
self.join(*parts[:length])
for length in range(len(parts) - 1, 0, -1)
self.join(*parts[:length]) for length in range(len(parts) - 1, 0, -1)
)

def name(self, path):
Expand Down Expand Up @@ -129,9 +120,7 @@ def overlaps(self, left, right):
def relpath(self, path, start=None):
if start is None:
start = "."
return self.flavour.relpath(
self.abspath(path), start=self.abspath(start)
)
return self.flavour.relpath(self.abspath(path), start=self.abspath(start))

def relparts(self, path, start=None):
return self.parts(self.relpath(path, start=start))
Expand Down Expand Up @@ -227,9 +216,7 @@ def info(self, path: str, **kwargs: Any) -> Dict[str, Any]:
ret["name"] = path
return ret
except KeyError:
raise FileNotFoundError(
errno.ENOENT, os.strerror(errno.ENOENT), path
)
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)

def exists(self, path: str, **kwargs: Any) -> bool:
key = self._get_key(path)
Expand All @@ -249,9 +236,7 @@ def ls(self, path, detail=True, **kwargs):
except KeyError as exc:
raise FileNotFoundError from exc

paths = [
posixpath.join(path, name) if path else name for name in names
]
paths = [posixpath.join(path, name) if path else name for name in names]

if not detail:
return paths
Expand Down
34 changes: 8 additions & 26 deletions src/scmrepo/git/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
from pathspec.patterns import GitWildMatchPattern

from scmrepo.base import Base
from scmrepo.exceptions import (
FileNotInRepoError,
GitHookAlreadyExists,
RevError,
)
from scmrepo.exceptions import FileNotInRepoError, GitHookAlreadyExists, RevError
from scmrepo.utils import relpath

from .backend.base import BaseGitBackend, NoGitBackendError
Expand Down Expand Up @@ -50,13 +46,9 @@ def __getitem__(self, key: str) -> BaseGitBackend:
self.initialized[key] = initialized
return initialized

def __init__(
self, selected: Optional[Iterable[str]], *args, **kwargs
) -> None:
def __init__(self, selected: Optional[Iterable[str]], *args, **kwargs) -> None:
selected = selected or list(self.DEFAULT)
self.backends = OrderedDict(
(key, self.DEFAULT[key]) for key in selected
)
self.backends = OrderedDict((key, self.DEFAULT[key]) for key in selected)

self.initialized: Dict[str, BaseGitBackend] = {}

Expand Down Expand Up @@ -91,9 +83,7 @@ class Git(Base):
RE_HEXSHA = re.compile(r"^[0-9A-Fa-f]{4,40}$")
BAD_REF_CHARS_RE = re.compile("[\177\\s~^:?*\\[]")

def __init__(
self, *args, backends: Optional[Iterable[str]] = None, **kwargs
):
def __init__(self, *args, backends: Optional[Iterable[str]] = None, **kwargs):
self.backends = GitBackends(backends, *args, **kwargs)
first_ = first(self.backends.values())
super().__init__(first_.root_dir)
Expand Down Expand Up @@ -234,9 +224,7 @@ def verify_hook(self, name):
if (self.hooks_dir / name).exists():
raise GitHookAlreadyExists(name)

def install_hook(
self, name: str, script: str, interpreter: str = "sh"
) -> None:
def install_hook(self, name: str, script: str, interpreter: str = "sh") -> None:
import shutil

self.hooks_dir.mkdir(exist_ok=True)
Expand All @@ -246,9 +234,7 @@ def install_hook(
hook.write_text(f"{directive}\n{script}\n", encoding="utf-8")
hook.chmod(0o777)

def install_merge_driver(
self, name: str, description: str, driver: str
) -> None:
def install_merge_driver(self, name: str, description: str, driver: str) -> None:
self.gitpython.repo.git.config(f"merge.{name}.name", description)
self.gitpython.repo.git.config(f"merge.{name}.driver", driver)

Expand Down Expand Up @@ -300,9 +286,7 @@ def get_fs(self, rev: str):
return GitFileSystem(scm=self, rev=rev)

@classmethod
def init(
cls, path: str, bare: bool = False, _backend: str = None
) -> "Git":
def init(cls, path: str, bare: bool = False, _backend: str = None) -> "Git":
for name, backend in GitBackends.DEFAULT.items():
if _backend and name != _backend:
continue
Expand Down Expand Up @@ -365,9 +349,7 @@ def add_commit(

get_tree_obj = partialmethod(_backend_func, "get_tree_obj")

def branch_revs(
self, branch: str, end_rev: Optional[str] = None
) -> Iterable[str]:
def branch_revs(self, branch: str, end_rev: Optional[str] = None) -> Iterable[str]:
"""Iterate over revisions in a given branch (from newest to oldest).

If end_rev is set, iterator will stop when the specified revision is
Expand Down
10 changes: 1 addition & 9 deletions src/scmrepo/git/backend/base.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import os
from abc import ABC, abstractmethod
from enum import Enum
from typing import (
TYPE_CHECKING,
Callable,
Iterable,
Mapping,
Optional,
Tuple,
Union,
)
from typing import TYPE_CHECKING, Callable, Iterable, Mapping, Optional, Tuple, Union

from scmrepo.exceptions import SCMError

Expand Down
Loading