Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 1, 2024
1 parent 0e0cf33 commit 2a8f27d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
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
12 changes: 5 additions & 7 deletions src/pg_purepy/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,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
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

0 comments on commit 2a8f27d

Please sign in to comment.