160160import functools
161161import logging
162162import re
163- from typing import Any , Awaitable , Callable , Generic , TypeVar
163+ from typing import Any , Awaitable , Callable , Generic , Literal , TypeVar
164164
165165from wrapt import wrap_function_wrapper
166166
199199 "MySQLdb" : "mysqlclient" ,
200200}
201201
202+ CommentPositionT = Literal ["start" , "end" ]
203+
202204_logger = logging .getLogger (__name__ )
203205
204206ConnectionT = TypeVar ("ConnectionT" )
@@ -216,7 +218,7 @@ def trace_integration( # pylint: disable=too-many-positional-arguments
216218 db_api_integration_factory : type [DatabaseApiIntegration ] | None = None ,
217219 enable_attribute_commenter : bool = False ,
218220 commenter_options : dict [str , Any ] | None = None ,
219- comment_position : str = "end" ,
221+ comment_position : CommentPositionT = "end" ,
220222):
221223 """Integrate with DB API library.
222224 https://www.python.org/dev/peps/pep-0249/
@@ -267,7 +269,7 @@ def wrap_connect( # pylint: disable=too-many-positional-arguments
267269 db_api_integration_factory : type [DatabaseApiIntegration ] | None = None ,
268270 commenter_options : dict [str , Any ] | None = None ,
269271 enable_attribute_commenter : bool = False ,
270- comment_position : str = "end" ,
272+ comment_position : CommentPositionT = "end" ,
271273):
272274 """Integrate with DB API library.
273275 https://www.python.org/dev/peps/pep-0249/
@@ -349,7 +351,7 @@ def instrument_connection( # pylint: disable=too-many-positional-arguments
349351 connect_module : Callable [..., Any ] | None = None ,
350352 enable_attribute_commenter : bool = False ,
351353 db_api_integration_factory : type [DatabaseApiIntegration ] | None = None ,
352- comment_position : str = "end" ,
354+ comment_position : CommentPositionT = "end" ,
353355) -> TracedConnectionProxy [ConnectionT ]:
354356 """Enable instrumentation in a database connection.
355357
@@ -431,7 +433,7 @@ def __init__( # pylint: disable=too-many-positional-arguments
431433 commenter_options : dict [str , Any ] | None = None ,
432434 connect_module : Callable [..., Any ] | None = None ,
433435 enable_attribute_commenter : bool = False ,
434- comment_position : str = "end" ,
436+ comment_position : CommentPositionT = "end" ,
435437 ):
436438 if connection_attributes is None :
437439 self .connection_attributes = {
0 commit comments