◐ 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
26 changes: 0 additions & 26 deletions .flake8
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ repos:
name: black (format)
exclude: ^git/ext/

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
- flake8-bugbear==23.9.16
- flake8-comprehensions==3.14.0
- flake8-typing-imports==1.14.0
exclude: ^doc|^git/ext/

- repo: https://github.com/shellcheck-py/shellcheck-py
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ The same linting, and running tests on all the different supported Python versio
Specific tools:

- Configurations for `mypy`, `pytest`, `coverage.py`, and `black` are in `./pyproject.toml`.
- Configuration for `flake8` is in the `./.flake8` file.

Orchestration tools:

Expand Down
8 changes: 4 additions & 4 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def write(
# Make sure we have our entries read before getting a write lock.
# Otherwise it would be done when streaming.
# This can happen if one doesn't change the index, but writes it right away.
self.entries
lfd = LockedFD(file_path or self._file_path)
stream = lfd.open(write=True, stream=True)

Expand Up @@ -397,7 +397,7 @@ def from_tree(cls, repo: "Repo", *treeish: Treeish, **kwargs: Any) -> "IndexFile
with TemporaryFileSwap(join_path_native(repo.git_dir, "index")):
repo.git.read_tree(*arg_list, **kwargs)
index = cls(repo, tmp_index)
index.entries # Force it to read the file as we will delete the temp-file.
return index
# END index merge handling

Expand Down Expand Up @@ -1339,7 +1339,7 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik
# Make sure we have our entries loaded before we start checkout_index, which
# will hold a lock on it. We try to get the lock as well during our entries
# initialization.
self.entries

args.append("--stdin")
kwargs["as_process"] = True
Expand Down @@ -1379,7 +1379,7 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik
self._flush_stdin_and_wait(proc, ignore_stdout=True)
except GitCommandError:
# Without parsing stdout we don't know what failed.
raise CheckoutError(
"Some files could not be checked out from the index, probably because they didn't exist.",
failed_files,
[],
Expand Down
6 changes: 5 additions & 1 deletion git/objects/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
from mimetypes import guess_type
from . import base

from git.types import Literal

__all__ = ("Blob",)

Expand Down
7 changes: 6 additions & 1 deletion git/objects/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
Dict,
)

from git.types import PathLike, Literal

if TYPE_CHECKING:
from git.repo import Repo
Expand Down
9 changes: 7 additions & 2 deletions git/objects/submodule/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast
from typing import Any, Iterator, Union

from git.types import Commit_ish, Literal, PathLike, TBD

if TYPE_CHECKING:
from git.index import IndexFile
Expand Down Expand Up @@ -1445,7 +1450,7 @@ def exists(self) -> bool:

try:
try:
self.path
return True
except Exception:
return False
Expand Down
5 changes: 4 additions & 1 deletion git/objects/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

from typing import List, TYPE_CHECKING, Union

from git.types import Literal

if TYPE_CHECKING:
from git.repo import Repo
Expand Down
7 changes: 6 additions & 1 deletion git/objects/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
TYPE_CHECKING,
)

from git.types import PathLike, Literal

if TYPE_CHECKING:
from git.repo import Repo
Expand Down
2 changes: 1 addition & 1 deletion git/objects/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def _list_traverse(

if not as_edge:
out: IterableList[Union["Commit", "Submodule", "Tree", "Blob"]] = IterableList(id)
out.extend(self.traverse(as_edge=as_edge, *args, **kwargs))
return out
# Overloads in subclasses (mypy doesn't allow typing self: subclass).
# Union[IterableList['Commit'], IterableList['Submodule'], IterableList[Union['Submodule', 'Tree', 'Blob']]]
Expand Down
4 changes: 2 additions & 2 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def is_valid(self) -> bool:
valid object or reference.
"""
try:
self.object
except (OSError, ValueError):
return False
else:
Expand All @@ -510,7 +510,7 @@ def is_detached(self) -> bool:
instead to another reference.
"""
try:
self.ref
return False
except TypeError:
return True
Expand Down
36 changes: 35 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ warn_unreachable = true
show_error_codes = true
implicit_reexport = true
# strict = true

# TODO: Remove when 'gitdb' is fully annotated.
exclude = ["^git/ext/gitdb"]
[[tool.mypy.overrides]]
Expand All @@ -47,3 +46,38 @@ omit = ["*/git/ext/*"]
line-length = 120
target-version = ["py37"]
extend-exclude = "git/ext/gitdb"
2 changes: 0 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@

# libraries for additional local testing/linting - to be added to test-requirements.txt when all pass

flake8-type-checking;python_version>="3.8" # checks for TYPE_CHECKING only imports

pytest-icdiff
# pytest-profiling
Toggle all file notes Toggle all file annotations