Skip to content

Commit b28d940

Browse files
committed
Fix mypy strict equality
1 parent c921ebc commit b28d940

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ no_implicit_reexport = True
77
disallow_subclassing_any = True
88
disallow_untyped_decorators = True
99

10+
strict_equality = True
11+
1012
[mypy-test.*]
1113
disallow_untyped_defs = True
1214
disallow_untyped_calls = True

test/test_blob.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_read_blob(testrepo: Repository) -> None:
8787
assert blob.id == BLOB_SHA
8888
assert isinstance(blob, pygit2.Blob)
8989
assert not blob.is_binary
90-
assert ObjectType.BLOB == blob.type
90+
assert int(ObjectType.BLOB) == blob.type
9191
assert BLOB_CONTENT == blob.data
9292
assert len(BLOB_CONTENT) == blob.size
9393
assert BLOB_CONTENT == blob.read_raw()
@@ -98,7 +98,7 @@ def test_create_blob(testrepo: Repository) -> None:
9898
blob = testrepo[blob_oid]
9999

100100
assert isinstance(blob, pygit2.Blob)
101-
assert ObjectType.BLOB == blob.type
101+
assert int(ObjectType.BLOB) == blob.type
102102

103103
assert blob_oid == blob.id
104104
assert utils.gen_blob_sha1(BLOB_NEW_CONTENT) == blob_oid
@@ -122,7 +122,7 @@ def test_create_blob_fromworkdir(testrepo: Repository) -> None:
122122
blob = testrepo[blob_oid]
123123

124124
assert isinstance(blob, pygit2.Blob)
125-
assert ObjectType.BLOB == blob.type
125+
assert int(ObjectType.BLOB) == blob.type
126126

127127
assert blob_oid == blob.id
128128
assert utils.gen_blob_sha1(BLOB_FILE_CONTENT) == blob_oid
@@ -149,7 +149,7 @@ def test_create_blob_fromdisk(testrepo: Repository) -> None:
149149
blob = testrepo[blob_oid]
150150

151151
assert isinstance(blob, pygit2.Blob)
152-
assert ObjectType.BLOB == blob.type
152+
assert int(ObjectType.BLOB) == blob.type
153153

154154

155155
def test_create_blob_fromiobase(testrepo: Repository) -> None:
@@ -161,7 +161,7 @@ def test_create_blob_fromiobase(testrepo: Repository) -> None:
161161
blob = testrepo[blob_oid]
162162

163163
assert isinstance(blob, pygit2.Blob)
164-
assert ObjectType.BLOB == blob.type
164+
assert int(ObjectType.BLOB) == blob.type
165165

166166
assert blob_oid == blob.id
167167
assert BLOB_SHA == blob_oid

test/test_commit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def test_amend_commit_argument_types(barerepo: Repository) -> None:
278278
# Pass an Oid for the commit
279279
amended_oid = repo.amend_commit(alt_commit1, None, message='Hello')
280280
amended_commit = repo[amended_oid]
281-
assert ObjectType.COMMIT == amended_commit.type
281+
assert int(ObjectType.COMMIT) == amended_commit.type
282282
assert amended_oid != COMMIT_SHA_TO_AMEND
283283

284284
# Pass a str for the commit
@@ -294,6 +294,6 @@ def test_amend_commit_argument_types(barerepo: Repository) -> None:
294294
# (Warning: the tip of the branch will be altered after this test!)
295295
amended_oid = repo.amend_commit(alt_commit2, alt_refname, message='Hello')
296296
amended_commit = repo[amended_oid]
297-
assert ObjectType.COMMIT == amended_commit.type
297+
assert int(ObjectType.COMMIT) == amended_commit.type
298298
assert amended_oid != COMMIT_SHA_TO_AMEND
299299
assert repo.head.target == amended_oid

test/test_config.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,30 @@ def test_multivar() -> None:
156156
config.add_file(CONFIG_FILENAME, 6)
157157
assert 'this.that' in config
158158

159-
assert ['foobar', 'foobeer'] == list(config.get_multivar('this.that'))
160-
assert ['foobar'] == list(config.get_multivar('this.that', 'bar'))
161-
assert ['foobar', 'foobeer'] == list(config.get_multivar('this.that', 'foo.*'))
159+
assert ['foobar', 'foobeer'] == list(
160+
str(config_entry) for config_entry in config.get_multivar('this.that')
161+
)
162+
assert ['foobar'] == list(
163+
str(config_entry) for config_entry in config.get_multivar('this.that', 'bar')
164+
)
165+
assert ['foobar', 'foobeer'] == list(
166+
str(config_entry) for config_entry in config.get_multivar('this.that', 'foo.*')
167+
)
162168

163169
config.set_multivar('this.that', '^.*beer', 'fool')
164-
assert ['fool'] == list(config.get_multivar('this.that', 'fool'))
170+
assert ['fool'] == list(
171+
str(config_entry) for config_entry in config.get_multivar('this.that', 'fool')
172+
)
165173

166174
config.set_multivar('this.that', 'foo.*', 'foo-123456')
167175
assert ['foo-123456', 'foo-123456'] == list(
168-
config.get_multivar('this.that', 'foo.*')
176+
str(config_entry) for config_entry in config.get_multivar('this.that', 'foo.*')
169177
)
170178

171179
config.delete_multivar('this.that', 'bar')
172-
assert ['foo-123456', 'foo-123456'] == list(config.get_multivar('this.that', ''))
180+
assert ['foo-123456', 'foo-123456'] == list(
181+
str(config_entry) for config_entry in config.get_multivar('this.that', '')
182+
)
173183

174184
config.delete_multivar('this.that', 'foo-[0-9]+')
175185
assert [] == list(config.get_multivar('this.that', ''))

test/test_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_sorting(barerepo: Repository) -> None:
9999
tree_a = barerepo['18e2d2e9db075f9eb43bcb2daa65a2867d29a15e']
100100
assert isinstance(tree_a, Tree)
101101
assert list(tree_a) == sorted(reversed(list(tree_a)), key=pygit2.tree_entry_key)
102-
assert list(tree_a) != reversed(list(tree_a))
102+
assert list(tree_a) != list(reversed(list(tree_a)))
103103

104104

105105
def test_read_subtree(barerepo: Repository) -> None:

0 commit comments

Comments
 (0)