@@ -320,7 +320,9 @@ def get_settings(self) -> '_cprotocol.ConnectionSettings':
320
320
return self ._protocol .get_settings ()
321
321
322
322
def transaction (self , * ,
323
- isolation : transaction .IsolationLevels = 'read_committed' ,
323
+ isolation : typing .Optional [
324
+ transaction .IsolationLevels
325
+ ] = None ,
324
326
readonly : bool = False ,
325
327
deferrable : bool = False ) -> transaction .Transaction :
326
328
"""Create a :class:`~transaction.Transaction` object.
@@ -1749,7 +1751,7 @@ def _maybe_gc_stmt(
1749
1751
if (
1750
1752
stmt .refs == 0
1751
1753
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 )
1753
1755
)
1754
1756
):
1755
1757
# If low-level `stmt` isn't referenced from any high-level
@@ -2736,14 +2738,17 @@ async def connect(dsn: typing.Optional[str] = None, *,
2736
2738
)
2737
2739
2738
2740
2741
+ _StatementCacheKey = typing .Tuple [str , typing .Type [_Record ], bool ]
2742
+
2743
+
2739
2744
class _StatementCacheEntry :
2740
2745
2741
2746
__slots__ = ('_query' , '_statement' , '_cache' , '_cleanup_cb' )
2742
2747
2743
2748
def __init__ (
2744
2749
self ,
2745
2750
cache : '_StatementCache' ,
2746
- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2751
+ query : _StatementCacheKey [ _Record ],
2747
2752
statement : '_cprotocol.PreparedStatementState[_Record]'
2748
2753
) -> None :
2749
2754
self ._cache = cache
@@ -2783,7 +2788,7 @@ def __init__(self, *, loop: asyncio.AbstractEventLoop,
2783
2788
# entries dict, whereas the unused one will group in the
2784
2789
# beginning of it.
2785
2790
self ._entries : collections .OrderedDict [
2786
- typing . Tuple [ str , typing . Type [ '_cprotocol.Record' ], bool ],
2791
+ _StatementCacheKey [ '_cprotocol.Record' ],
2787
2792
_StatementCacheEntry
2788
2793
] = collections .OrderedDict ()
2789
2794
@@ -2811,7 +2816,7 @@ def set_max_lifetime(self, new_lifetime: float) -> None:
2811
2816
2812
2817
def get (
2813
2818
self ,
2814
- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2819
+ query : _StatementCacheKey [ _Record ],
2815
2820
* ,
2816
2821
promote : bool = True
2817
2822
) -> typing .Optional ['_cprotocol.PreparedStatementState[_Record]' ]:
@@ -2837,12 +2842,12 @@ def get(
2837
2842
2838
2843
return entry ._statement
2839
2844
2840
- def has (self , query : typing . Tuple [ str , typing . Type [ _Record ], bool ]) -> bool :
2845
+ def has (self , query : _StatementCacheKey [ _Record ]) -> bool :
2841
2846
return self .get (query , promote = False ) is not None
2842
2847
2843
2848
def put (
2844
2849
self ,
2845
- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2850
+ query : _StatementCacheKey [ _Record ],
2846
2851
statement : '_cprotocol.PreparedStatementState[_Record]'
2847
2852
) -> None :
2848
2853
if not self ._max_size :
@@ -2884,7 +2889,7 @@ def _set_entry_timeout(self, entry: _StatementCacheEntry) -> None:
2884
2889
2885
2890
def _new_entry (
2886
2891
self ,
2887
- query : typing . Tuple [ str , typing . Type [ _Record ], bool ],
2892
+ query : _StatementCacheKey [ _Record ],
2888
2893
statement : '_cprotocol.PreparedStatementState[_Record]'
2889
2894
) -> _StatementCacheEntry :
2890
2895
entry = _StatementCacheEntry (self , query , statement )
0 commit comments