Skip to content

Commit cc76ac5

Browse files
authored
Fix #776: fix sync socket close helper method (#777)
* Fix #776: fix sync socket close helper method * Improve type hints in socket wrapper classes
1 parent fac52ee commit cc76ac5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

neo4j/_async_compat/network/_bolt_socket.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
if t.TYPE_CHECKING:
4444
import typing_extensions as te
4545

46+
from ..._async.io import AsyncBolt
47+
from ..._sync.io import Bolt
48+
4649
from ... import addressing
4750
from ..._deadline import Deadline
4851
from ..._exceptions import (
@@ -75,7 +78,7 @@ def _sanitize_deadline(deadline):
7578

7679

7780
class AsyncBoltSocket:
78-
Bolt: te.Final[t.Type] = None # type: ignore[assignment]
81+
Bolt: te.Final[t.Type[AsyncBolt]] = None # type: ignore[assignment]
7982

8083
def __init__(self, reader, protocol, writer):
8184
self._reader = reader # type: asyncio.StreamReader
@@ -405,7 +408,7 @@ async def connect(cls, address, *, timeout, custom_resolver, ssl_context,
405408

406409

407410
class BoltSocket:
408-
Bolt: te.Final[t.Type] = None # type: ignore[assignment]
411+
Bolt: te.Final[t.Type[Bolt]] = None # type: ignore[assignment]
409412

410413
def __init__(self, socket_: socket):
411414
self._socket = socket_
@@ -605,7 +608,7 @@ def _handshake(cls, s, resolved_address):
605608
def close_socket(cls, socket_):
606609
try:
607610
if isinstance(socket_, BoltSocket):
608-
socket.close()
611+
socket_.close()
609612
else:
610613
socket_.shutdown(SHUT_RDWR)
611614
socket_.close()

0 commit comments

Comments
 (0)