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

+1-1
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

+20-20
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

+1-1
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

+2-2
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

+2-2
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

+1-1
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

+1-1
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

+1-1
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

+10-10
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

+2-2
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

pygit2/credentials.py

+1-1
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

2828
from typing import TYPE_CHECKING
2929

pygit2/enums.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class BlameFlag(IntFlag):
7777
'Not yet implemented and reserved for future use (as of libgit2 1.9.0).'
7878

7979
FIRST_PARENT = _pygit2.GIT_BLAME_FIRST_PARENT
80-
'Restrict the search of commits to those reachable following only the first parents.'
80+
'Restrict the search of commits to those reachable following only the first parents.' # noqa: E501
8181

8282
USE_MAILMAP = _pygit2.GIT_BLAME_USE_MAILMAP
8383
"""
@@ -95,7 +95,7 @@ class BlobFilter(IntFlag):
9595
'Do not apply filters to binary files.'
9696

9797
NO_SYSTEM_ATTRIBUTES = _pygit2.GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES
98-
'Filters will not load configuration from the system-wide `gitattributes` in `/etc` (or system equivalent).'
98+
'Filters will not load configuration from the system-wide `gitattributes` in `/etc` (or system equivalent).' # noqa: E501
9999

100100
ATTRIBUTES_FROM_HEAD = _pygit2.GIT_BLOB_FILTER_ATTRIBUTES_FROM_HEAD
101101
'Load filters from a `.gitattributes` file in the HEAD commit.'
@@ -246,7 +246,7 @@ class ConfigLevel(IntEnum):
246246
'XDG compatible configuration file; typically ~/.config/git/config'
247247

248248
GLOBAL = _pygit2.GIT_CONFIG_LEVEL_GLOBAL
249-
'User-specific configuration file (also called Global configuration file); typically ~/.gitconfig'
249+
'User-specific configuration file (also called Global configuration file); typically ~/.gitconfig' # noqa: E501
250250

251251
LOCAL = _pygit2.GIT_CONFIG_LEVEL_LOCAL
252252
'Repository specific configuration file; $WORK_DIR/.git/config on non-bare repos'
@@ -642,7 +642,7 @@ class DiffStatsFormat(IntFlag):
642642
'Number statistics, equivalent of `--numstat`'
643643

644644
INCLUDE_SUMMARY = _pygit2.GIT_DIFF_STATS_INCLUDE_SUMMARY
645-
'Extended header information such as creations, renames and mode changes, equivalent of `--summary`'
645+
'Extended header information such as creations, renames and mode changes, equivalent of `--summary`' # noqa: E501
646646

647647

648648
class Feature(IntFlag):
@@ -726,7 +726,7 @@ class FilterFlag(IntFlag):
726726
'Load attributes from `.gitattributes` in the root of HEAD'
727727

728728
ATTRIBUTES_FROM_COMMIT = _pygit2.GIT_FILTER_ATTRIBUTES_FROM_COMMIT
729-
'Load attributes from `.gitattributes` in a given commit. This can only be specified in a `git_filter_options`.'
729+
'Load attributes from `.gitattributes` in a given commit. This can only be specified in a `git_filter_options`.' # noqa: E501
730730

731731

732732
class FilterMode(IntEnum):
@@ -947,7 +947,7 @@ class ObjectType(IntEnum):
947947
class Option(IntEnum):
948948
"""Global libgit2 library options"""
949949

950-
# Commented out values --> exists in libgit2 but not supported in pygit2's options.c yet
950+
# Commented out values --> exists in libgit2 but not supported in pygit2's options.c yet # noqa: E501
951951
GET_MWINDOW_SIZE = _pygit2.GIT_OPT_GET_MWINDOW_SIZE
952952
SET_MWINDOW_SIZE = _pygit2.GIT_OPT_SET_MWINDOW_SIZE
953953
GET_MWINDOW_MAPPED_LIMIT = _pygit2.GIT_OPT_GET_MWINDOW_MAPPED_LIMIT
@@ -1293,7 +1293,7 @@ class SubmoduleStatus(IntFlag):
12931293
'submodule workdir index is dirty (flag available if ignore is NONE or UNTRACKED)'
12941294

12951295
WD_WD_MODIFIED = _pygit2.GIT_SUBMODULE_STATUS_WD_WD_MODIFIED
1296-
'submodule workdir has modified files (flag available if ignore is NONE or UNTRACKED)'
1296+
'submodule workdir has modified files (flag available if ignore is NONE or UNTRACKED)' # noqa: E501
12971297

12981298
WD_UNTRACKED = _pygit2.GIT_SUBMODULE_STATUS_WD_UNTRACKED
12991299
'submodule workdir contains untracked files (flag available if ignore is NONE)'

pygit2/errors.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@
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 ._pygit2 import GitError
2929

3030

31-
value_errors = set([C.GIT_EEXISTS, C.GIT_EINVALIDSPEC, C.GIT_EAMBIGUOUS])
31+
value_errors = set([C.GIT_EEXISTS, C.GIT_EINVALIDSPEC, C.GIT_EAMBIGUOUS]) # noqa: C405
3232

3333

3434
def check_error(err, io=False):
3535
if err >= 0:
3636
return
3737

3838
# These are special error codes, they should never reach here
39-
test = err != C.GIT_EUSER and err != C.GIT_PASSTHROUGH
39+
test = err != C.GIT_EUSER and err != C.GIT_PASSTHROUGH # noqa: PLR1714
4040
assert test, f'Unexpected error code {err}'
4141

4242
# Error message

pygit2/ffi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
# Import from pygit2
27-
from ._libgit2 import ffi, lib as C
27+
from ._libgit2 import ffi, lib as C # noqa: I001, F401

pygit2/filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def check(self, src: FilterSource, attr_values: List[Optional[str]]):
7676
"""
7777

7878
def write(
79-
self, data: bytes, src: FilterSource, write_next: Callable[[bytes], None]
79+
self, data: bytes, src: FilterSource, write_next: Callable[[bytes], None] # noqa: ARG002
8080
):
8181
"""
8282
Write input `data` to this filter.

pygit2/index.py

+3-3
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-
import warnings
26+
import warnings # noqa: I001
2727
import weakref
2828

2929
# Import from pygit2
@@ -367,15 +367,15 @@ def oid(self):
367367
@property
368368
def hex(self):
369369
"""The id of the referenced object as a hex string"""
370-
warnings.warn('Use str(entry.id)', DeprecationWarning)
370+
warnings.warn('Use str(entry.id)', DeprecationWarning) # noqa: B028
371371
return str(self.id)
372372

373373
def __str__(self):
374374
return f'<path={self.path} id={self.id} mode={self.mode}>'
375375

376376
def __repr__(self):
377377
t = type(self)
378-
return f'<{t.__module__}.{t.__qualname__} path={self.path} id={self.id} mode={self.mode}>'
378+
return f'<{t.__module__}.{t.__qualname__} path={self.path} id={self.id} mode={self.mode}>' # noqa: E501
379379

380380
def __eq__(self, other):
381381
if self is other:

pygit2/packbuilder.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
# Import from pygit2
28-
from .errors import check_error
28+
from .errors import check_error # noqa: I001
2929
from .ffi import ffi, C
3030
from .utils import to_bytes
3131

0 commit comments

Comments
 (0)