sqlalchemy-postgres-point 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sqlalchemy-postgres-point
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Lightweight SQLAlchemy custom type for PostgreSQL POINT columns with tuple binding and an earth-distance comparator.
5
5
  Keywords: sqlalchemy,postgresql,point,geometry,geospatial,gis,database,types,earthdistance
6
6
  Author: Michael Bianco
@@ -46,7 +46,7 @@ from sqlalchemy_postgres_point import PointType
46
46
 
47
47
 
48
48
  class Base(DeclarativeBase):
49
- pass
49
+ pass
50
50
 
51
51
 
52
52
  class Place(Base):
@@ -55,6 +55,7 @@ class Place(Base):
55
55
  # Store as (longitude, latitude)
56
56
  location = Column(PointType)
57
57
 
58
+
58
59
  # Example query using the custom comparator
59
60
  from sqlalchemy import select
60
61
 
@@ -80,14 +81,15 @@ Revises: your_previous_revision
80
81
  Create Date: 2025-01-XX XX:XX:XX.XXXXXX
81
82
 
82
83
  """
84
+
83
85
  from typing import Sequence, Union
84
86
 
85
87
  from alembic import op
86
88
  import sqlalchemy as sa
87
89
 
88
90
  # revision identifiers, used by Alembic.
89
- revision: str = 'your_revision_id'
90
- down_revision: Union[str, None] = 'your_previous_revision'
91
+ revision: str = "your_revision_id"
92
+ down_revision: Union[str, None] = "your_previous_revision"
91
93
  branch_labels: Union[str, Sequence[str], None] = None
92
94
  depends_on: Union[str, Sequence[str], None] = None
93
95
 
@@ -118,15 +120,16 @@ Values are loaded as a 2-tuple of floats `(lng, lat)` or `None` when NULL.
118
120
 
119
121
  ## Alembic Integration
120
122
 
121
- To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`:
123
+ To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`. This must be added to **both** `run_migrations_online` and `run_migrations_offline`:
122
124
 
123
125
  ```python
124
- from sqlalchemy_postgres_point.alembic_integration import render_item
126
+ from sqlalchemy_postgres_point.alembic_integration import (
127
+ render_item as render_point_item,
128
+ )
125
129
 
126
- # in run_migrations_online and run_migrations_offline:
127
130
  context.configure(
128
131
  # ... other options ...
129
- render_item=render_item,
132
+ render_item=render_point_item,
130
133
  )
131
134
  ```
132
135
 
@@ -134,17 +137,26 @@ Once wired up, `from sqlalchemy_postgres_point import PointType` will be automat
134
137
 
135
138
  ### Chaining `render_item`
136
139
 
137
- It's insane to me, but you have to chain multiple `render_item` instances you may have yourself.
140
+ If you need to combine this with other packages that also provide a `render_item`, chain them:
138
141
 
139
142
  ```python
140
- from sqlalchemy_postgres_point.alembic_integration import render_item as render_point
143
+ from sqlalchemy_postgres_point.alembic_integration import (
144
+ render_item as render_point_item,
145
+ )
146
+
141
147
 
142
148
  def render_item(type_, obj, autogen_context):
143
149
  return (
144
- render_point(type_, obj, autogen_context)
150
+ render_point_item(type_, obj, autogen_context)
145
151
  or other_package.render_item(type_, obj, autogen_context)
146
152
  or False
147
153
  )
154
+
155
+
156
+ context.configure(
157
+ # ... other options ...
158
+ render_item=render_item,
159
+ )
148
160
  ```
149
161
 
150
162
  Or you could use something like [`some_fn`](https://funcy.readthedocs.io/en/stable/funcs.html#some_fn) to make this even cleaner.
@@ -34,7 +34,7 @@ from sqlalchemy_postgres_point import PointType
34
34
 
35
35
 
36
36
  class Base(DeclarativeBase):
37
- pass
37
+ pass
38
38
 
39
39
 
40
40
  class Place(Base):
@@ -43,6 +43,7 @@ class Place(Base):
43
43
  # Store as (longitude, latitude)
44
44
  location = Column(PointType)
45
45
 
46
+
46
47
  # Example query using the custom comparator
47
48
  from sqlalchemy import select
48
49
 
@@ -68,14 +69,15 @@ Revises: your_previous_revision
68
69
  Create Date: 2025-01-XX XX:XX:XX.XXXXXX
69
70
 
70
71
  """
72
+
71
73
  from typing import Sequence, Union
72
74
 
73
75
  from alembic import op
74
76
  import sqlalchemy as sa
75
77
 
76
78
  # revision identifiers, used by Alembic.
77
- revision: str = 'your_revision_id'
78
- down_revision: Union[str, None] = 'your_previous_revision'
79
+ revision: str = "your_revision_id"
80
+ down_revision: Union[str, None] = "your_previous_revision"
79
81
  branch_labels: Union[str, Sequence[str], None] = None
80
82
  depends_on: Union[str, Sequence[str], None] = None
81
83
 
@@ -106,15 +108,16 @@ Values are loaded as a 2-tuple of floats `(lng, lat)` or `None` when NULL.
106
108
 
107
109
  ## Alembic Integration
108
110
 
109
- To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`:
111
+ To ensure generated migration files include the correct `PointType` import, pass the provided `render_item` hook to `context.configure()` in your `alembic/env.py`. This must be added to **both** `run_migrations_online` and `run_migrations_offline`:
110
112
 
111
113
  ```python
112
- from sqlalchemy_postgres_point.alembic_integration import render_item
114
+ from sqlalchemy_postgres_point.alembic_integration import (
115
+ render_item as render_point_item,
116
+ )
113
117
 
114
- # in run_migrations_online and run_migrations_offline:
115
118
  context.configure(
116
119
  # ... other options ...
117
- render_item=render_item,
120
+ render_item=render_point_item,
118
121
  )
119
122
  ```
120
123
 
@@ -122,17 +125,26 @@ Once wired up, `from sqlalchemy_postgres_point import PointType` will be automat
122
125
 
123
126
  ### Chaining `render_item`
124
127
 
125
- It's insane to me, but you have to chain multiple `render_item` instances you may have yourself.
128
+ If you need to combine this with other packages that also provide a `render_item`, chain them:
126
129
 
127
130
  ```python
128
- from sqlalchemy_postgres_point.alembic_integration import render_item as render_point
131
+ from sqlalchemy_postgres_point.alembic_integration import (
132
+ render_item as render_point_item,
133
+ )
134
+
129
135
 
130
136
  def render_item(type_, obj, autogen_context):
131
137
  return (
132
- render_point(type_, obj, autogen_context)
138
+ render_point_item(type_, obj, autogen_context)
133
139
  or other_package.render_item(type_, obj, autogen_context)
134
140
  or False
135
141
  )
142
+
143
+
144
+ context.configure(
145
+ # ... other options ...
146
+ render_item=render_item,
147
+ )
136
148
  ```
137
149
 
138
150
  Or you could use something like [`some_fn`](https://funcy.readthedocs.io/en/stable/funcs.html#some_fn) to make this even cleaner.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sqlalchemy-postgres-point"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Lightweight SQLAlchemy custom type for PostgreSQL POINT columns with tuple binding and an earth-distance comparator."
5
5
  keywords = [
6
6
  "sqlalchemy",
@@ -21,7 +21,7 @@ urls = { "Repository" = "https://github.com/iloveitaly/sqlalchemy-postgres-point
21
21
 
22
22
 
23
23
  [build-system]
24
- requires = ["uv_build>=0.11.0,<0.12"]
24
+ requires = ["uv_build>=0.11.0,<0.13"]
25
25
  build-backend = "uv_build"
26
26
 
27
27
  [tool.uv.build-backend]
@@ -11,7 +11,6 @@ References:
11
11
 
12
12
  import math
13
13
  import re
14
- from typing import Tuple
15
14
 
16
15
  from sqlalchemy.types import Float, UserDefinedType
17
16
 
@@ -23,7 +22,7 @@ class PointType(UserDefinedType):
23
22
  return "POINT"
24
23
 
25
24
  @staticmethod
26
- def _validate_point(value: Tuple[float, float]) -> Tuple[float, float]:
25
+ def _validate_point(value: tuple[float, float]) -> tuple[float, float]:
27
26
  """Validate and normalize a (lng, lat) tuple.
28
27
 
29
28
  - Ensures it's a 2-length tuple/list