Skip to content

Commit 71fe831

Browse files
committed
Another attempt to fix type checking.
1 parent 02aee02 commit 71fe831

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/trio/_ssl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def __init__(
394394

395395
self._estimated_receive_size = STARTING_RECEIVE_SIZE
396396

397-
self._ssl_error = None
397+
self._ssl_error: _stdlib_ssl.CertificateError | None = None
398398

399399
_forwarded: ClassVar = {
400400
"context",

src/trio/_tests/test_ssl.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,31 +472,29 @@ async def test_ssl_client_basics(client_ctx: SSLContext) -> None:
472472
# rather than choking with UNEXPECTED_EOF_WHILE_READING.
473473
with pytest.RaisesGroup(
474474
pytest.RaisesExc(ssl.SSLError, match="TLSV1_ALERT_UNKNOWN_CA")
475-
) as excinfo:
475+
):
476476
async with ssl_echo_server_raw(expect_fail="raise") as sock:
477477
bad_client_ctx = ssl.create_default_context()
478478
s = SSLStream(
479479
sock, bad_client_ctx, server_hostname="trio-test-1.example.org"
480480
)
481481
assert not s.server_side
482-
with pytest.RaisesGroup(
483-
BrokenResourceError, allow_unwrapped=True, flatten_subgroups=True
484-
) as excinfo:
482+
with pytest.raises(BrokenResourceError) as excinfo1:
485483
await s.send_all(b"x")
486-
assert isinstance(excinfo.value.__cause__, ssl.SSLError)
484+
assert isinstance(excinfo1.value.__cause__, ssl.SSLError)
487485

488486
# Trusted CA, but wrong host name
489487
# Check that the server receives SSLV3_ALERT_BAD_CERTIFICATE
490488
# rather than choking with UNEXPECTED_EOF_WHILE_READING.
491489
with pytest.RaisesGroup(
492490
pytest.RaisesExc(ssl.SSLError, match="SSLV3_ALERT_BAD_CERTIFICATE")
493-
) as excinfo:
491+
):
494492
async with ssl_echo_server_raw(expect_fail="raise") as sock:
495493
s = SSLStream(sock, client_ctx, server_hostname="trio-test-2.example.org")
496494
assert not s.server_side
497-
with pytest.raises(BrokenResourceError) as excinfo:
495+
with pytest.raises(BrokenResourceError) as excinfo2:
498496
await s.send_all(b"x")
499-
assert isinstance(excinfo.value.__cause__, ssl.CertificateError)
497+
assert isinstance(excinfo2.value.__cause__, ssl.CertificateError)
500498

501499

502500
async def test_ssl_server_basics(client_ctx: SSLContext) -> None:

0 commit comments

Comments
 (0)