◐ 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
5 changes: 3 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ statistics = True
# W293 = Blank line contains whitespace
# W504 = Line break after operator
# E704 = multiple statements in one line - used for @override
# TC002 =
# ANN = flake8-annotations
# TC, TC2 = flake8-type-checking
# D = flake8-docstrings
Expand All @@ -19,7 +19,8 @@ enable-extensions = TC, TC2 # only needed for extensions not enabled by default
ignore = E265,E266,E731,E704,
W293, W504,
ANN0 ANN1 ANN2,
TC0, TC1, TC2
# B,
A,
D,
Expand Down
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,21 @@ On *Windows*, make sure you have `git-daemon` in your PATH. For MINGW-git, the
exists in `Git\mingw64\libexec\git-core\`; CYGWIN has no daemon, but should get along fine
with MINGW's.

Ensure testing libraries are installed. In the root directory, run: `pip install test-requirements.txt`
Then,

To lint, run `flake8`
To typecheck, run `mypy -p git`
To test, `pytest`

Configuration for flake8 is in root/.flake8 file.
Configuration for mypy, pytest, coverage is in root/pyproject.toml.

The same linting and testing will also be performed against different supported python versions
upon submitting a pull request (or on each push if you have a fork with a "main" branch).



### Contributions
Expand Down
2 changes: 1 addition & 1 deletion git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# ---------------------------------------------------------------------------


is_win = (os.name == 'nt') # type: bool
is_posix = (os.name == 'posix')
is_darwin = (os.name == 'darwin')
defenc = sys.getfilesystemencoding()
Expand Down
20 changes: 11 additions & 9 deletions git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def get(self, key: str, default: Union[Any, None] = None) -> Union[Any, None]:
def getall(self, key: str) -> Any:
return super(_OMD, self).__getitem__(key)

def items(self) -> List[Tuple[str, Any]]: # type: ignore ## mypy doesn't like overwriting supertype signitures
"""List of (key, last value for key)."""
return [(k, self[k]) for k in self]

Expand Down Expand Up @@ -238,7 +238,7 @@ def get_config_path(config_level: Lit_config_levels) -> str:
assert_never(config_level, ValueError(f"Invalid configuration level: {config_level!r}"))


class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, object)): # type: ignore ## mypy does not understand dynamic class creation # noqa: E501

"""Implements specifics required to read git style configuration files.

Expand Down Expand Up @@ -322,7 +322,7 @@ def __init__(self, file_or_files: Union[None, PathLike, 'BytesIO', Sequence[Unio
self._is_initialized = False
self._merge_includes = merge_includes
self._repo = repo
self._lock = None # type: Union['LockFile', None]
self._acquire_lock()

def _acquire_lock(self) -> None:
Expand Down @@ -545,13 +545,15 @@ def read(self) -> None:
return None
self._is_initialized = True

files_to_read = [""] # type: List[Union[PathLike, IO]] ## just for types until 3.5 dropped
if isinstance(self._file_or_files, (str)): # replace with PathLike once 3.5 dropped
files_to_read = [self._file_or_files] # for str, as str is a type of Sequence
elif not isinstance(self._file_or_files, (tuple, list, Sequence)):
files_to_read = [self._file_or_files] # for IO or Path
else:
files_to_read = list(self._file_or_files) # for lists or tuples
# end assure we have a copy of the paths to handle

seen = set(files_to_read)
Expand Down
2 changes: 1 addition & 1 deletion git/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

if TYPE_CHECKING:
from git.cmd import Git

# --------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def diff(self, other: Union[Type['Index'], 'Tree', 'Commit', None, str, object]
paths = [paths]

if hasattr(self, 'Has_Repo'):
self.repo: Repo = self.repo

diff_cmd = self.repo.git.diff
if other is self.Index:
Expand Down Expand Up @@ -351,13 +351,13 @@ def __hash__(self) -> int:
return hash(tuple(getattr(self, n) for n in self.__slots__))

def __str__(self) -> str:
h = "%s" # type: str
if self.a_blob:
h %= self.a_blob.path
elif self.b_blob:
h %= self.b_blob.path

msg = '' # type: str
line = None # temp line
line_length = 0 # line length
for b, n in zip((self.a_blob, self.b_blob), ('lhs', 'rhs')):
Expand Down Expand Up @@ -449,7 +449,7 @@ def _index_from_patch_format(cls, repo: 'Repo', proc: TBD) -> DiffIndex:
:return: git.DiffIndex """

## FIXME: Here SLURPING raw, need to re-phrase header-regexes linewise.
text_list = [] # type: List[bytes]
handle_process_output(proc, text_list.append, None, finalize_process, decode_streams=False)

# for now, we have to bake the stream
Expand Down
2 changes: 0 additions & 2 deletions git/index/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Initialize the index package"""
# flake8: noqa
from __future__ import absolute_import

from .base import *
from .typ import *
Loading
Toggle all file notes Toggle all file annotations