Skip to content

Commit 6903eb5

Browse files
authored
Merge pull request #26 from qaspen-python/feature/add_macaddr_support
Added support for MacAddr6 type
2 parents ddaa491 + fa78e0e commit 6903eb5

File tree

16 files changed

+117
-16
lines changed

16 files changed

+117
-16
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ chrono-tz = "0.8.5"
2828
uuid = { version = "1.7.0", features = ["v4"] }
2929
serde_json = "1.0.113"
3030
futures-util = "0.3.30"
31+
macaddr = "1.0.1"

docs/examples/aiohttp/start_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from typing import Any, cast
44

55
from aiohttp import web
6+
67
from psqlpy import PSQLPool
78

89

docs/examples/fastapi/advanced_example.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import uvicorn
77
from fastapi import FastAPI
88
from fastapi.responses import JSONResponse
9+
910
from psqlpy import PSQLPool
1011

1112
db_pool = PSQLPool(

docs/examples/fastapi/start_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import uvicorn
66
from fastapi import Depends, FastAPI, Request
77
from fastapi.responses import JSONResponse
8-
from psqlpy import Connection, PSQLPool
98
from typing_extensions import Annotated
109

10+
from psqlpy import Connection, PSQLPool
11+
1112

1213
@asynccontextmanager
1314
async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
@@ -26,7 +27,7 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
2627

2728
async def db_connection(request: Request) -> Connection:
2829
"""Retrieve new connection from connection pool and return it."""
29-
return await (cast(PSQLPool, request.app.state.db_pool)).connection()
30+
return await cast(PSQLPool, request.app.state.db_pool).connection()
3031

3132

3233
@app.get("/")

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ profile = "black"
5353
multi_line_output = 3
5454

5555
[tool.black]
56-
line-length = 79
56+
line-length = 89
5757

5858
[tool.mypy]
5959
strict = true
@@ -113,7 +113,7 @@ ignore = [
113113
]
114114
exclude = [".venv/"]
115115
mccabe = { max-complexity = 10 }
116-
line-length = 79
116+
line-length = 89
117117

118118
[tool.ruff.per-file-ignores]
119119
"python/psqlpy/*" = ["PYI021"]

python/psqlpy/_internal/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ class Transaction:
535535
)
536536
537537
```
538-
""" # noqa: E501
538+
"""
539539
async def savepoint(self: Self, savepoint_name: str) -> None:
540540
"""Create new savepoint.
541541

python/psqlpy/_internal/extra_types.pyi

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,13 @@ class PyJSON:
6262
### Parameters:
6363
- `value`: value for the JSON/JSONB field.
6464
"""
65+
66+
class PyMacAddr6:
67+
"""Represents MACADDR in PostgreSQL."""
68+
69+
def __init__(self, value: str) -> None:
70+
"""Construct new MacAddr.
71+
72+
### Parameters:
73+
- `value`: value for MACADDR field.
74+
"""

python/psqlpy/extra_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
from ._internal.extra_types import BigInt, Integer, PyJSON, PyUUID, SmallInt
1+
from ._internal.extra_types import BigInt, Integer, PyJSON, PyMacAddr6, PyUUID, SmallInt
22

33
__all__ = [
44
"SmallInt",
55
"Integer",
66
"BigInt",
77
"PyUUID",
88
"PyJSON",
9+
"PyMacAddr6",
910
]

python/tests/test_cursor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ async def test_cursor_fetch_forward_all(
116116

117117
rest_results = await test_cursor.fetch_forward_all()
118118

119-
assert (
120-
len(rest_results.result())
121-
== number_database_records - default_fetch_number
122-
)
119+
assert len(rest_results.result()) == number_database_records - default_fetch_number
123120

124121

125122
async def test_cursor_fetch_backward(

0 commit comments

Comments
 (0)