Skip to content

Commit 2495cd4

Browse files
committed
Reformat docstring for create_pool() and connect()
1 parent 10955fd commit 2495cd4

File tree

2 files changed

+77
-53
lines changed

2 files changed

+77
-53
lines changed

asyncpg/connection.py

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ async def add_listener(self, channel, callback):
116116
"""Add a listener for Postgres notifications.
117117
118118
:param str channel: Channel to listen on.
119+
119120
:param callable callback:
120-
A callable receiving the following arguments:
121-
**connection**: a Connection the callback is registered with;
122-
**pid**: PID of the Postgres server that sent the notification;
123-
**channel**: name of the channel the notification was sent to;
124-
**payload**: the payload.
121+
A callable receiving the following arguments:
122+
**connection**: a Connection the callback is registered with;
123+
**pid**: PID of the Postgres server that sent the notification;
124+
**channel**: name of the channel the notification was sent to;
125+
**payload**: the payload.
125126
"""
126127
self._check_open()
127128
if channel not in self._listeners:
@@ -245,7 +246,7 @@ async def executemany(self, command: str, args,
245246
... ''', [(1, 2, 3), (4, 5, 6)])
246247
247248
:param command: Command to execute.
248-
:args: An iterable containing sequences of arguments.
249+
:param args: An iterable containing sequences of arguments.
249250
:param float timeout: Optional timeout value in seconds.
250251
:return None: This method discards the results of the operations.
251252
@@ -713,43 +714,52 @@ async def connect(dsn=None, *,
713714
714715
Returns a new :class:`~asyncpg.connection.Connection` object.
715716
716-
:param dsn: Connection arguments specified using as a single string in the
717-
following format:
718-
``postgres://user:pass@host:port/database?option=value``
717+
:param dsn:
718+
Connection arguments specified using as a single string in the
719+
following format:
720+
``postgres://user:pass@host:port/database?option=value``
719721
720-
:param host: database host address or a path to the directory containing
721-
database server UNIX socket (defaults to the default UNIX
722-
socket, or the value of the ``PGHOST`` environment variable,
723-
if set).
722+
:param host:
723+
database host address or a path to the directory containing
724+
database server UNIX socket (defaults to the default UNIX socket,
725+
or the value of the ``PGHOST`` environment variable, if set).
724726
725-
:param port: connection port number (defaults to ``5432``, or the value of
726-
the ``PGPORT`` environment variable, if set)
727+
:param port:
728+
connection port number (defaults to ``5432``, or the value of
729+
the ``PGPORT`` environment variable, if set)
727730
728-
:param user: the name of the database role used for authentication
729-
(defaults to the name of the effective user of the process
730-
making the connection, or the value of ``PGUSER`` environment
731-
variable, if set)
731+
:param user:
732+
the name of the database role used for authentication
733+
(defaults to the name of the effective user of the process
734+
making the connection, or the value of ``PGUSER`` environment
735+
variable, if set)
732736
733-
:param database: the name of the database (defaults to the value of
734-
``PGDATABASE`` environment variable, if set.)
737+
:param database:
738+
the name of the database (defaults to the value of ``PGDATABASE``
739+
environment variable, if set.)
735740
736-
:param password: password used for authentication
741+
:param password:
742+
password used for authentication
737743
738-
:param loop: An asyncio event loop instance. If ``None``, the default
739-
event loop will be used.
744+
:param loop:
745+
An asyncio event loop instance. If ``None``, the default
746+
event loop will be used.
740747
741-
:param float timeout: connection timeout in seconds.
748+
:param float timeout:
749+
connection timeout in seconds.
742750
743-
:param int statement_cache_size: the size of prepared statement LRU cache.
744-
Pass ``0`` to disable the cache.
751+
:param int statement_cache_size:
752+
the size of prepared statement LRU cache. Pass ``0`` to
753+
disable the cache.
745754
746755
:param int max_cached_statement_lifetime:
747756
the maximum time in seconds a prepared statement will stay
748757
in the cache. Pass ``0`` to allow statements be cached
749758
indefinitely.
750759
751-
:param float command_timeout: the default timeout for operations on
752-
this connection (the default is no timeout).
760+
:param float command_timeout:
761+
the default timeout for operations on this connection
762+
(the default is no timeout).
753763
754764
:return: A :class:`~asyncpg.connection.Connection` instance.
755765

asyncpg/pool.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -575,33 +575,47 @@ def create_pool(dsn=None, *,
575575
finally:
576576
await pool.release(con)
577577
578-
:param str dsn: Connection arguments specified using as a single string in
579-
the following format:
580-
``postgres://user:pass@host:port/database?option=value``.
581-
582-
:param \*\*connect_kwargs: Keyword arguments for the
583-
:func:`~asyncpg.connection.connect` function.
584-
:param int min_size: Number of connection the pool will be initialized
585-
with.
586-
:param int max_size: Max number of connections in the pool.
587-
:param int max_queries: Number of queries after a connection is closed
588-
and replaced with a new connection.
578+
:param str dsn:
579+
Connection arguments specified using as a single string in
580+
the following format:
581+
``postgres://user:pass@host:port/database?option=value``.
582+
583+
:param \*\*connect_kwargs:
584+
Keyword arguments for the :func:`~asyncpg.connection.connect`
585+
function.
586+
587+
:param int min_size:
588+
Number of connection the pool will be initialized with.
589+
590+
:param int max_size:
591+
Max number of connections in the pool.
592+
593+
:param int max_queries:
594+
Number of queries after a connection is closed and replaced
595+
with a new connection.
596+
589597
:param float max_inactive_connection_lifetime:
590598
Number of seconds after which inactive connections in the
591599
pool will be closed. Pass ``0`` to disable this mechanism.
592-
:param coroutine setup: A coroutine to prepare a connection right before
593-
it is returned from :meth:`~pool.Pool.acquire`.
594-
An example use case would be to automatically
595-
set up notifications listeners for all connections
596-
of a pool.
597-
:param coroutine init: A coroutine to initialize a connection when it
598-
is created. An example use case would be to setup
599-
type codecs with
600-
:meth:`~asyncpg.connection.Connection.\
601-
set_builtin_type_codec` or :meth:`~asyncpg.\
602-
connection.Connection.set_type_codec`.
603-
:param loop: An asyncio event loop instance. If ``None``, the default
604-
event loop will be used.
600+
601+
:param coroutine setup:
602+
A coroutine to prepare a connection right before it is returned
603+
from :meth:`Pool.acquire() <pool.Pool.acquire>`. An example use
604+
case would be to automatically set up notifications listeners for
605+
all connections of a pool.
606+
607+
:param coroutine init:
608+
A coroutine to initialize a connection when it is created.
609+
An example use case would be to setup type codecs with
610+
:meth:`Connection.set_builtin_type_codec() <\
611+
asyncpg.connection.Connection.set_builtin_type_codec>`
612+
or :meth:`Connection.set_type_codec() <\
613+
asyncpg.connection.Connection.set_type_codec>`.
614+
615+
:param loop:
616+
An asyncio event loop instance. If ``None``, the default
617+
event loop will be used.
618+
605619
:return: An instance of :class:`~asyncpg.pool.Pool`.
606620
607621
.. versionchanged:: 0.10.0

0 commit comments

Comments
 (0)