Skip to content

Commit ed3d963

Browse files
authored
Merge branch 'master' into cython3
2 parents a68e151 + 7f00484 commit ed3d963

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

.github/workflows/tests.yml

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ jobs:
5353
version_line_pattern: |
5454
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
5555
56+
- name: Setup PostgreSQL
57+
uses: tj-actions/install-postgresql@2a80e9368dff47cd05fee5bf3cf7d88f68c2f8e9 # v3.1.1
58+
if: steps.release.outputs.version == 0 && matrix.os == 'macos-latest'
59+
with:
60+
postgresql-version: 16
61+
5662
- name: Set up Python ${{ matrix.python-version }}
5763
uses: actions/setup-python@v4
5864
if: steps.release.outputs.version == 0

README.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ Basic Usage
8888
)
8989
await conn.close()
9090
91-
loop = asyncio.get_event_loop()
92-
loop.run_until_complete(run())
91+
asyncio.run(run())
9392
9493
9594
License

asyncpg/connection.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,8 @@ def add_query_logger(self, callback):
231231
232232
:param callable callback:
233233
A callable or a coroutine function receiving one argument:
234-
**record**: a LoggedQuery containing `query`, `args`, `timeout`,
235-
`elapsed`, `exception`, `conn_addr`, and
236-
`conn_params`.
234+
**record**, a LoggedQuery containing `query`, `args`, `timeout`,
235+
`elapsed`, `exception`, `conn_addr`, and `conn_params`.
237236
238237
.. versionadded:: 0.29.0
239238
"""
@@ -800,7 +799,7 @@ async def copy_from_table(self, table_name, *, output,
800799
... output='file.csv', format='csv')
801800
... print(result)
802801
...
803-
>>> asyncio.get_event_loop().run_until_complete(run())
802+
>>> asyncio.run(run())
804803
'COPY 100'
805804
806805
.. _`COPY statement documentation`:
@@ -869,7 +868,7 @@ async def copy_from_query(self, query, *args, output,
869868
... output='file.csv', format='csv')
870869
... print(result)
871870
...
872-
>>> asyncio.get_event_loop().run_until_complete(run())
871+
>>> asyncio.run(run())
873872
'COPY 10'
874873
875874
.. _`COPY statement documentation`:
@@ -945,7 +944,7 @@ async def copy_to_table(self, table_name, *, source,
945944
... 'mytable', source='datafile.tbl')
946945
... print(result)
947946
...
948-
>>> asyncio.get_event_loop().run_until_complete(run())
947+
>>> asyncio.run(run())
949948
'COPY 140000'
950949
951950
.. _`COPY statement documentation`:
@@ -1027,7 +1026,7 @@ async def copy_records_to_table(self, table_name, *, records,
10271026
... (2, 'ham', 'spam')])
10281027
... print(result)
10291028
...
1030-
>>> asyncio.get_event_loop().run_until_complete(run())
1029+
>>> asyncio.run(run())
10311030
'COPY 2'
10321031
10331032
Asynchronous record iterables are also supported:
@@ -1045,7 +1044,7 @@ async def copy_records_to_table(self, table_name, *, records,
10451044
... 'mytable', records=record_gen(100))
10461045
... print(result)
10471046
...
1048-
>>> asyncio.get_event_loop().run_until_complete(run())
1047+
>>> asyncio.run(run())
10491048
'COPY 100'
10501049
10511050
.. versionadded:: 0.11.0
@@ -1305,7 +1304,7 @@ async def set_type_codec(self, typename, *,
13051304
... print(result)
13061305
... print(datetime.datetime(2002, 1, 1) + result)
13071306
...
1308-
>>> asyncio.get_event_loop().run_until_complete(run())
1307+
>>> asyncio.run(run())
13091308
relativedelta(years=+2, months=+3, days=+1)
13101309
2004-04-02 00:00:00
13111310
@@ -1772,7 +1771,7 @@ async def reload_schema_state(self):
17721771
... await con.execute('LOCK TABLE tbl')
17731772
... await change_type(con)
17741773
...
1775-
>>> asyncio.get_event_loop().run_until_complete(run())
1774+
>>> asyncio.run(run())
17761775
17771776
.. versionadded:: 0.14.0
17781777
"""
@@ -1809,9 +1808,8 @@ def query_logger(self, callback):
18091808
18101809
:param callable callback:
18111810
A callable or a coroutine function receiving one argument:
1812-
**record**: a LoggedQuery containing `query`, `args`, `timeout`,
1813-
`elapsed`, `exception`, `conn_addr`, and
1814-
`conn_params`.
1811+
**record**, a LoggedQuery containing `query`, `args`, `timeout`,
1812+
`elapsed`, `exception`, `conn_addr`, and `conn_params`.
18151813
18161814
Example:
18171815
@@ -2258,7 +2256,7 @@ async def connect(dsn=None, *,
22582256
... types = await con.fetch('SELECT * FROM pg_type')
22592257
... print(types)
22602258
...
2261-
>>> asyncio.get_event_loop().run_until_complete(run())
2259+
>>> asyncio.run(run())
22622260
[<Record typname='bool' typnamespace=11 ...
22632261
22642262
.. versionadded:: 0.10.0

docs/api/index.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ a need to run the same query again.
3636
.. code-block:: pycon
3737
3838
>>> import asyncpg, asyncio
39-
>>> loop = asyncio.get_event_loop()
4039
>>> async def run():
4140
... conn = await asyncpg.connect()
4241
... stmt = await conn.prepare('''SELECT 2 ^ $1''')
4342
... print(await stmt.fetchval(10))
4443
... print(await stmt.fetchval(20))
4544
...
46-
>>> loop.run_until_complete(run())
45+
>>> asyncio.run(run())
4746
1024.0
4847
1048576.0
4948

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
with open(version_file, 'r') as f:
1212
for line in f:
13-
if line.startswith('__version__ ='):
13+
if line.startswith('__version__: typing.Final ='):
1414
_, _, version = line.partition('=')
1515
version = version.strip(" \n'\"")
1616
break

docs/usage.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ which provides methods to run queries and manage transactions.
4444
# Close the connection.
4545
await conn.close()
4646
47-
asyncio.get_event_loop().run_until_complete(main())
48-
47+
asyncio.run(main())
4948
5049
5150
.. note::
@@ -344,7 +343,7 @@ shows how to instruct asyncpg to use floats instead.
344343
finally:
345344
await conn.close()
346345
347-
asyncio.get_event_loop().run_until_complete(main())
346+
asyncio.run(main())
348347
349348
350349
Example: decoding hstore values
@@ -369,7 +368,7 @@ be registered on a connection using :meth:`Connection.set_builtin_type_codec()
369368
result = await conn.fetchval("SELECT 'a=>1,b=>2,c=>NULL'::hstore")
370369
assert result == {'a': '1', 'b': '2', 'c': None}
371370
372-
asyncio.get_event_loop().run_until_complete(run())
371+
asyncio.run(run())
373372
374373
.. _hstore: https://www.postgresql.org/docs/current/static/hstore.html
375374

tools/generate_type_map.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ def main():
124124
help='PostgreSQL server user')
125125

126126
args = parser.parse_args()
127-
128-
loop = asyncio.get_event_loop()
129-
130-
loop.run_until_complete(runner(args))
127+
asyncio.run(runner(args))
131128

132129

133130
if __name__ == '__main__':

0 commit comments

Comments
 (0)