52
52
TYPE_RSA ,
53
53
X509 ,
54
54
PKey ,
55
+ X509Name ,
55
56
X509Store ,
56
57
dump_certificate ,
57
58
dump_privatekey ,
@@ -3144,15 +3145,15 @@ def test_wantReadError(self) -> None:
3144
3145
conn .bio_read (1024 )
3145
3146
3146
3147
@pytest .mark .parametrize ("bufsize" , [1.0 , None , object (), "bufsize" ])
3147
- def test_bio_read_wrong_args (self , bufsize ) -> None :
3148
+ def test_bio_read_wrong_args (self , bufsize : object ) -> None :
3148
3149
"""
3149
3150
`Connection.bio_read` raises `TypeError` if passed a non-integer
3150
3151
argument.
3151
3152
"""
3152
3153
ctx = Context (SSLv23_METHOD )
3153
3154
conn = Connection (ctx , None )
3154
3155
with pytest .raises (TypeError ):
3155
- conn .bio_read (bufsize )
3156
+ conn .bio_read (bufsize ) # type: ignore[arg-type]
3156
3157
3157
3158
def test_buffer_size (self ) -> None :
3158
3159
"""
@@ -3287,7 +3288,9 @@ class TestConnectionRecvInto:
3287
3288
Tests for `Connection.recv_into`.
3288
3289
"""
3289
3290
3290
- def _no_length_test (self , factory ):
3291
+ def _no_length_test (
3292
+ self , factory : typing .Callable [[int ], typing .Any ]
3293
+ ) -> None :
3291
3294
"""
3292
3295
Assert that when the given buffer is passed to `Connection.recv_into`,
3293
3296
whatever bytes are available to be received that fit into that buffer
@@ -3308,7 +3311,9 @@ def test_bytearray_no_length(self) -> None:
3308
3311
"""
3309
3312
self ._no_length_test (bytearray )
3310
3313
3311
- def _respects_length_test (self , factory ):
3314
+ def _respects_length_test (
3315
+ self , factory : typing .Callable [[int ], typing .Any ]
3316
+ ) -> None :
3312
3317
"""
3313
3318
Assert that when the given buffer is passed to `Connection.recv_into`
3314
3319
along with a value for `nbytes` that is less than the size of that
@@ -3330,7 +3335,9 @@ def test_bytearray_respects_length(self) -> None:
3330
3335
"""
3331
3336
self ._respects_length_test (bytearray )
3332
3337
3333
- def _doesnt_overfill_test (self , factory ):
3338
+ def _doesnt_overfill_test (
3339
+ self , factory : typing .Callable [[int ], typing .Any ]
3340
+ ) -> None :
3334
3341
"""
3335
3342
Assert that if there are more bytes available to be read from the
3336
3343
receive buffer than would fit into the buffer passed to
@@ -3881,7 +3888,9 @@ def test_unexpected_EOF(self) -> None:
3881
3888
(54 , "ECONNRESET" ),
3882
3889
]
3883
3890
3884
- def _check_client_ca_list (self , func ):
3891
+ def _check_client_ca_list (
3892
+ self , func : typing .Callable [[Context ], list [X509Name ]]
3893
+ ) -> None :
3885
3894
"""
3886
3895
Verify the return value of the `get_client_ca_list` method for
3887
3896
server and client connections.
@@ -3912,9 +3921,9 @@ def test_set_client_ca_list_errors(self) -> None:
3912
3921
"""
3913
3922
ctx = Context (SSLv23_METHOD )
3914
3923
with pytest .raises (TypeError ):
3915
- ctx .set_client_ca_list ("spam" )
3924
+ ctx .set_client_ca_list ("spam" ) # type: ignore[arg-type]
3916
3925
with pytest .raises (TypeError ):
3917
- ctx .set_client_ca_list (["spam" ])
3926
+ ctx .set_client_ca_list (["spam" ]) # type: ignore[list-item]
3918
3927
3919
3928
def test_set_empty_ca_list (self ) -> None :
3920
3929
"""
@@ -4016,7 +4025,7 @@ def test_add_client_ca_wrong_args(self) -> None:
4016
4025
"""
4017
4026
ctx = Context (SSLv23_METHOD )
4018
4027
with pytest .raises (TypeError ):
4019
- ctx .add_client_ca ("spam" )
4028
+ ctx .add_client_ca ("spam" ) # type: ignore[arg-type]
4020
4029
4021
4030
def test_one_add_client_ca (self ) -> None :
4022
4031
"""
@@ -4142,7 +4151,7 @@ def test_available(self) -> None:
4142
4151
results = []
4143
4152
4144
4153
@feature_guard
4145
- def inner ():
4154
+ def inner () -> bool :
4146
4155
results .append (True )
4147
4156
return True
4148
4157
@@ -4157,7 +4166,7 @@ def test_unavailable(self) -> None:
4157
4166
feature_guard = _make_requires (False , "Error text" )
4158
4167
4159
4168
@feature_guard
4160
- def inner (): # pragma: nocover
4169
+ def inner () -> None : # pragma: nocover
4161
4170
pytest .fail ("Should not be called" )
4162
4171
4163
4172
with pytest .raises (NotImplementedError ) as e :
@@ -4180,7 +4189,7 @@ def _client_connection(
4180
4189
self ,
4181
4190
callback : typing .Callable [[Connection , bytes , T | None ], bool ],
4182
4191
data : T | None ,
4183
- request_ocsp = True ,
4192
+ request_ocsp : bool = True ,
4184
4193
) -> Connection :
4185
4194
"""
4186
4195
Builds a client connection suitable for using OCSP.
@@ -4586,6 +4595,7 @@ def pump() -> None:
4586
4595
s_listening = False
4587
4596
s_handshaking = True
4588
4597
# Write the duplicate ClientHello. See giant comment above.
4598
+ assert latest_client_hello is not None
4589
4599
s .bio_write (latest_client_hello )
4590
4600
4591
4601
if s_handshaking :
0 commit comments