Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #8

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.5.5
hooks:
- id: ruff
args: ["--preview", "--fix"]
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
0.11.0 (2024-04-12)
-------------------

- Switch to the ``whenever`` package for date/time types, instead of Arrow. See
- Switch to the ``whenever`` package for date/time types, instead of Arrow. See
https://dev.arie.bovenberg.net/blog/python-datetime-pitfalls/ for more information as to why.
- ``pg-purepy`` now passes Pyright strict mode.
- :class:`.Converter` is now a generic type.
Expand Down
2 changes: 1 addition & 1 deletion docs/conversion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Date/Time types

.. note::

I use Whenever over the vanilla ``datetime`` objects because I don't like ``datetime``. Write
I use Whenever over the vanilla ``datetime`` objects because I don't like ``datetime``. Write
your own converter if you disagree with me.

Enumeration types
Expand Down
19 changes: 9 additions & 10 deletions src/pg_purepy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import types
import warnings
from asyncio import lowlevel
from collections.abc import AsyncGenerator, AsyncIterator, Mapping
from contextlib import aclosing, asynccontextmanager
from os import PathLike, fspath
Expand Down Expand Up @@ -187,7 +188,7 @@ async def _read_until_ready(
"""

if self._protocol.ready:
await anyio.sleep(0)
await lowlevel.checkpoint()
return

while True:
Expand All @@ -210,7 +211,7 @@ async def _read_until_ready(
yield next_event

if isinstance(next_event, ReadyForQuery):
await anyio.sleep(0) # checkpoint()
await lowlevel.checkpoint() # checkpoint()
return

to_send = self._protocol.get_needed_synchronisation()
Expand Down Expand Up @@ -288,13 +289,11 @@ async def lowlevel_query(
if not self._protocol.ready:
await self.wait_until_ready()

simple_query = all(
(
not (params or kwargs),
not isinstance(query, PreparedStatementInfo),
max_rows is None,
)
)
simple_query = all((
not (params or kwargs),
not isinstance(query, PreparedStatementInfo),
max_rows is None,
))

logger.debug("Executing query", query=query)
if simple_query:
Expand Down Expand Up @@ -527,7 +526,7 @@ async def row_count(self) -> int:
"""

if self._row_count >= 0:
await anyio.sleep(0) # checkpoint
await lowlevel.checkpoint() # checkpoint
return self._row_count

async for _ in self:
Expand Down
2 changes: 1 addition & 1 deletion src/pg_purepy/conversion/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, oid: int, subconverter: Converter[T], quote_inner: bool = Fal
def from_postgres(self, context: ConversionContext, data: str) -> list[T]:
p = partial(self._subconverter.from_postgres, context)
return _parse_array(data, p)

@override
def to_postgres(self, context: ConversionContext, data: Iterable[T]) -> str:
converted = [
Expand Down
5 changes: 2 additions & 3 deletions src/pg_purepy/conversion/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def to_postgres(
context: ConversionContext,
data: PostgresTimestampTz,
) -> str:

match data:
case "infinity":
return "infinity"
Expand Down Expand Up @@ -85,14 +84,14 @@ def to_postgres(self, context: ConversionContext, data: PostgresTimestampWithout
# |---------------------|
# | 2021-07-13 22:16:36 |
# +---------------------+

match data:
case "infinity":
return data

case "-infinity":
return data

case whenever.NaiveDateTime():
return data.common_iso8601()

Expand Down
2 changes: 1 addition & 1 deletion src/pg_purepy/conversion/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pg_purepy.protocol import ConversionContext


class EnumConverter[T : Enum](Converter[T]):
class EnumConverter[T: Enum](Converter[T]):
"""
A converter that lets you use Python enums for PostgreSQL enums.
"""
Expand Down
Loading