@@ -320,7 +320,9 @@ def get_settings(self) -> '_cprotocol.ConnectionSettings':
320320 return self ._protocol .get_settings ()
321321
322322 def transaction (self , * ,
323- isolation : transaction .IsolationLevels = 'read_committed' ,
323+ isolation : typing .Optional [
324+ transaction .IsolationLevels
325+ ] = None ,
324326 readonly : bool = False ,
325327 deferrable : bool = False ) -> transaction .Transaction :
326328 """Create a :class:`~transaction.Transaction` object.
@@ -1749,7 +1751,7 @@ def _maybe_gc_stmt(
17491751 if (
17501752 stmt .refs == 0
17511753 and not self ._stmt_cache .has (
1752- (stmt .query , stmt .record_class , bool ( stmt .ignore_custom_codec ) )
1754+ (stmt .query , stmt .record_class , stmt .ignore_custom_codec )
17531755 )
17541756 ):
17551757 # If low-level `stmt` isn't referenced from any high-level
@@ -2736,14 +2738,17 @@ async def connect(dsn: typing.Optional[str] = None, *,
27362738 )
27372739
27382740
2741+ _StatementCacheKey = typing .Tuple [str , typing .Type [_Record ], bool ]
2742+
2743+
27392744class _StatementCacheEntry :
27402745
27412746 __slots__ = ('_query' , '_statement' , '_cache' , '_cleanup_cb' )
27422747
27432748 def __init__ (
27442749 self ,
27452750 cache : '_StatementCache' ,
2746- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2751+ query : _StatementCacheKey [ _Record ],
27472752 statement : '_cprotocol.PreparedStatementState[_Record]'
27482753 ) -> None :
27492754 self ._cache = cache
@@ -2783,7 +2788,7 @@ def __init__(self, *, loop: asyncio.AbstractEventLoop,
27832788 # entries dict, whereas the unused one will group in the
27842789 # beginning of it.
27852790 self ._entries : collections .OrderedDict [
2786- typing . Tuple [ str , typing . Type [ '_cprotocol.Record' ], bool ],
2791+ _StatementCacheKey [ '_cprotocol.Record' ],
27872792 _StatementCacheEntry
27882793 ] = collections .OrderedDict ()
27892794
@@ -2811,7 +2816,7 @@ def set_max_lifetime(self, new_lifetime: float) -> None:
28112816
28122817 def get (
28132818 self ,
2814- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2819+ query : _StatementCacheKey [ _Record ],
28152820 * ,
28162821 promote : bool = True
28172822 ) -> typing .Optional ['_cprotocol.PreparedStatementState[_Record]' ]:
@@ -2837,12 +2842,12 @@ def get(
28372842
28382843 return entry ._statement
28392844
2840- def has (self , query : typing . Tuple [ str , typing . Type [ _Record ], bool ]) -> bool :
2845+ def has (self , query : _StatementCacheKey [ _Record ]) -> bool :
28412846 return self .get (query , promote = False ) is not None
28422847
28432848 def put (
28442849 self ,
2845- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2850+ query : _StatementCacheKey [ _Record ],
28462851 statement : '_cprotocol.PreparedStatementState[_Record]'
28472852 ) -> None :
28482853 if not self ._max_size :
@@ -2884,7 +2889,7 @@ def _set_entry_timeout(self, entry: _StatementCacheEntry) -> None:
28842889
28852890 def _new_entry (
28862891 self ,
2887- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2892+ query : _StatementCacheKey [ _Record ],
28882893 statement : '_cprotocol.PreparedStatementState[_Record]'
28892894 ) -> _StatementCacheEntry :
28902895 entry = _StatementCacheEntry (self , query , statement )
0 commit comments