Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ddceff9

Browse files
committed
Fix the first stage of mypy stricter errors
Following this doc: https://mypy.readthedocs.io/en/stable/existing_code.html#getting-to-strict Total 13 error fixed.
1 parent 6caa06d commit ddceff9

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

pygit2/blame.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def __del__(self) -> None:
127127
C.git_blame_free(self._blame)
128128

129129
def __len__(self) -> int:
130-
return C.git_blame_get_hunk_count(self._blame) # type: ignore[no-any-return]
130+
return C.git_blame_get_hunk_count(self._blame)
131131

132132
def __getitem__(self, index: int) -> BlameHunk:
133133
chunk = C.git_blame_get_hunk_byindex(self._blame, index)

pygit2/callbacks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def git_proxy_options(
414414
elif type(proxy) is str:
415415
opts.type = C.GIT_PROXY_SPECIFIED
416416
# Keep url in memory, otherwise memory is freed and bad things happen
417-
payload.__proxy_url = ffi.new('char[]', to_bytes(proxy)) # type: ignore[attr-defined, no-untyped-call]
417+
payload.__proxy_url = ffi.new('char[]', to_bytes(proxy)) # type: ignore[attr-defined]
418418
opts.url = payload.__proxy_url # type: ignore[attr-defined]
419419
else:
420420
raise TypeError('Proxy must be None, True, or a string')

pygit2/ffi.py

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

2626
# Import from pygit2
27-
from ._libgit2 import ffi # type: ignore # noqa: F401
27+
from ._libgit2 import ffi # noqa: F401
2828
from ._libgit2 import lib as C # type: ignore # noqa: F401

pygit2/repository.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def diff(
615615

616616
# Case 2: Index to workdir
617617
elif a is None and b is None:
618-
return self.index.diff_to_workdir(**options) # type: ignore[arg-type]
618+
return self.index.diff_to_workdir(**options)
619619

620620
# Case 3: Diff tree to index or workdir
621621
elif isinstance(a, Tree) and b is None:

test/test_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def test_read(testrepo: Repository) -> None:
4949
assert len(index) == 2
5050

5151
with pytest.raises(TypeError):
52-
index[()] # type: ignore
53-
utils.assertRaisesWithArg(ValueError, -4, lambda: index[-4]) # type: ignore
52+
index[()]
53+
utils.assertRaisesWithArg(ValueError, -4, lambda: index[-4])
5454
utils.assertRaisesWithArg(KeyError, 'abc', lambda: index['abc'])
5555

5656
sha = 'a520c24d85fbfc815d385957eed41406ca5a860b'

test/test_tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_new_tag(barerepo: Repository) -> None:
5959
target_prefix = target[:5]
6060
too_short_prefix = target[:3]
6161
with pytest.raises(ValueError):
62-
barerepo.create_tag(name, too_short_prefix, ObjectType.BLOB, tagger, message) # type: ignore
62+
barerepo.create_tag(name, too_short_prefix, ObjectType.BLOB, tagger, message)
6363

6464
sha = barerepo.create_tag(name, target_prefix, ObjectType.BLOB, tagger, message)
6565
tag = barerepo[sha]

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)) # type: ignore[comparison-overlap]
102+
assert list(tree_a) != reversed(list(tree_a))
103103

104104

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

0 commit comments

Comments
 (0)