◐ 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: 5 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -47,6 +47,11 @@ jobs:
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 --ignore=W293,E265,E266,W503,W504,E731 --count --show-source --statistics
- name: Test with nose
run: |
set -x
7 changes: 4 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
include VERSION
include LICENSE
include CHANGES
include AUTHORS
include CONTRIBUTING.md
include README.md
include requirements.txt

recursive-include doc *
recursive-exclude test *
Expand Down
30 changes: 28 additions & 2 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@

# typing --------------------------------------------------------------------

from typing import IO, Any, AnyStr, Dict, Optional, Type, Union
from git.types import TBD

# ---------------------------------------------------------------------------
@@ -30,6 +39,12 @@
defenc = sys.getfilesystemencoding()


def safe_decode(s: Union[IO[str], AnyStr, None]) -> Optional[str]:
"""Safely decodes a binary string to unicode"""
if isinstance(s, str):
Expand All @@ -42,6 +57,12 @@ def safe_decode(s: Union[IO[str], AnyStr, None]) -> Optional[str]:
raise TypeError('Expected bytes or text, but got %r' % (s,))


def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
"""Safely encodes a binary string to unicode"""
if isinstance(s, str):
Expand All @@ -54,6 +75,12 @@ def safe_encode(s: Optional[AnyStr]) -> Optional[bytes]:
raise TypeError('Expected bytes or text, but got %r' % (s,))


def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
"""Encode unicodes for process arguments on Windows."""
if isinstance(s, str):
Expand All @@ -65,7 +92,6 @@ def win_encode(s: Optional[AnyStr]) -> Optional[bytes]:
return None



def with_metaclass(meta: Type[Any], *bases: Any) -> 'metaclass': # type: ignore ## mypy cannot understand dynamic class creation
"""copied from https://github.com/Byron/bcore/blob/master/src/python/butility/future.py#L15"""

Expand Down
2 changes: 1 addition & 1 deletion git/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def get_config_path(config_level: Literal['system', 'global', 'user', 'repositor
raise ValueError("Invalid configuration level: %r" % config_level)


class GitConfigParser(with_metaclass(MetaParserBuilder, cp.RawConfigParser, object)):

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

Expand Down
1 change: 1 addition & 0 deletions git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
""" Module containing all exceptions thrown throughout the git package, """

from gitdb.exc import * # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614
from git.compat import safe_decode

Expand Down
4 changes: 2 additions & 2 deletions git/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from .tree import *
# Fix import dependency - add IndexObject to the util module, so that it can be
# imported by the submodule.base
smutil.IndexObject = IndexObject
smutil.Object = Object
del(smutil)

# must come after submodule was made available
Expand Down
3 changes: 2 additions & 1 deletion git/objects/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import gitdb.typ as dbtyp
import os.path as osp

from .util import get_object_type_by_name

Expand All @@ -24,7 +25,7 @@ class Object(LazyMixin):

TYPES = (dbtyp.str_blob_type, dbtyp.str_tree_type, dbtyp.str_commit_type, dbtyp.str_tag_type)
__slots__ = ("repo", "binsha", "size")
type = None # to be set by subclass

def __init__(self, repo, binsha):
"""Initialize an object by identifying it by its binary sha.
Expand Down
4 changes: 2 additions & 2 deletions git/refs/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def iter_items(cls, repo, common_path=None):

#{ Remote Interface

@property
@require_remote_ref_path
def remote_name(self):
"""
Expand All @@ -114,7 +114,7 @@ def remote_name(self):
# /refs/remotes/<remote name>/<branch_name>
return tokens[2]

@property
@require_remote_ref_path
def remote_head(self):
""":return: Name of the remote head itself, i.e. master.
Expand Down
7 changes: 6 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

[mypy]

disallow_untyped_defs = True
Toggle all file notes Toggle all file annotations