11from __future__ import annotations
2-
32import contextvars
43from dataclasses import dataclass
54from typing import TYPE_CHECKING , Any , Generator , Mapping , Sequence
1312from psqlpy .exceptions import RustPSQLDriverPyBaseError
1413from typing_extensions import Self
1514
15+
1616if TYPE_CHECKING :
1717 import types
1818
@@ -88,7 +88,7 @@ async def __aexit__(
8888
8989
9090class Atomic :
91- """This is useful if you want to build up a transaction programmatically.
91+ """Useful if you want to build up a transaction programmatically.
9292
9393 Usage::
9494
@@ -205,8 +205,7 @@ def __init__(self: Self, engine: PSQLPyEngine, allow_nested: bool = True) -> Non
205205 self ._parent = current_transaction
206206 else :
207207 raise TransactionError (
208- "A transaction is already active - nested transactions "
209- "aren't allowed." ,
208+ "A transaction is already active - nested transactions aren't allowed." ,
210209 )
211210
212211 async def __aenter__ (self : Self ) -> Self :
@@ -296,8 +295,7 @@ async def savepoint(self: Self, name: str | None = None) -> Savepoint:
296295
297296
298297class PSQLPyEngine (Engine [PostgresTransaction ]):
299- """
300- Engine for PostgreSQL.
298+ """Engine for PostgreSQL.
301299
302300 ### Params:
303301 - `config`:
@@ -334,16 +332,12 @@ class PSQLPyEngine(Engine[PostgresTransaction]):
334332 to a ``PSQLPyEngine`` instance. For example::
335333
336334 DB = PSQLPyEngine(
337- config={' database': ' main_db' },
335+ config={" database": " main_db" },
338336 extra_nodes={
339- 'read_replica_1': PSQLPyEngine(
340- config={
341- 'database': 'main_db',
342- host: 'read_replicate.my_db.com'
343- },
344- extensions=()
337+ "read_replica_1": PSQLPyEngine(
338+ config={"database": "main_db", host: "read_replicate.my_db.com"}, extensions=()
345339 )
346- }
340+ },
347341 )
348342
349343 Note how we set ``extensions=()``, because it's a read only database.
@@ -358,7 +352,7 @@ class PSQLPyEngine(Engine[PostgresTransaction]):
358352 engine_type = "postgres"
359353 min_version_number = 10
360354
361- def __init__ (
355+ def __init__ ( # noqa: PLR0913
362356 self : Self ,
363357 config : dict [str , Any ],
364358 extensions : Sequence [str ] = ("uuid-ossp" ,),
@@ -403,16 +397,12 @@ def __init__(
403397 to a ``PSQLPyEngine`` instance. For example::
404398
405399 DB = PSQLPyEngine(
406- config={' database': ' main_db' },
400+ config={" database": " main_db" },
407401 extra_nodes={
408- 'read_replica_1': PSQLPyEngine(
409- config={
410- 'database': 'main_db',
411- host: 'read_replicate.my_db.com'
412- },
413- extensions=()
402+ "read_replica_1": PSQLPyEngine(
403+ config={"database": "main_db", host: "read_replicate.my_db.com"}, extensions=()
414404 )
415- }
405+ },
416406 )
417407
418408 Note how we set ``extensions=()``, because it's a read only database.
@@ -507,17 +497,15 @@ async def start_connnection_pool(
507497 - `kwargs`: configuration parameters for `ConnectionPool` from PSQLPy.
508498 """
509499 colored_warning (
510- "`start_connnection_pool` is a typo - please change it to "
511- "`start_connection_pool`." ,
500+ "`start_connnection_pool` is a typo - please change it to `start_connection_pool`." ,
512501 category = DeprecationWarning ,
513502 )
514503 return await self .start_connection_pool ()
515504
516505 async def close_connnection_pool (self : Self , ** _kwargs : dict [str , Any ]) -> None :
517506 """Close connection pool."""
518507 colored_warning (
519- "`close_connnection_pool` is a typo - please change it to "
520- "`close_connection_pool`." ,
508+ "`close_connnection_pool` is a typo - please change it to `close_connection_pool`." ,
521509 category = DeprecationWarning ,
522510 )
523511 return await self .close_connection_pool ()
@@ -533,8 +521,7 @@ async def start_connection_pool(self: Self, **kwargs: dict[str, Any]) -> None:
533521 """
534522 if self .pool :
535523 colored_warning (
536- "A pool already exists - close it first if you want to create "
537- "a new pool." ,
524+ "A pool already exists - close it first if you want to create a new pool." ,
538525 )
539526 else :
540527 config = dict (self .config )
@@ -669,7 +656,6 @@ async def run_querystring(
669656
670657 if self .log_queries :
671658 self .print_query (query_id = query_id , query = querystring .__str__ ())
672- print (querystring )
673659 # If running inside a transaction:
674660 current_transaction = self .current_transaction .get ()
675661 if current_transaction :
0 commit comments