2929import pytest
3030
3131import pygit2
32+ from pygit2 import Repository , Signature
3233
3334
34- def __assert (signature , encoding ) :
35+ def __assert (signature : Signature , encoding : None | str ) -> None :
3536 encoding = encoding or 'utf-8'
3637 assert signature ._encoding == encoding
3738 assert signature .name == signature .raw_name .decode (encoding )
@@ -41,25 +42,25 @@ def __assert(signature, encoding):
4142
4243
4344@pytest .mark .parametrize ('encoding' , [None , 'utf-8' , 'iso-8859-1' ])
44- def test_encoding (encoding ) :
45+ def test_encoding (encoding : None | str ) -> None :
4546 signature = pygit2 .Signature ('Foo Ibáñez' , 'foo@example.com' , encoding = encoding )
4647 __assert (signature , encoding )
4748 assert abs (signature .time - time .time ()) < 5
4849 assert str (signature ) == 'Foo Ibáñez <foo@example.com>'
4950
5051
51- def test_default_encoding ():
52+ def test_default_encoding () -> None :
5253 signature = pygit2 .Signature ('Foo Ibáñez' , 'foo@example.com' , 1322174594 , 60 )
5354 __assert (signature , 'utf-8' )
5455
5556
56- def test_ascii ():
57+ def test_ascii () -> None :
5758 with pytest .raises (UnicodeEncodeError ):
5859 pygit2 .Signature ('Foo Ibáñez' , 'foo@example.com' , encoding = 'ascii' )
5960
6061
6162@pytest .mark .parametrize ('encoding' , [None , 'utf-8' , 'iso-8859-1' ])
62- def test_repr (encoding ) :
63+ def test_repr (encoding : str | None ) -> None :
6364 signature = pygit2 .Signature (
6465 'Foo Ibáñez' , 'foo@bar.com' , 1322174594 , 60 , encoding = encoding
6566 )
@@ -68,7 +69,7 @@ def test_repr(encoding):
6869 assert signature == eval (expected )
6970
7071
71- def test_repr_from_commit (barerepo ) :
72+ def test_repr_from_commit (barerepo : Repository ) -> None :
7273 repo = barerepo
7374 signature = pygit2 .Signature ('Foo Ibáñez' , 'foo@example.com' , encoding = None )
7475 tree = '967fce8df97cc71722d3c2a5930ef3e6f1d27b12'
@@ -80,7 +81,7 @@ def test_repr_from_commit(barerepo):
8081 assert repr (signature ) == repr (commit .committer )
8182
8283
83- def test_incorrect_encoding ():
84+ def test_incorrect_encoding () -> None :
8485 gbk_bytes = 'Café' .encode ('GBK' )
8586
8687 # deliberately specifying a mismatching encoding (mojibake)
0 commit comments