◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 0 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -16,5 +16,3 @@ jobs:
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --hook-stage manual
env:
SKIP: black-format
18 changes: 2 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
repos:
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black
alias: black-check
name: black (check)
args: [--check, --diff]
exclude: ^git/ext/
stages: [manual]

- id: black
alias: black-format
name: black (format)
exclude: ^git/ext/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
#- id: ruff-format # todo: eventually replace Black with Ruff for consistency
# args: ["--preview"]
- id: ruff
args: ["--fix"]
exclude: ^doc|^git/ext/
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ To lint, and apply automatic code formatting, run:
pre-commit run --all-files
```

- Linting without modifying code can be done with: `make lint`
- Auto-formatting without other lint checks can be done with: `black .`

To typecheck, run:

```bash
Expand Down
18 changes: 6 additions & 12 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,11 @@


@overload
def safe_decode(s: None) -> None:
...


@overload
def safe_decode(s: AnyStr) -> str:
...


def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:
Expand All @@ -91,13 +89,11 @@ def safe_decode(s: Union[AnyStr, None]) -> Optional[str]:


@overload
def safe_encode(s: None) -> None:
...


@overload
def safe_encode(s: AnyStr) -> bytes:
...


def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
Expand All @@ -113,13 +109,11 @@ def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:


@overload
def win_encode(s: None) -> None:
...


@overload
def win_encode(s: AnyStr) -> bytes:
...


def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
Expand Down
6 changes: 3 additions & 3 deletions git/index/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ def read_cache(
# 4 bytes length of chunk
# Repeated 0 - N times
extension_data = stream.read(~0)
assert (
len(extension_data) > 19
), "Index Footer was not at least a sha on content as it was only %i bytes in size" % len(extension_data)

content_sha = extension_data[-20:]

Expand Down
6 changes: 2 additions & 4 deletions git/objects/fun.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,11 @@ def _find_by_name(tree_data: MutableSequence[EntryTupOrNone], name: str, is_dir:


@overload
def _to_full_path(item: None, path_prefix: str) -> None:
...


@overload
def _to_full_path(item: EntryTup, path_prefix: str) -> EntryTup:
...


def _to_full_path(item: EntryTupOrNone, path_prefix: str) -> EntryTupOrNone:
Expand Down
2 changes: 1 addition & 1 deletion git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class Tree(IndexObject, git_diff.Diffable, util.Traversable, util.Serializable):
_map_id_to_type: Dict[int, Type[IndexObjUnion]] = {
commit_id: Submodule,
blob_id: Blob,
symlink_id: Blob
# Tree ID added once Tree is defined.
}

12 changes: 4 additions & 8 deletions git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,7 @@ def list_traverse(self: T_TIobj, *args: Any, **kwargs: Any) -> IterableList[T_TI
return super()._list_traverse(*args, **kwargs)

@overload # type: ignore
def traverse(self: T_TIobj) -> Iterator[T_TIobj]:
...

@overload
def traverse(
Expand All @@ -633,8 +632,7 @@ def traverse(
visit_once: bool,
ignore_self: Literal[True],
as_edge: Literal[False],
) -> Iterator[T_TIobj]:
...

@overload
def traverse(
Expand All @@ -646,8 +644,7 @@ def traverse(
visit_once: bool,
ignore_self: Literal[False],
as_edge: Literal[True],
) -> Iterator[Tuple[Union[T_TIobj, None], T_TIobj]]:
...

@overload
def traverse(
Expand All @@ -659,8 +656,7 @@ def traverse(
visit_once: bool,
ignore_self: Literal[True],
as_edge: Literal[True],
) -> Iterator[Tuple[T_TIobj, T_TIobj]]:
...

def traverse(
self: T_TIobj,
Expand Down
11 changes: 4 additions & 7 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,19 @@ def add_progress(


@overload
def to_progress_instance(progress: None) -> RemoteProgress:
...


@overload
def to_progress_instance(progress: Callable[..., Any]) -> CallableRemoteProgress:
...


@overload
def to_progress_instance(progress: RemoteProgress) -> RemoteProgress:
...


def to_progress_instance(
progress: Union[Callable[..., Any], RemoteProgress, None]
) -> Union[RemoteProgress, CallableRemoteProgress]:
"""Given the `progress` return a suitable object derived from
:class:`~git.util.RemoteProgress`."""
Expand Down
9 changes: 3 additions & 6 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,11 @@ def decygpath(path: PathLike) -> str:


@overload
def is_cygwin_git(git_executable: None) -> Literal[False]:
...


@overload
def is_cygwin_git(git_executable: PathLike) -> bool:
...


def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
Expand Up @@ -494,8 +492,7 @@ def finalize_process(proc: Union[subprocess.Popen, "Git.AutoInterrupt"], **kwarg


@overload
def expand_path(p: None, expand_vars: bool = ...) -> None:
...


@overload
Expand Down
Loading
Toggle all file notes Toggle all file annotations