Skip to content

Commit c04b087

Browse files
committed
PostgresEngine now uses colored_warning instead of the stdlib's warning directly
1 parent a266633 commit c04b087

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

piccolo/engine/postgres.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import contextvars
33
from dataclasses import dataclass
44
import typing as t
5-
import warnings
65

76
import asyncpg # type: ignore
87
from asyncpg.connection import Connection # type: ignore
@@ -291,26 +290,28 @@ async def prep_database(self):
291290
# methods for now to ensure backwards compatility.
292291

293292
async def start_connnection_pool(self, **kwargs) -> None:
294-
warnings.warn(
295-
"This is a typo - please upgrade to `start_connection_pool`. This "
296-
"proxy method will be retired in the future."
293+
colored_warning(
294+
"`start_connnection_pool` is a typo - please change it to "
295+
"`start_connection_pool`.",
296+
category=DeprecationWarning,
297297
)
298298
return await self.start_connection_pool()
299299

300300
async def close_connnection_pool(self, **kwargs) -> None:
301-
warnings.warn(
302-
"This is a typo - please upgrade to `close_connection_pool`. This "
303-
"proxy method will be retired in the future."
301+
colored_warning(
302+
"`close_connnection_pool` is a typo - please change it to "
303+
"`close_connection_pool`.",
304+
category=DeprecationWarning,
304305
)
305306
return await self.close_connection_pool()
306307

307308
###########################################################################
308309

309310
async def start_connection_pool(self, **kwargs) -> None:
310311
if self.pool:
311-
warnings.warn(
312+
colored_warning(
312313
"A pool already exists - close it first if you want to create "
313-
"a new pool."
314+
"a new pool.",
314315
)
315316
else:
316317
config = dict(self.config)
@@ -322,7 +323,7 @@ async def close_connection_pool(self) -> None:
322323
await self.pool.close()
323324
self.pool = None
324325
else:
325-
warnings.warn("No pool is running.")
326+
colored_warning("No pool is running.")
326327

327328
###########################################################################
328329

0 commit comments

Comments
 (0)