Skip to content

Commit 5ceb724

Browse files
committed
add noqa across the repository (by running ruff check . --add-noqa)
1 parent a93d488 commit 5ceb724

Some content is hidden

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

70 files changed

+438
-438
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# add these directories to sys.path here. If the directory is relative to the
1414
# documentation root, use os.path.abspath to make it absolute, like shown here.
1515
#
16-
sys.path.insert(0, os.path.abspath('..'))
16+
sys.path.insert(0, os.path.abspath('..')) # noqa: PTH100
1717

1818

1919
# -- Project information -----------------------------------------------------

pygit2/__init__.py

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

2626
# Standard Library
27-
import functools
27+
import functools # noqa: I001
2828
from os import PathLike
2929
import typing
3030

3131
# Low level API
32-
from ._pygit2 import *
32+
from ._pygit2 import * # noqa: F403
3333
from ._pygit2 import _cache_enums
3434

3535
# High level API
3636
from . import enums
37-
from ._build import __version__
38-
from .blame import Blame, BlameHunk
39-
from .blob import BlobIO
40-
from .callbacks import Payload, RemoteCallbacks, CheckoutCallbacks, StashApplyCallbacks
41-
from .callbacks import git_clone_options, git_fetch_options, get_credentials
42-
from .config import Config
43-
from .credentials import *
44-
from .errors import check_error, Passthrough
37+
from ._build import __version__ # noqa: F401
38+
from .blame import Blame, BlameHunk # noqa: F401
39+
from .blob import BlobIO # noqa: F401
40+
from .callbacks import Payload, RemoteCallbacks, CheckoutCallbacks, StashApplyCallbacks # noqa: F401
41+
from .callbacks import git_clone_options, git_fetch_options, get_credentials # noqa: F401
42+
from .config import Config # noqa: F401
43+
from .credentials import * # noqa: F403
44+
from .errors import check_error, Passthrough # noqa: F401
4545
from .ffi import ffi, C
46-
from .filter import Filter
47-
from .index import Index, IndexEntry
48-
from .legacyenums import *
49-
from .packbuilder import PackBuilder
50-
from .remotes import Remote
46+
from .filter import Filter # noqa: F401
47+
from .index import Index, IndexEntry # noqa: F401
48+
from .legacyenums import * # noqa: F403
49+
from .packbuilder import PackBuilder # noqa: F401
50+
from .remotes import Remote # noqa: F401
5151
from .repository import Repository
5252
from .settings import Settings
53-
from .submodules import Submodule
53+
from .submodules import Submodule # noqa: F401
5454
from .utils import to_bytes, to_str
5555

5656

5757
# Features
5858
features = enums.Feature(C.git_libgit2_features())
5959

6060
# libgit version tuple
61-
LIBGIT2_VER = (LIBGIT2_VER_MAJOR, LIBGIT2_VER_MINOR, LIBGIT2_VER_REVISION)
61+
LIBGIT2_VER = (LIBGIT2_VER_MAJOR, LIBGIT2_VER_MINOR, LIBGIT2_VER_REVISION) # noqa: F405
6262

6363
# Let _pygit2 cache references to Python enum types.
6464
# This is separate from PyInit__pygit2() to avoid a circular import.
6565
_cache_enums()
6666

6767

68-
def init_repository(
68+
def init_repository( # noqa: PLR0913
6969
path: typing.Union[str, bytes, PathLike, None],
7070
bare: bool = False,
7171
flags: enums.RepositoryInitFlag = enums.RepositoryInitFlag.MKPATH,
@@ -143,7 +143,7 @@ def init_repository(
143143
return Repository(to_str(path))
144144

145145

146-
def clone_repository(
146+
def clone_repository( # noqa: PLR0913
147147
url,
148148
path,
149149
bare=False,
@@ -220,6 +220,6 @@ def clone_repository(
220220
return Repository._from_c(crepo[0], owned=True)
221221

222222

223-
tree_entry_key = functools.cmp_to_key(tree_entry_cmp)
223+
tree_entry_key = functools.cmp_to_key(tree_entry_cmp) # noqa: F405
224224

225225
settings = Settings()

pygit2/_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def _get_libgit2_path():
4848

4949
# Default
5050
if os.name == 'nt':
51-
return Path(r'%s\libgit2' % os.getenv('ProgramFiles'))
51+
return Path(r'%s\libgit2' % os.getenv('ProgramFiles')) # noqa: SIM112
5252
return Path('/usr/local')
5353

5454

pygit2/_pygit2.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Iterator, Literal, Optional, overload
1+
from typing import Iterator, Literal, Optional, overload # noqa: I001
22
from io import IOBase
33
from . import Index
44
from .enums import (
@@ -42,7 +42,7 @@ class Object:
4242
oid: Oid
4343
raw_name: bytes | None
4444
short_id: str
45-
type: 'Literal[GIT_OBJ_COMMIT] | Literal[GIT_OBJ_TREE] | Literal[GIT_OBJ_TAG] | Literal[GIT_OBJ_BLOB]'
45+
type: 'Literal[GIT_OBJ_COMMIT] | Literal[GIT_OBJ_TREE] | Literal[GIT_OBJ_TAG] | Literal[GIT_OBJ_BLOB]' # noqa: E501
4646
type_str: "Literal['commit'] | Literal['tree'] | Literal['tag'] | Literal['blob']"
4747
@overload
4848
def peel(self, target_type: 'Literal[GIT_OBJ_COMMIT]') -> 'Commit': ...

pygit2/_run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"""
2929

3030
# Import from the Standard Library
31-
import codecs
31+
import codecs # noqa: I001
3232
from pathlib import Path
3333
import sys
3434

@@ -85,7 +85,7 @@
8585
]
8686
h_source = []
8787
for h_file in h_files:
88-
h_file = dir_path / 'decl' / h_file
88+
h_file = dir_path / 'decl' / h_file # noqa: PLW2901
8989
with codecs.open(h_file, 'r', 'utf-8') as f:
9090
h_source.append(f.read())
9191

pygit2/blame.py

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

2626
# Import from pygit2
27-
from .ffi import ffi, C
27+
from .ffi import ffi, C # noqa: I001
2828
from .utils import GenericIterator
2929
from ._pygit2 import Signature, Oid
3030

pygit2/blob.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io
1+
import io # noqa: I001
22
import threading
33
import time
44
from contextlib import AbstractContextManager

pygit2/branches.py

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

26-
from __future__ import annotations
26+
from __future__ import annotations # noqa: I001
2727
from typing import TYPE_CHECKING
2828

2929
from .enums import BranchType, ReferenceType

pygit2/callbacks.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"""
6464

6565
# Standard Library
66-
from contextlib import contextmanager
66+
from contextlib import contextmanager # noqa: I001
6767
from functools import wraps
6868
from typing import Optional, Union
6969

@@ -133,9 +133,9 @@ def sideband_progress(self, string: str) -> None:
133133

134134
def credentials(
135135
self,
136-
url: str,
137-
username_from_url: Union[str, None],
138-
allowed_types: CredentialType,
136+
url: str, # noqa: ARG002
137+
username_from_url: Union[str, None], # noqa: ARG002
138+
allowed_types: CredentialType, # noqa: ARG002
139139
):
140140
"""
141141
Credentials callback. If the remote server requires authentication,
@@ -159,7 +159,7 @@ def credentials(
159159
"""
160160
raise Passthrough
161161

162-
def certificate_check(self, certificate: None, valid: bool, host: str) -> bool:
162+
def certificate_check(self, certificate: None, valid: bool, host: str) -> bool: # noqa: ARG002
163163
"""
164164
Certificate callback. Override with your own function to determine
165165
whether to accept the server's certificate.
@@ -493,7 +493,7 @@ def _certificate_check_cb(cert_i, valid, host, data):
493493
if not val:
494494
return C.GIT_ECERTIFICATE
495495
except Passthrough:
496-
if is_ssh:
496+
if is_ssh: # noqa: SIM114
497497
return 0
498498
elif valid:
499499
return 0
@@ -667,15 +667,15 @@ def get_credentials(fn, url, username, allowed):
667667

668668

669669
@libgit2_callback
670-
def _checkout_notify_cb(
670+
def _checkout_notify_cb( # noqa: PLR0913
671671
why, path_cstr, baseline, target, workdir, data: CheckoutCallbacks
672672
):
673673
pypath = maybe_string(path_cstr)
674674
pybaseline = DiffFile.from_c(ptr_to_bytes(baseline))
675675
pytarget = DiffFile.from_c(ptr_to_bytes(target))
676676
pyworkdir = DiffFile.from_c(ptr_to_bytes(workdir))
677677

678-
try:
678+
try: # noqa: SIM105
679679
data.checkout_notify(why, pypath, pybaseline, pytarget, pyworkdir)
680680
except Passthrough:
681681
# Unlike most other operations with optional callbacks, checkout
@@ -701,7 +701,7 @@ def _git_checkout_options(
701701
paths=None,
702702
c_checkout_options_ptr=None,
703703
):
704-
if callbacks is None:
704+
if callbacks is None: # noqa: SIM108
705705
payload = CheckoutCallbacks()
706706
else:
707707
payload = callbacks
@@ -768,7 +768,7 @@ def git_checkout_options(callbacks=None, strategy=None, directory=None, paths=No
768768

769769
@libgit2_callback
770770
def _stash_apply_progress_cb(progress: StashApplyProgress, data: StashApplyCallbacks):
771-
try:
771+
try: # noqa: SIM105
772772
data.stash_apply_progress(progress)
773773
except Passthrough:
774774
# Unlike most other operations with optional callbacks, stash apply

pygit2/config.py

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

3131
# Import from pygit2
32-
from .errors import check_error
32+
from .errors import check_error # noqa: I001
3333
from .ffi import ffi, C
3434
from .utils import to_bytes
3535

@@ -93,7 +93,7 @@ def from_c(cls, repo, ptr):
9393
return config
9494

9595
def __del__(self):
96-
try:
96+
try: # noqa: SIM105
9797
C.git_config_free(self._config)
9898
except AttributeError:
9999
pass

0 commit comments

Comments
 (0)