Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

lint: switch Black withruff-format#1865

New issue

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

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 3 commits intogitpython-developers:mainfromBorda:ruff/black
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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: 0 additions & 2 deletions.github/workflows/lint.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
View file
Open in desktop
Original file line numberDiff line numberDiff 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-format
exclude: ^git/ext/
- id: ruff
args: ["--fix"]
exclude: ^doc|^git/ext/
Expand Down
5 changes: 1 addition & 4 deletionsMakefile
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
.PHONY: alllintclean release force_release
.PHONY: all clean release force_release

all:
@awk -F: '/^[[:alpha:]].*:/ && !/^all:/ {print $$1}' Makefile

lint:
SKIP=black-format pre-commit run --all-files --hook-stage manual

clean:
rm -rf build/ dist/ .eggs/ .tox/

Expand Down
3 changes: 0 additions & 3 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff 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
72 changes: 29 additions & 43 deletionsgit/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -495,9 +495,8 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
if mode in quiet:
pass
elif mode in warn or mode in error:
err = (
dedent(
"""\
err = dedent(
"""\
%s
All git commands will error until this is rectified.

Expand All@@ -510,40 +509,35 @@ def refresh(cls, path: Union[None, PathLike] = None) -> bool:
Example:
export %s=%s
"""
)
% (
err,
cls._refresh_env_var,
"|".join(quiet),
"|".join(warn),
"|".join(error),
cls._refresh_env_var,
quiet[0],
)
) % (
err,
cls._refresh_env_var,
"|".join(quiet),
"|".join(warn),
"|".join(error),
cls._refresh_env_var,
quiet[0],
)

if mode in warn:
_logger.critical(err)
else:
raise ImportError(err)
else:
err = (
dedent(
"""\
err = dedent(
"""\
%s environment variable has been set but it has been set with an invalid value.

Use only the following values:
- %s: for no message or exception
- %s: for a warning message (logging level CRITICAL, displayed by default)
- %s: for a raised exception
"""
)
% (
cls._refresh_env_var,
"|".join(quiet),
"|".join(warn),
"|".join(error),
)
) % (
cls._refresh_env_var,
"|".join(quiet),
"|".join(warn),
"|".join(error),
)
raise ImportError(err)

Expand All@@ -565,13 +559,11 @@ def is_cygwin(cls) -> bool:

@overload
@classmethod
def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str:
...
def polish_url(cls, url: str, is_cygwin: Literal[False] = ...) -> str: ...

@overload
@classmethod
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str:
...
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> str: ...

@classmethod
def polish_url(cls, url: str, is_cygwin: Union[None, bool] = None) -> PathLike:
Expand DownExpand Up@@ -932,8 +924,7 @@ def execute(
command: Union[str, Sequence[Any]],
*,
as_process: Literal[True],
) -> "AutoInterrupt":
...
) -> "AutoInterrupt": ...

@overload
def execute(
Expand All@@ -942,8 +933,7 @@ def execute(
*,
as_process: Literal[False] = False,
stdout_as_string: Literal[True],
) -> Union[str, Tuple[int, str, str]]:
...
) -> Union[str, Tuple[int, str, str]]: ...

@overload
def execute(
Expand All@@ -952,8 +942,7 @@ def execute(
*,
as_process: Literal[False] = False,
stdout_as_string: Literal[False] = False,
) -> Union[bytes, Tuple[int, bytes, str]]:
...
) -> Union[bytes, Tuple[int, bytes, str]]: ...

@overload
def execute(
Expand All@@ -963,8 +952,7 @@ def execute(
with_extended_output: Literal[False],
as_process: Literal[False],
stdout_as_string: Literal[True],
) -> str:
...
) -> str: ...

@overload
def execute(
Expand All@@ -974,8 +962,7 @@ def execute(
with_extended_output: Literal[False],
as_process: Literal[False],
stdout_as_string: Literal[False],
) -> bytes:
...
) -> bytes: ...

def execute(
self,
Expand DownExpand Up@@ -1387,8 +1374,9 @@ def __call__(self, **kwargs: Any) -> "Git":
return self

@overload
def _call_process(self, method: str, *args: None, **kwargs: None) -> str:
... # If no args were given, execute the call with all defaults.
def _call_process(
self, method: str, *args: None, **kwargs: None
) -> str: ... # If no args were given, execute the call with all defaults.

@overload
def _call_process(
Expand All@@ -1398,14 +1386,12 @@ def _call_process(
as_process: Literal[True],
*args: Any,
**kwargs: Any,
) -> "Git.AutoInterrupt":
...
) -> "Git.AutoInterrupt": ...

@overload
def _call_process(
self, method: str, *args: Any, **kwargs: Any
) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]:
...
) -> Union[str, bytes, Tuple[int, Union[str, bytes], str], "Git.AutoInterrupt"]: ...

def _call_process(
self, method: str, *args: Any, **kwargs: Any
Expand Down
18 changes: 6 additions & 12 deletionsgit/compat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -69,13 +69,11 @@


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


@overload
def safe_decode(s: AnyStr) -> str:
...
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:
...
def safe_encode(s: None) -> None: ...


@overload
def safe_encode(s: AnyStr) -> bytes:
...
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:
...
def win_encode(s: None) -> None: ...


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


def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
Expand Down
6 changes: 3 additions & 3 deletionsgit/index/fun.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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)
assertlen(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 deletionsgit/objects/fun.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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:
...
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: EntryTup, path_prefix: str) -> EntryTup: ...


def _to_full_path(item: EntryTupOrNone, path_prefix: str) -> EntryTupOrNone:
Expand Down
2 changes: 1 addition & 1 deletiongit/objects/tree.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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
symlink_id: Blob,
# Tree ID added once Tree is defined.
}

Expand Down
12 changes: 4 additions & 8 deletionsgit/objects/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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]:
...
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]:
...
) -> 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]]:
...
) -> 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]]:
...
) -> Iterator[Tuple[T_TIobj, T_TIobj]]: ...

def traverse(
self: T_TIobj,
Expand Down
11 changes: 4 additions & 7 deletionsgit/remote.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,22 +93,19 @@ def add_progress(


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


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


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


def to_progress_instance(
progress: Union[Callable[..., Any], RemoteProgress, None]
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 deletionsgit/util.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -441,13 +441,11 @@ def decygpath(path: PathLike) -> str:


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


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


def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool:
Expand DownExpand 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:
...
def expand_path(p: None, expand_vars: bool = ...) -> None: ...


@overload
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp