Skip to content

Commit 12c575e

Browse files
committed
ruff check
1 parent 8810e4c commit 12c575e

11 files changed

+24
-31
lines changed

build_tag.py

+2-1
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}')

docs/conf.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# list see the documentation:
55
# http://www.sphinx-doc.org/en/master/config
66

7-
import os, sys
7+
import os
8+
import sys
89

910
# -- Path setup --------------------------------------------------------------
1011

pygit2/credentials.py

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
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
2927

3028

pygit2/utils.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ class StrArray:
113113
contents of 'struct' only remain valid within the StrArray context.
114114
"""
115115

116-
def __init__(self, l):
116+
def __init__(self, lst):
117117
# Allow passing in None as lg2 typically considers them the same as empty
118-
if l is None:
118+
if lst is None:
119119
self.__array = ffi.NULL
120120
return
121121

122-
if not isinstance(l, (list, tuple)):
122+
if not isinstance(lst, (list, tuple)):
123123
raise TypeError('Value must be a list')
124124

125-
strings = [None] * len(l)
126-
for i in range(len(l)):
127-
li = l[i]
125+
strings = [None] * len(lst)
126+
for i in range(len(lst)):
127+
li = lst[i]
128128
if not isinstance(li, str) and not hasattr(li, '__fspath__'):
129129
raise TypeError('Value must be a string or PathLike object')
130130

pyproject.toml

+1-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,8 @@ environment = {LIBGIT2_VERSION="1.9.0", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSIO
2525
repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
2626

2727
[tool.ruff]
28+
extend-exclude = [ ".cache", ".coverage", "build", "site-packages", "venv*"]
2829
target-version = "py310" # oldest supported Python version
29-
fix = true
30-
extend-exclude = [
31-
".cache",
32-
".coverage",
33-
"build",
34-
"venv*",
35-
]
3630

3731
[tool.ruff.format]
3832
quote-style = "single"

test/test_diff.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def get_context_for_lines(diff):
220220

221221
def test_diff_revparse(barerepo):
222222
diff = barerepo.diff('HEAD', 'HEAD~6')
223-
assert type(diff) == pygit2.Diff
223+
assert type(diff) is pygit2.Diff
224224

225225

226226
def test_diff_tree_opts(barerepo):

test/test_object.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_peel_commit(testrepo):
8888
# and peel to the tree
8989
tree = commit.peel(ObjectType.TREE)
9090

91-
assert type(tree) == Tree
91+
assert type(tree) is Tree
9292
assert tree.id == 'fd937514cb799514d4b81bb24c5fcfeb6472b245'
9393

9494

@@ -97,7 +97,7 @@ def test_peel_commit_type(testrepo):
9797
commit = testrepo[commit_id]
9898
tree = commit.peel(Tree)
9999

100-
assert type(tree) == Tree
100+
assert type(tree) is Tree
101101
assert tree.id == 'fd937514cb799514d4b81bb24c5fcfeb6472b245'
102102

103103

test/test_odb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ def test_write(odb):
9191
odb.write(ObjectType.ANY, data)
9292

9393
oid = odb.write(ObjectType.BLOB, data)
94-
assert type(oid) == Oid
94+
assert type(oid) is Oid

test/test_remote.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
2424
# Boston, MA 02110-1301, USA.
2525

26-
from unittest.mock import patch
2726
import sys
2827

2928
import pytest
@@ -50,7 +49,7 @@ def test_remote_create(testrepo):
5049

5150
remote = testrepo.remotes.create(name, url)
5251

53-
assert type(remote) == pygit2.Remote
52+
assert type(remote) is pygit2.Remote
5453
assert name == remote.name
5554
assert url == remote.url
5655
assert remote.push_url is None
@@ -66,7 +65,7 @@ def test_remote_create_with_refspec(testrepo):
6665

6766
remote = testrepo.remotes.create(name, url, fetch)
6867

69-
assert type(remote) == pygit2.Remote
68+
assert type(remote) is pygit2.Remote
7069
assert name == remote.name
7170
assert url == remote.url
7271
assert [fetch] == remote.fetch_refspecs
@@ -140,7 +139,7 @@ def test_refspec(testrepo):
140139
assert refspec.force is True
141140
assert ORIGIN_REFSPEC == refspec.string
142141

143-
assert list == type(remote.fetch_refspecs)
142+
assert list is type(remote.fetch_refspecs)
144143
assert 1 == len(remote.fetch_refspecs)
145144
assert ORIGIN_REFSPEC == remote.fetch_refspecs[0]
146145

@@ -149,18 +148,18 @@ def test_refspec(testrepo):
149148
assert 'refs/remotes/origin/master' == refspec.transform('refs/heads/master')
150149
assert 'refs/heads/master' == refspec.rtransform('refs/remotes/origin/master')
151150

152-
assert list == type(remote.push_refspecs)
151+
assert list is type(remote.push_refspecs)
153152
assert 0 == len(remote.push_refspecs)
154153

155154
push_specs = remote.push_refspecs
156-
assert list == type(push_specs)
155+
assert list is type(push_specs)
157156
assert 0 == len(push_specs)
158157

159158
testrepo.remotes.add_fetch('origin', '+refs/test/*:refs/test/remotes/*')
160159
remote = testrepo.remotes['origin']
161160

162161
fetch_specs = remote.fetch_refspecs
163-
assert list == type(fetch_specs)
162+
assert list is type(fetch_specs)
164163
assert 2 == len(fetch_specs)
165164
assert [
166165
'+refs/heads/*:refs/remotes/origin/*',

test/test_repository.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def test_new_repo(tmp_path):
596596
repo = init_repository(tmp_path, False)
597597

598598
oid = repo.write(ObjectType.BLOB, 'Test')
599-
assert type(oid) == Oid
599+
assert type(oid) is Oid
600600

601601
assert (tmp_path / '.git').exists()
602602

test/test_repository_bare.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_is_bare(barerepo):
5454
def test_head(barerepo):
5555
head = barerepo.head
5656
assert HEAD_SHA == head.target
57-
assert type(head) == pygit2.Reference
57+
assert type(head) is pygit2.Reference
5858
assert not barerepo.head_is_unborn
5959
assert not barerepo.head_is_detached
6060

@@ -94,7 +94,7 @@ def test_write(barerepo):
9494
barerepo.write(ObjectType.ANY, data)
9595

9696
oid = barerepo.write(ObjectType.BLOB, data)
97-
assert type(oid) == pygit2.Oid
97+
assert type(oid) is pygit2.Oid
9898

9999

100100
def test_contains(barerepo):

0 commit comments

Comments
 (0)