Skip to content

Commit 6586f99

Browse files
authored
Merge pull request #114 from psqlpy-python/feature/names_refactor
Renamed classes, removed Py prefix
2 parents 1ae5e30 + 08e8371 commit 6586f99

File tree

7 files changed

+290
-294
lines changed

7 files changed

+290
-294
lines changed

docs/usage/types/extra_types.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ All extra types available from Python with mapping to PostgreSQL type and Rust t
1212
| SmallInt | SmallInt | i16 |
1313
| Float32 | FLOAT4 | f32 |
1414
| Float64 | FLOAT8 | f64 |
15-
| PyVarChar | VarChar | String |
16-
| PyText | Text | String |
17-
| PyJSON | JSON | serde::Value |
18-
| PyJSONB | JSONB | serde::Value |
19-
| PyMacAddr6 | MacAddr | MacAddr6 |
20-
| PyMacAddr8 | MacAddr8 | MacAddr8 |
21-
| PyPoint | Point | Point |
22-
| PyBox | Rect | Box |
23-
| PyPath | LineString | Path |
24-
| PyLine | LineSegment | Line |
25-
| PyLineSegment | LineSegment | Lseg |
26-
| PyCircle | Circle | Circle |
15+
| VarChar | VarChar | String |
16+
| Text | Text | String |
17+
| JSON | JSON | serde::Value |
18+
| JSONB | JSONB | serde::Value |
19+
| MacAddr6 | MacAddr | MacAddr6 |
20+
| MacAddr8 | MacAddr8 | MacAddr8 |
21+
| Point | Point | Point |
22+
| Box | Rect | Box |
23+
| Path | LineString | Path |
24+
| Line | LineSegment | Line |
25+
| LineSegment | LineSegment | Lseg |
26+
| Circle | Circle | Circle |
2727
| PgVector | Vector | Vector |
2828

2929
::: important
@@ -208,7 +208,7 @@ Let's assume we have table `geo_info` with all PostgreSQL geo types in the datab
208208
from typing import Final
209209

210210
from psqlpy import ConnectionPool, QueryResult
211-
from psqlpy.extra_types import PyPoint, PyBox, PyPath, PyLine, PyLineSegment, PyCircle
211+
from psqlpy.extra_types import Point, Box, Path, Line, LineSegment, Circle
212212

213213

214214
async def main() -> None:
@@ -218,12 +218,12 @@ async def main() -> None:
218218
await db_pool.execute(
219219
"INSERT INTO geo_info VALUES ($1, $2, $3, $4, $5, $6)",
220220
[
221-
PyPoint([1.5, 2]),
222-
PyBox([(1.7, 2.8), (9, 9)]),
223-
PyPath([(3.5, 3), (9, 9), (8, 8)]),
224-
PyLine([1, -2, 3]),
225-
PyLineSegment([(5.6, 3.1), (4, 5)]),
226-
PyCircle([5, 1.8, 10]),
221+
Point([1.5, 2]),
222+
Box([(1.7, 2.8), (9, 9)]),
223+
Path([(3.5, 3), (9, 9), (8, 8)]),
224+
Line([1, -2, 3]),
225+
LineSegment([(5.6, 3.1), (4, 5)]),
226+
Circle([5, 1.8, 10]),
227227
],
228228
)
229229

docs/usage/types/supported_types.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Here you can find all types supported by `PSQLPy`. If PSQLPy isn't `-`, you can
1111
| bool | - | BOOL |
1212
| bytes | - | BYTEA |
1313
| str | - | VARCHAR |
14-
| str | PyVarChar | VARCHAR |
15-
| str | PyText | TEXT |
14+
| str | VarChar | VARCHAR |
15+
| str | Text | TEXT |
1616
| str | - | XML |
1717
| int | SmallInt | SMALLINT |
1818
| int | INTEGER | INTEGER |
@@ -28,20 +28,20 @@ Here you can find all types supported by `PSQLPy`. If PSQLPy isn't `-`, you can
2828
| datetime.timedelta | - | INTERVAL |
2929
| UUID | - | UUID |
3030
| dict | - | JSONB |
31-
| dict | PyJSONB | JSONB |
32-
| dict | PyJSON | JSON |
33-
| Mac Address 6 | PyMacAddr6 | MacAddr |
34-
| Mac Address 8 | PyMacAddr8 | MacAddr |
31+
| dict | JSONB | JSONB |
32+
| dict | JSON | JSON |
33+
| Mac Address 6 | MacAddr6 | MacAddr |
34+
| Mac Address 8 | MacAddr8 | MacAddr |
3535
| IPv4Address | - | INET |
3636
| IPv6Address | - | INET |
3737
| decimal.Decimal | - | NUMERIC |
3838
| int/str | Money | MONEY |
39-
| Point | PyPoint | POINT |
40-
| Box | PyBox | BOX |
41-
| Path | PyPath | PATH |
42-
| Line | PyLine | LINE |
43-
| Line Segment | PyLineSegment | LSEG |
44-
| Circle | PyCircle | CIRCLE |
39+
| Point | Point | POINT |
40+
| Box | Box | BOX |
41+
| Path | Path | PATH |
42+
| Line | Line | LINE |
43+
| Line Segment | LineSegment | LSEG |
44+
| Circle | Circle | CIRCLE |
4545
| PgVector | PgVector | Vector |
4646

4747
::: important

python/psqlpy/_internal/extra_types.pyi

+32-32
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Float64:
6666
- `inner_value`: float object.
6767
"""
6868

69-
class PyVarChar:
69+
class VarChar:
7070
"""Represent VarChar in PostgreSQL and String in Rust."""
7171

7272
def __init__(self: Self, inner_value: str) -> None:
@@ -78,7 +78,7 @@ class PyVarChar:
7878
- `inner_value`: str object.
7979
"""
8080

81-
class PyText:
81+
class Text:
8282
"""Represent TEXT in PostgreSQL and String ins Rust."""
8383

8484
def __init__(self: Self, inner_value: str) -> None:
@@ -90,7 +90,7 @@ class PyText:
9090
- `inner_value`: str object.
9191
"""
9292

93-
class PyJSONB:
93+
class JSONB:
9494
"""Represent JSONB field in PostgreSQL and Value in Rust."""
9595

9696
def __init__(
@@ -105,7 +105,7 @@ class PyJSONB:
105105
- `value`: value for the JSONB field.
106106
"""
107107

108-
class PyJSON:
108+
class JSON:
109109
"""Represent JSON field in PostgreSQL and Value in Rust."""
110110

111111
def __init__(
@@ -120,7 +120,7 @@ class PyJSON:
120120
- `value`: value for the JSONB field.
121121
"""
122122

123-
class PyMacAddr6:
123+
class MacAddr6:
124124
"""Represents MACADDR in PostgreSQL."""
125125

126126
def __init__(self, value: str) -> None:
@@ -130,7 +130,7 @@ class PyMacAddr6:
130130
- `value`: value for MACADDR field.
131131
"""
132132

133-
class PyMacAddr8:
133+
class MacAddr8:
134134
"""Represents MACADDR8 in PostgreSQL."""
135135

136136
def __init__(self, value: str) -> None:
@@ -140,19 +140,19 @@ class PyMacAddr8:
140140
- `value`: value for MACADDR8 field.
141141
"""
142142

143-
class PyCustomType:
143+
class CustomType:
144144
def __init__(self, value: bytes) -> None: ...
145145

146146
Coordinates: TypeAlias = list[int | float] | set[int | float] | tuple[int | float, int | float]
147147
PairsOfCoordinates: TypeAlias = (
148148
list[Coordinates | int | float] | set[Coordinates | int | float] | tuple[Coordinates | int | float, ...]
149149
)
150150

151-
class PyPoint:
151+
class Point:
152152
"""Represent point field in PostgreSQL and Point in Rust."""
153153

154154
def __init__(self: Self, value: Coordinates) -> None:
155-
"""Create new instance of PyPoint.
155+
"""Create new instance of Point.
156156
157157
It accepts any pair(List, Tuple or Set)
158158
of int/float numbers in every combination.
@@ -161,11 +161,11 @@ class PyPoint:
161161
- `value`: pair of int/float numbers in every combination.
162162
"""
163163

164-
class PyBox:
164+
class Box:
165165
"""Represent box field in PostgreSQL and Rect in Rust."""
166166

167167
def __init__(self: Self, value: PairsOfCoordinates) -> None:
168-
"""Create new instance of PyBox.
168+
"""Create new instance of Box.
169169
170170
You need to pass any of this structures:
171171
- sequence(List, Tuple or Set) of two sequences(List, Tuple or Set),
@@ -177,11 +177,11 @@ class PyBox:
177177
of int/float numbers in every combination.
178178
"""
179179

180-
class PyPath:
180+
class Path:
181181
"""Represent path field in PostgreSQL and LineString in Rust."""
182182

183183
def __init__(self: Self, value: PairsOfCoordinates) -> None:
184-
"""Create new instance of PyPath.
184+
"""Create new instance of Path.
185185
186186
You need to pass any of this structures:
187187
- sequence(List, Tuple or Set) of sequences(List, Tuple or Set),
@@ -193,11 +193,11 @@ class PyPath:
193193
- `value`: any valid structure with int/float numbers in every combination.
194194
"""
195195

196-
class PyLine:
196+
class Line:
197197
"""Represent line field in PostgreSQL and LineSegment in Rust."""
198198

199199
def __init__(self: Self, value: PairsOfCoordinates) -> None:
200-
"""Create new instance of PyLine.
200+
"""Create new instance of Line.
201201
202202
You need to pass any of this structures:
203203
- sequence of three int/float numbers(a, b, c)
@@ -206,11 +206,11 @@ class PyLine:
206206
- `value`: any valid structure with int/float numbers.
207207
"""
208208

209-
class PyLineSegment:
209+
class LineSegment:
210210
"""Represent lseg field in PostgreSQL and LineSegment in Rust."""
211211

212212
def __init__(self: Self, value: PairsOfCoordinates) -> None:
213-
"""Create new instance of PyLineSegment.
213+
"""Create new instance of LineSegment.
214214
215215
You need to pass any of this structures:
216216
- sequence(List, Tuple or Set) of two sequences(List, Tuple or Set),
@@ -222,14 +222,14 @@ class PyLineSegment:
222222
- `value`: any valid structure with int/float numbers in every combination.
223223
"""
224224

225-
class PyCircle:
225+
class Circle:
226226
"""Represent circle field in PostgreSQL and Circle in Rust."""
227227

228228
def __init__(
229229
self: Self,
230230
value: list[int | float] | set[int | float] | tuple[int | float, int | float, int | float],
231231
) -> None:
232-
"""Create new instance of PyCircle.
232+
"""Create new instance of Circle.
233233
234234
You need to pass any of this structures:
235235
- sequence of three int/float numbers(x, y, r)
@@ -390,9 +390,9 @@ class JSONBArray:
390390
self: Self,
391391
inner: typing.Sequence[
392392
dict[str, typing.Any]
393-
| PyJSONB
393+
| JSONB
394394
| typing.Sequence[dict[str, typing.Any]]
395-
| typing.Sequence[PyJSONB]
395+
| typing.Sequence[JSONB]
396396
| typing.Sequence[typing.Any]
397397
],
398398
) -> None:
@@ -409,9 +409,9 @@ class JSONArray:
409409
self: Self,
410410
inner: typing.Sequence[
411411
dict[str, typing.Any]
412-
| PyJSON
412+
| JSON
413413
| typing.Sequence[dict[str, typing.Any]]
414-
| typing.Sequence[PyJSON]
414+
| typing.Sequence[JSON]
415415
| typing.Sequence[typing.Any]
416416
],
417417
) -> None:
@@ -478,7 +478,7 @@ class MacAddr6Array:
478478

479479
def __init__(
480480
self: Self,
481-
inner: typing.Sequence[PyMacAddr6 | typing.Sequence[PyMacAddr6] | typing.Any,],
481+
inner: typing.Sequence[MacAddr6 | typing.Sequence[MacAddr6] | typing.Any,],
482482
) -> None:
483483
"""Create new instance of MacAddr6Array.
484484
@@ -491,7 +491,7 @@ class MacAddr8Array:
491491

492492
def __init__(
493493
self: Self,
494-
inner: typing.Sequence[PyMacAddr8 | typing.Sequence[PyMacAddr8] | typing.Any,],
494+
inner: typing.Sequence[MacAddr8 | typing.Sequence[MacAddr8] | typing.Any,],
495495
) -> None:
496496
"""Create new instance of MacAddr8Array.
497497
@@ -517,7 +517,7 @@ class PointArray:
517517

518518
def __init__(
519519
self: Self,
520-
inner: typing.Sequence[PyPoint | typing.Sequence[PyPoint] | typing.Any,],
520+
inner: typing.Sequence[Point | typing.Sequence[Point] | typing.Any,],
521521
) -> None:
522522
"""Create new instance of PointArray.
523523
@@ -530,20 +530,20 @@ class BoxArray:
530530

531531
def __init__(
532532
self: Self,
533-
inner: typing.Sequence[PyBox | typing.Sequence[PyBox] | typing.Any,],
533+
inner: typing.Sequence[Box | typing.Sequence[Box] | typing.Any,],
534534
) -> None:
535535
"""Create new instance of BoxArray.
536536
537537
### Parameters:
538-
- `inner`: inner value, sequence of PyBox values.
538+
- `inner`: inner value, sequence of Box values.
539539
"""
540540

541541
class PathArray:
542542
"""Represent PATH ARRAY in PostgreSQL."""
543543

544544
def __init__(
545545
self: Self,
546-
inner: typing.Sequence[PyPath | typing.Sequence[PyPath] | typing.Any,],
546+
inner: typing.Sequence[Path | typing.Sequence[Path] | typing.Any,],
547547
) -> None:
548548
"""Create new instance of PathArray.
549549
@@ -556,7 +556,7 @@ class LineArray:
556556

557557
def __init__(
558558
self: Self,
559-
inner: typing.Sequence[PyLine | typing.Sequence[PyLine] | typing.Any,],
559+
inner: typing.Sequence[Line | typing.Sequence[Line] | typing.Any,],
560560
) -> None:
561561
"""Create new instance of LineArray.
562562
@@ -569,7 +569,7 @@ class LsegArray:
569569

570570
def __init__(
571571
self: Self,
572-
inner: typing.Sequence[PyLineSegment | typing.Sequence[PyLineSegment] | typing.Any,],
572+
inner: typing.Sequence[LineSegment | typing.Sequence[LineSegment] | typing.Any,],
573573
) -> None:
574574
"""Create new instance of LsegArray.
575575
@@ -582,7 +582,7 @@ class CircleArray:
582582

583583
def __init__(
584584
self: Self,
585-
inner: typing.Sequence[PyCircle | typing.Sequence[PyCircle] | typing.Any,],
585+
inner: typing.Sequence[Circle | typing.Sequence[Circle] | typing.Any,],
586586
) -> None:
587587
"""Create new instance of CircleArray.
588588

0 commit comments

Comments
 (0)