6060 + ConnectionAcquisitionTimeoutError
6161"""
6262
63- from __future__ import annotations
63+ from __future__ import annotations as _
6464
65- import typing as t
65+ import typing as _t
6666from copy import deepcopy as _deepcopy
6767from enum import Enum as _Enum
6868
6969from ._warnings import preview as _preview
7070
7171
72- if t .TYPE_CHECKING :
73- from collections .abc import Mapping
72+ if _t .TYPE_CHECKING :
73+ from collections .abc import Mapping as _Mapping
7474
75- import typing_extensions as te
75+ import typing_extensions as _te
7676
7777 from ._async .work import (
78- AsyncManagedTransaction ,
79- AsyncResult ,
80- AsyncSession ,
81- AsyncTransaction ,
78+ AsyncManagedTransaction as _AsyncManagedTransaction ,
79+ AsyncResult as _AsyncResult ,
80+ AsyncSession as _AsyncSession ,
81+ AsyncTransaction as _AsyncTransaction ,
8282 )
8383 from ._sync .work import (
84- ManagedTransaction ,
85- Result ,
86- Session ,
87- Transaction ,
84+ ManagedTransaction as _ManagedTransaction ,
85+ Result as _Result ,
86+ Session as _Session ,
87+ Transaction as _Transaction ,
8888 )
8989
90- _TTransaction : t .TypeAlias = (
91- AsyncManagedTransaction
92- | AsyncTransaction
93- | ManagedTransaction
94- | Transaction
90+ _TTransaction : _t .TypeAlias = (
91+ _AsyncManagedTransaction
92+ | _AsyncTransaction
93+ | _ManagedTransaction
94+ | _Transaction
9595 )
96- _TResult : t .TypeAlias = AsyncResult | Result
97- _TSession : t .TypeAlias = AsyncSession | Session
98- _T = t .TypeVar ("_T" )
96+ _TResult : _t .TypeAlias = _AsyncResult | _Result
97+ _TSession : _t .TypeAlias = _AsyncSession | _Session
98+ _T = _t .TypeVar ("_T" )
9999
100100
101101__all__ = [
138138]
139139
140140
141- _CLASSIFICATION_CLIENT : te .Final [str ] = "ClientError"
142- _CLASSIFICATION_TRANSIENT : te .Final [str ] = "TransientError"
143- _CLASSIFICATION_DATABASE : te .Final [str ] = "DatabaseError"
141+ _CLASSIFICATION_CLIENT : _te .Final [str ] = "ClientError"
142+ _CLASSIFICATION_TRANSIENT : _te .Final [str ] = "TransientError"
143+ _CLASSIFICATION_DATABASE : _te .Final [str ] = "DatabaseError"
144144
145145
146146_ERROR_REWRITE_MAP : dict [str , tuple [str , str | None ]] = {
167167}
168168
169169
170- _UNKNOWN_NEO4J_CODE : te .Final [str ] = "Neo.DatabaseError.General.UnknownError"
170+ _UNKNOWN_NEO4J_CODE : _te .Final [str ] = "Neo.DatabaseError.General.UnknownError"
171171# TODO: 7.0 - Make _UNKNOWN_GQL_MESSAGE the default message
172- _UNKNOWN_MESSAGE : te .Final [str ] = "An unknown error occurred"
173- _UNKNOWN_GQL_STATUS : te .Final [str ] = "50N42"
174- _UNKNOWN_GQL_DESCRIPTION : te .Final [str ] = (
172+ _UNKNOWN_MESSAGE : _te .Final [str ] = "An unknown error occurred"
173+ _UNKNOWN_GQL_STATUS : _te .Final [str ] = "50N42"
174+ _UNKNOWN_GQL_DESCRIPTION : _te .Final [str ] = (
175175 "error: general processing exception - unexpected error"
176176)
177- _UNKNOWN_GQL_MESSAGE : te .Final [str ] = (
177+ _UNKNOWN_GQL_MESSAGE : _te .Final [str ] = (
178178 f"{ _UNKNOWN_GQL_STATUS } : "
179179 "Unexpected error has occurred. See debug log for details."
180180)
181- _UNKNOWN_GQL_DIAGNOSTIC_RECORD : te .Final [tuple [tuple [str , t .Any ], ...]] = (
181+ _UNKNOWN_GQL_DIAGNOSTIC_RECORD : _te .Final [tuple [tuple [str , _t .Any ], ...]] = (
182182 ("OPERATION" , "" ),
183183 ("OPERATION_CODE" , "0" ),
184184 ("CURRENT_SCHEMA" , "/" ),
@@ -240,12 +240,12 @@ class GqlError(Exception):
240240 _gql_status_description : str
241241 _gql_raw_classification : str | None
242242 _gql_classification : GqlErrorClassification
243- _status_diagnostic_record : dict [str , t .Any ] # original, internal only
244- _diagnostic_record : dict [str , t .Any ] # copy to be used externally
243+ _status_diagnostic_record : dict [str , _t .Any ] # original, internal only
244+ _diagnostic_record : dict [str , _t .Any ] # copy to be used externally
245245 _gql_cause : GqlError | None
246246
247247 @staticmethod
248- def _hydrate_cause (** metadata : t .Any ) -> GqlError :
248+ def _hydrate_cause (** metadata : _t .Any ) -> GqlError :
249249 meta_extractor = _MetaExtractor (metadata )
250250 gql_status = meta_extractor .str_value ("gql_status" )
251251 description = meta_extractor .str_value ("description" )
@@ -276,7 +276,7 @@ def _init_gql(
276276 gql_status : str ,
277277 message : str ,
278278 description : str ,
279- diagnostic_record : dict [str , t .Any ] | None = None ,
279+ diagnostic_record : dict [str , _t .Any ] | None = None ,
280280 cause : GqlError | None = None ,
281281 ) -> None :
282282 self ._gql_status = gql_status
@@ -438,7 +438,7 @@ def _gql_classification_no_preview(self) -> GqlErrorClassification:
438438 if not (
439439 isinstance (classification , str )
440440 and classification
441- in t .cast (t .Iterable [str ], iter (GqlErrorClassification ))
441+ in _t .cast (_t .Iterable [str ], iter (GqlErrorClassification ))
442442 ):
443443 self ._gql_classification = GqlErrorClassification .UNKNOWN
444444 else :
@@ -450,15 +450,15 @@ def _gql_classification_no_preview(self) -> GqlErrorClassification:
450450 def gql_classification (self ) -> GqlErrorClassification :
451451 return self ._gql_classification_no_preview
452452
453- def _get_status_diagnostic_record (self ) -> dict [str , t .Any ]:
453+ def _get_status_diagnostic_record (self ) -> dict [str , _t .Any ]:
454454 if hasattr (self , "_status_diagnostic_record" ):
455455 return self ._status_diagnostic_record
456456
457457 self ._status_diagnostic_record = dict (_UNKNOWN_GQL_DIAGNOSTIC_RECORD )
458458 return self ._status_diagnostic_record
459459
460460 @property
461- def _diagnostic_record_no_preview (self ) -> Mapping [str , t .Any ]:
461+ def _diagnostic_record_no_preview (self ) -> _Mapping [str , _t .Any ]:
462462 if hasattr (self , "_diagnostic_record" ):
463463 return self ._diagnostic_record
464464
@@ -469,7 +469,7 @@ def _diagnostic_record_no_preview(self) -> Mapping[str, t.Any]:
469469
470470 @property
471471 @_preview ("GQLSTATUS support is a preview feature." )
472- def diagnostic_record (self ) -> Mapping [str , t .Any ]:
472+ def diagnostic_record (self ) -> _Mapping [str , _t .Any ]:
473473 return self ._diagnostic_record_no_preview
474474
475475 def __str__ (self ):
@@ -493,7 +493,7 @@ class Neo4jError(GqlError):
493493 _category : str
494494 _title : str
495495 #: (dict) Any additional information returned by the server.
496- _metadata : dict [str , t .Any ]
496+ _metadata : dict [str , _t .Any ]
497497 _from_server : bool
498498
499499 _retryable = False
@@ -508,7 +508,7 @@ def __init__(self, *args: object) -> None:
508508 )
509509
510510 @staticmethod
511- def _hydrate_neo4j (** metadata : t .Any ) -> Neo4jError :
511+ def _hydrate_neo4j (** metadata : _t .Any ) -> Neo4jError :
512512 meta_extractor = _MetaExtractor (metadata )
513513 code = meta_extractor .str_value ("code" ) or _UNKNOWN_NEO4J_CODE
514514 message = meta_extractor .str_value ("message" ) or _UNKNOWN_MESSAGE
@@ -525,7 +525,7 @@ def _hydrate_neo4j(**metadata: t.Any) -> Neo4jError:
525525 return inst
526526
527527 @staticmethod
528- def _hydrate_gql (** metadata : t .Any ) -> Neo4jError :
528+ def _hydrate_gql (** metadata : _t .Any ) -> Neo4jError :
529529 meta_extractor = _MetaExtractor (metadata )
530530 gql_status = meta_extractor .str_value ("gql_status" )
531531 status_description = meta_extractor .str_value ("description" )
@@ -643,7 +643,7 @@ def title(self) -> str:
643643 return self ._title
644644
645645 @property
646- def metadata (self ) -> dict [str , t .Any ]:
646+ def metadata (self ) -> dict [str , _t .Any ]:
647647 # Undocumented, might be useful for debugging
648648 return self ._metadata
649649
@@ -709,16 +709,16 @@ def __str__(self):
709709
710710
711711class _MetaExtractor :
712- def __init__ (self , metadata : dict [str , t .Any ]) -> None :
712+ def __init__ (self , metadata : dict [str , _t .Any ]) -> None :
713713 self ._metadata = metadata
714714
715- def rest (self ) -> dict [str , t .Any ]:
715+ def rest (self ) -> dict [str , _t .Any ]:
716716 return self ._metadata
717717
718- @t .overload
718+ @_t .overload
719719 def str_value (self , key : str ) -> str | None : ...
720720
721- @t .overload
721+ @_t .overload
722722 def str_value (self , key : str , default : _T ) -> str | _T : ...
723723
724724 def str_value (
@@ -729,15 +729,15 @@ def str_value(
729729 res = default
730730 return res
731731
732- @t .overload
733- def map_value (self , key : str ) -> dict [str , t .Any ] | None : ...
732+ @_t .overload
733+ def map_value (self , key : str ) -> dict [str , _t .Any ] | None : ...
734734
735- @t .overload
736- def map_value (self , key : str , default : _T ) -> dict [str , t .Any ] | _T : ...
735+ @_t .overload
736+ def map_value (self , key : str , default : _T ) -> dict [str , _t .Any ] | _T : ...
737737
738738 def map_value (
739739 self , key : str , default : _T | None = None
740- ) -> dict [str , t .Any ] | _T | None :
740+ ) -> dict [str , _t .Any ] | _T | None :
741741 res = self ._metadata .pop (key , default )
742742 if not (
743743 isinstance (res , dict ) and all (isinstance (k , str ) for k in res )
0 commit comments