Skip to content

Commit de6092a

Browse files
committed
Fix mypy strict equality
1 parent 68c871b commit de6092a

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
assertblob.id==BLOB_SHA
8888
assertisinstance(blob, pygit2.Blob)
8989
assertnotblob.is_binary
90-
assertObjectType.BLOB==blob.type
90+
assertint(ObjectType.BLOB)==blob.type
9191
assertBLOB_CONTENT==blob.data
9292
assertlen(BLOB_CONTENT) ==blob.size
9393
assertBLOB_CONTENT==blob.read_raw()
@@ -98,7 +98,7 @@ def test_create_blob(testrepo: Repository) -> None:
9898
blob=testrepo[blob_oid]
9999

100100
assertisinstance(blob, pygit2.Blob)
101-
assertObjectType.BLOB==blob.type
101+
assertint(ObjectType.BLOB)==blob.type
102102

103103
assertblob_oid==blob.id
104104
assertutils.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
assertisinstance(blob, pygit2.Blob)
125-
assertObjectType.BLOB==blob.type
125+
assertint(ObjectType.BLOB)==blob.type
126126

127127
assertblob_oid==blob.id
128128
assertutils.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
assertisinstance(blob, pygit2.Blob)
152-
assertObjectType.BLOB==blob.type
152+
assertint(ObjectType.BLOB)==blob.type
153153

154154

155155
deftest_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
assertisinstance(blob, pygit2.Blob)
164-
assertObjectType.BLOB==blob.type
164+
assertint(ObjectType.BLOB)==blob.type
165165

166166
assertblob_oid==blob.id
167167
assertBLOB_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-
assertObjectType.COMMIT==amended_commit.type
281+
assertint(ObjectType.COMMIT)==amended_commit.type
282282
assertamended_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-
assertObjectType.COMMIT==amended_commit.type
297+
assertint(ObjectType.COMMIT)==amended_commit.type
298298
assertamended_oid!=COMMIT_SHA_TO_AMEND
299299
assertrepo.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'inconfig
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) forconfig_entryinconfig.get_multivar('this.that')
161+
)
162+
assert ['foobar'] ==list(
163+
str(config_entry) forconfig_entryinconfig.get_multivar('this.that', 'bar')
164+
)
165+
assert ['foobar', 'foobeer'] ==list(
166+
str(config_entry) forconfig_entryinconfig.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) forconfig_entryinconfig.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) forconfig_entryinconfig.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) forconfig_entryinconfig.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
assertisinstance(tree_a, Tree)
101101
assertlist(tree_a) ==sorted(reversed(list(tree_a)), key=pygit2.tree_entry_key)
102-
assertlist(tree_a) !=reversed(list(tree_a))
102+
assertlist(tree_a) !=list(reversed(list(tree_a)))
103103

104104

105105
deftest_read_subtree(barerepo: Repository) ->None:

0 commit comments

Comments
(0)