From a5b12906d8742a869f7ac37cde128a965d9bdc32 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:31:53 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/mirrors-mypy: v2.1.0 → v2.3.1](https://github.com/pre-commit/mirrors-mypy/compare/v2.1.0...v2.3.1) - [github.com/astral-sh/ruff-pre-commit: v0.15.13 → v0.16.5](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.13...v0.16.5) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index eaba65b0..b819ffea 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: hooks: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v2.1.0 + rev: v2.3.1 hooks: - id: mypy name: python mypy @@ -15,7 +15,7 @@ repos: pass_filenames: false args: ["python"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.13 + rev: v0.16.5 hooks: # Run the linter. - id: ruff-check From 1b54b865e7155777a333159d408a4170eb1685c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 17:32:08 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- README.md | 1 - docs/components/connection.md | 5 +++++ docs/components/copy.md | 10 ++++++---- docs/components/cursor.md | 4 ++++ docs/components/listener.md | 14 ++++++++------ docs/components/prepared_statement.md | 2 ++ docs/components/transaction.md | 3 +-- docs/faq.md | 4 ++++ docs/usage/frameworks/aiohttp.md | 3 +-- docs/usage/frameworks/litestar.md | 1 - docs/usage/frameworks/panther.md | 2 +- docs/usage/row_factories/row_factories.md | 2 ++ docs/usage/types/array_types.md | 2 +- docs/usage/types/extra_types.md | 21 ++++++++++++++++----- python/psqlpy/extra_types.py | 4 ---- 15 files changed, 51 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b44e7f53..22d98473 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,6 @@ async def main() -> None: print(res.result()) db_pool.close() - ``` ## Benchmarks diff --git a/docs/components/connection.md b/docs/components/connection.md index bc5a8be6..2caa63fa 100644 --- a/docs/components/connection.md +++ b/docs/components/connection.md @@ -16,6 +16,7 @@ db_pool: Final = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def main() -> None: connection = await db_pool.connection() ``` @@ -24,6 +25,7 @@ async def main() -> None: ```python from psqlpy import connect + async def main() -> None: db_connection: Final = await connect( dsn="postgres://postgres:postgres@localhost:5432/postgres", @@ -39,6 +41,7 @@ db_pool: Final = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def main() -> None: async with db_pool.acquire() as connection: # connection is valid here @@ -197,6 +200,7 @@ async def main() -> None: ```python from psqlpy import IsolationLevel, ReadVariant + async def main() -> None: ... connection = await db_pool.connection() @@ -236,6 +240,7 @@ Prepare statement and return new instance. ```python from psqlpy import IsolationLevel, ReadVariant + async def main() -> None: ... connection = await db_pool.connection() diff --git a/docs/components/copy.md b/docs/components/copy.md index fafd2fe0..ae7ec143 100644 --- a/docs/components/copy.md +++ b/docs/components/copy.md @@ -75,12 +75,13 @@ This is the ergonomic alternative to `binary_copy_to_table` when you have Python ```python from datetime import datetime, timezone + async def main() -> None: ... connection = await db_pool.connection() records = [ - (1, "alpha", 1.5, datetime(2026, 1, 1, tzinfo=timezone.utc)), - (2, "beta", 2.25, datetime(2026, 1, 2, tzinfo=timezone.utc)), + (1, "alpha", 1.5, datetime(2026, 1, 1, tzinfo=timezone.utc)), + (2, "beta", 2.25, datetime(2026, 1, 2, tzinfo=timezone.utc)), (3, "gamma", None, datetime(2026, 1, 3, tzinfo=timezone.utc)), ] inserted = await connection.copy_records_to_table( @@ -94,12 +95,13 @@ async def main() -> None: ```python from datetime import datetime, timezone + async def main() -> None: ... connection = await db_pool.connection() records = [ - (1, "alpha", 1.5, datetime(2026, 1, 1, tzinfo=timezone.utc)), - (2, "beta", 2.25, datetime(2026, 1, 2, tzinfo=timezone.utc)), + (1, "alpha", 1.5, datetime(2026, 1, 1, tzinfo=timezone.utc)), + (2, "beta", 2.25, datetime(2026, 1, 2, tzinfo=timezone.utc)), (3, "gamma", None, datetime(2026, 1, 3, tzinfo=timezone.utc)), ] async with connection.transaction() as transaction: diff --git a/docs/components/cursor.md b/docs/components/cursor.md index f8c2fbd3..c066cf8d 100644 --- a/docs/components/cursor.md +++ b/docs/components/cursor.md @@ -22,6 +22,7 @@ Cursor can be used in different ways. ```python from psqlpy import ConnectionPool, QueryResult + async def main() -> None: db_pool = ConnectionPool() connection = await db_pool.connection() @@ -38,6 +39,7 @@ async def main() -> None: ```python from psqlpy import ConnectionPool, QueryResult + async def main() -> None: db_pool = ConnectionPool() connection = await db_pool.connection() @@ -54,6 +56,7 @@ async def main() -> None: ```python from psqlpy import ConnectionPool, QueryResult + async def main() -> None: db_pool = ConnectionPool() connection = await db_pool.connection() @@ -70,6 +73,7 @@ async def main() -> None: ```python from psqlpy import ConnectionPool, QueryResult + async def main() -> None: db_pool = ConnectionPool() connection = await db_pool.connection() diff --git a/docs/components/listener.md b/docs/components/listener.md index 000067ac..ba423975 100644 --- a/docs/components/listener.md +++ b/docs/components/listener.md @@ -21,6 +21,7 @@ db_pool = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def test_channel_callback( connection: Connection, payload: str, @@ -30,6 +31,7 @@ async def test_channel_callback( # do some important staff ... + async def main() -> None: # Create listener object listener: Listener = db_pool.listener() @@ -66,6 +68,7 @@ db_pool = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def main() -> None: # Create listener object listener: Listener = db_pool.listener() @@ -127,13 +130,13 @@ Callback signature is like this: ```python from psqlpy import Connection + async def callback( connection: Connection, payload: str, channel: str, process_id: int, -) -> None: - ... +) -> None: ... ``` Parameters for callback are based like `args`, so this signature is correct to: @@ -141,8 +144,7 @@ Parameters for callback are based like `args`, so this signature is correct to: async def callback( connection: Connection, *args, -) -> None: - ... +) -> None: ... ``` **Example:** @@ -152,8 +154,8 @@ async def test_channel_callback( payload: str, channel: str, process_id: int, -) -> None: - ... +) -> None: ... + async def main() -> None: listener = db_pool.listener() diff --git a/docs/components/prepared_statement.md b/docs/components/prepared_statement.md index ae38f682..336987fb 100644 --- a/docs/components/prepared_statement.md +++ b/docs/components/prepared_statement.md @@ -16,6 +16,7 @@ db_pool: Final = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def main() -> None: connection = await db_pool.connection() prepared_stmt = await connection.prepare( @@ -34,6 +35,7 @@ db_pool: Final = ConnectionPool( dsn="postgres://postgres:postgres@localhost:5432/postgres", ) + async def main() -> None: connection = await db_pool.connection() prepared_stmt: PreparedStatement = await connection.prepare( diff --git a/docs/components/transaction.md b/docs/components/transaction.md index d80c9182..06b3bfe0 100644 --- a/docs/components/transaction.md +++ b/docs/components/transaction.md @@ -334,7 +334,6 @@ async def main() -> None: ), ] ) - ``` ### Create Savepoint @@ -424,7 +423,7 @@ async def main() -> None: async for fetched_result in cursor: dict_result: List[Dict[Any, Any]] = fetched_result.result() - ... # do something with the result. + ... # do something with the result. ``` ### COPY FROM STDIN diff --git a/docs/faq.md b/docs/faq.md index a6b04bcb..d4e64a28 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -12,6 +12,7 @@ The main problem is PostgreSQL expects `LIMIT` and `OFFSET` to be BIGINT type bu from psqlpy import ConnectionPool from psqlpy.extra_types import BigInt + # --- Incorrect --- async def main() -> None: pool = ConnectionPool() @@ -37,6 +38,7 @@ Instead of using `WHERE IN ()` clause you must use `WHERE = ANY( ```python from psqlpy import ConnectionPool + # --- Incorrect --- async def main() -> None: pool = ConnectionPool() @@ -72,6 +74,7 @@ For example, when we want to make `WHERE` clause with `ANY` and string values, w from psqlpy import ConnectionPool from psqlpy.extra_types import TextArray + # --- Incorrect --- async def main() -> None: pool = ConnectionPool() @@ -105,6 +108,7 @@ The main problem that we cannot determine the type of the empty sequence passed from psqlpy import ConnectionPool from psqlpy.extra_types import VarCharArray + # --- Incorrect --- async def main() -> None: pool = ConnectionPool() diff --git a/docs/usage/frameworks/aiohttp.md b/docs/usage/frameworks/aiohttp.md index 6084bb5d..3895b93f 100644 --- a/docs/usage/frameworks/aiohttp.md +++ b/docs/usage/frameworks/aiohttp.md @@ -47,10 +47,9 @@ async def pg_pool_example(request: web.Request): application = web.Application() application.on_startup.append(start_db_pool) -application.add_routes([web.get('/', pg_pool_example)]) +application.add_routes([web.get("/", pg_pool_example)]) if __name__ == "__main__": web.run_app(application) - ``` diff --git a/docs/usage/frameworks/litestar.md b/docs/usage/frameworks/litestar.md index e4ca8aea..fe779469 100644 --- a/docs/usage/frameworks/litestar.md +++ b/docs/usage/frameworks/litestar.md @@ -61,5 +61,4 @@ if __name__ == "__main__": uvicorn.run( "start_example:app", ) - ``` diff --git a/docs/usage/frameworks/panther.md b/docs/usage/frameworks/panther.md index 35d25ced..9620b1fd 100644 --- a/docs/usage/frameworks/panther.md +++ b/docs/usage/frameworks/panther.md @@ -41,7 +41,7 @@ async def pg_pool_example(): return Response(data=query_result.result()) -app = Panther(__name__, configs=__name__, urls={'/': pg_pool_example}) +app = Panther(__name__, configs=__name__, urls={"/": pg_pool_example}) if __name__ == "__main__": uvicorn.run(app) diff --git a/docs/usage/row_factories/row_factories.md b/docs/usage/row_factories/row_factories.md index 564f312f..9cf12a21 100644 --- a/docs/usage/row_factories/row_factories.md +++ b/docs/usage/row_factories/row_factories.md @@ -18,6 +18,7 @@ class ValidationTestModel: id: int name: str + def to_class( class_: Type[ValidationTestModel], ) -> Callable[[Dict[str, Any]], ValidationTestModel]: @@ -26,6 +27,7 @@ def to_class( return to_class_inner + async def main() -> None: conn_result = await psql_pool.execute( querystring=f"SELECT * FROM {table_name}", diff --git a/docs/usage/types/array_types.md b/docs/usage/types/array_types.md index 06fd80ff..4b2e250a 100644 --- a/docs/usage/types/array_types.md +++ b/docs/usage/types/array_types.md @@ -54,6 +54,6 @@ async def main() -> None: querystring="SELECT * FROM users WHERE name = ANY($1)", parameters=[ TextArray(["Alex", "Dev", "Who"]), - ] + ], ) ``` diff --git a/docs/usage/types/extra_types.md b/docs/usage/types/extra_types.md index a97e8560..2ec763a0 100644 --- a/docs/usage/types/extra_types.md +++ b/docs/usage/types/extra_types.md @@ -65,7 +65,13 @@ async def main() -> None: async with db_pool.acquire() as connection: await connection.execute( "INSERT INTO numbers (index, elf_life, elon_musk_money) VALUES ($1, $2, $3, $4, $5)", - [SmallInt(101), Integer(10500), BigInt(300000000000), Float32(123.11), Float64(222.12)], + [ + SmallInt(101), + Integer(10500), + BigInt(300000000000), + Float32(123.11), + Float64(222.12), + ], ) ``` @@ -119,7 +125,7 @@ my_dict = { ], "with": { "nested": "values", - } + }, } ``` On the other side, if you want to set list of values to JSON/JSONB field, you must wrap it in `PyJSON`/`PyJSONB` type, otherwise `PSQLPy` will assume that you passed an array (PostgreSQL `ARRAY`). @@ -150,8 +156,11 @@ async def main() -> None: dict_for_jsonb_field = { "regular": "dict", "with": [ - "list", "of", "values", 100, - ] + "list", + "of", + "values", + 100, + ], } async with db_pool.acquire() as connection: @@ -161,7 +170,9 @@ async def main() -> None: ) await connection.execute( "INSERT INTO users (additional_user_info) VALUES ($1)", - [dict_for_jsonb_field,], + [ + dict_for_jsonb_field, + ], ) ``` diff --git a/python/psqlpy/extra_types.py b/python/psqlpy/extra_types.py index dc3df5e3..484bf016 100644 --- a/python/psqlpy/extra_types.py +++ b/python/psqlpy/extra_types.py @@ -53,7 +53,6 @@ "JSONB", "BigInt", "BoolArray", - "BoolArray", "Box", "BoxArray", "Circle", @@ -73,8 +72,6 @@ "IntervalArray", "IpAddressArray", "JSONArray", - "JSONArray", - "JSONBArray", "JSONBArray", "Line", "LineArray", @@ -97,7 +94,6 @@ "TextArray", "TimeArray", "UUIDArray", - "UUIDArray", "VarChar", "VarCharArray", ]