Skip to content

Commit 484886a

Browse files
committed
Initial formatting and liniting fix of all files
1 parent 2c06530 commit 484886a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+391
-368
lines changed

build_tag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import platform, sys
1+
import platform
2+
import sys
23

34
py = {'CPython': 'cp', 'PyPy': 'pp'}[platform.python_implementation()]
45
print(f'{py}{sys.version_info.major}{sys.version_info.minor}')

pygit2/__init__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,31 @@
2525

2626
# Standard Library
2727
import functools
28-
from os import PathLike
2928
import typing
30-
31-
# Low level API
32-
from ._pygit2 import *
33-
from ._pygit2 import _cache_enums
29+
from os import PathLike
3430

3531
# High level API
3632
from . import enums
3733
from ._build import __version__
34+
35+
# Low level API
36+
from ._pygit2 import *
37+
from ._pygit2 import _cache_enums
3838
from .blame import Blame, BlameHunk
3939
from .blob import BlobIO
40-
from .callbacks import Payload, RemoteCallbacks, CheckoutCallbacks, StashApplyCallbacks
41-
from .callbacks import git_clone_options, git_fetch_options, get_credentials
40+
from .callbacks import (
41+
CheckoutCallbacks,
42+
Payload,
43+
RemoteCallbacks,
44+
StashApplyCallbacks,
45+
get_credentials,
46+
git_clone_options,
47+
git_fetch_options,
48+
)
4249
from .config import Config
4350
from .credentials import *
44-
from .errors import check_error, Passthrough
45-
from .ffi import ffi, C
51+
from .errors import Passthrough, check_error
52+
from .ffi import C, ffi
4653
from .filter import Filter
4754
from .index import Index, IndexEntry
4855
from .legacyenums import *
@@ -53,7 +60,6 @@
5360
from .submodules import Submodule
5461
from .utils import to_bytes, to_str
5562

56-
5763
# Features
5864
features = enums.Feature(C.git_libgit2_features())
5965

pygit2/_pygit2.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from typing import Iterator, Literal, Optional, overload
21
from io import IOBase
2+
from typing import Iterator, Literal, Optional, overload
3+
34
from . import Index
45
from .enums import (
56
ApplyLocation,

pygit2/_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
# Import from the Standard Library
3131
import codecs
32-
from pathlib import Path
3332
import sys
33+
from pathlib import Path
3434

3535
# Import from cffi
3636
from cffi import FFI

pygit2/blame.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
# Import from pygit2
27-
from .ffi import ffi, C
27+
from ._pygit2 import Oid, Signature
28+
from .ffi import C, ffi
2829
from .utils import GenericIterator
29-
from ._pygit2 import Signature, Oid
3030

3131

3232
def wrap_signature(csig):

pygit2/blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import threading
33
import time
44
from contextlib import AbstractContextManager
5-
from typing import Optional
65
from queue import Queue
6+
from typing import Optional
77

88
from ._pygit2 import Blob, Oid
99
from .enums import BlobFilter

pygit2/branches.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
from __future__ import annotations
27+
2728
from typing import TYPE_CHECKING
2829

29-
from .enums import BranchType, ReferenceType
3030
from ._pygit2 import Commit, Oid
31+
from .enums import BranchType, ReferenceType
3132

3233
# Need BaseRepository for type hints, but don't let it cause a circular dependency
3334
if TYPE_CHECKING:

pygit2/callbacks.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@
6868
from typing import Optional, Union
6969

7070
# pygit2
71-
from ._pygit2 import Oid, DiffFile
71+
from ._pygit2 import DiffFile, Oid
7272
from .enums import CheckoutNotify, CheckoutStrategy, CredentialType, StashApplyProgress
73-
from .errors import check_error, Passthrough
74-
from .ffi import ffi, C
75-
from .utils import maybe_string, to_bytes, ptr_to_bytes, StrArray
76-
73+
from .errors import Passthrough, check_error
74+
from .ffi import C, ffi
75+
from .utils import StrArray, maybe_string, ptr_to_bytes, to_bytes
7776

7877
#
7978
# The payload is the way to pass information from the pygit2 API, through
@@ -471,9 +470,7 @@ def _certificate_check_cb(cert_i, valid, host, data):
471470
if not val:
472471
return C.GIT_ECERTIFICATE
473472
except Passthrough:
474-
if is_ssh:
475-
return 0
476-
elif valid:
473+
if is_ssh or valid:
477474
return 0
478475
else:
479476
return C.GIT_ECERTIFICATE
@@ -669,10 +666,7 @@ def _git_checkout_options(
669666
paths=None,
670667
c_checkout_options_ptr=None,
671668
):
672-
if callbacks is None:
673-
payload = CheckoutCallbacks()
674-
else:
675-
payload = callbacks
669+
payload = CheckoutCallbacks() if callbacks is None else callbacks
676670

677671
# Get handle to payload
678672
handle = ffi.new_handle(payload)

pygit2/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
from cached_property import cached_property
3030

3131
# Import from pygit2
32+
import contextlib
33+
3234
from .errors import check_error
33-
from .ffi import ffi, C
35+
from .ffi import C, ffi
3436
from .utils import to_bytes
3537

3638

@@ -96,10 +98,8 @@ def from_c(cls, repo, ptr):
9698
return config
9799

98100
def __del__(self):
99-
try:
101+
with contextlib.suppress(AttributeError):
100102
C.git_config_free(self._config)
101-
except AttributeError:
102-
pass
103103

104104
def _get(self, key):
105105
key = str_to_bytes(key, 'key')

pygit2/credentials.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26-
from .ffi import C
27-
2826
from .enums import CredentialType
27+
from .ffi import C
2928

3029

3130
class Username:

0 commit comments

Comments
 (0)