psycopg-toolkit 0.1.7__tar.gz → 0.2.0__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.
Files changed (23) hide show
  1. psycopg_toolkit-0.2.0/.gitignore +167 -0
  2. psycopg_toolkit-0.2.0/.vscode/settings.json +27 -0
  3. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/PKG-INFO +96 -23
  4. psycopg_toolkit-0.1.7/docs/readme.md → psycopg_toolkit-0.2.0/README.md +78 -8
  5. psycopg_toolkit-0.2.0/pyproject.toml +194 -0
  6. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/__init__.py +27 -13
  7. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/core/__init__.py +2 -0
  8. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/core/config.py +23 -26
  9. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/core/database.py +56 -33
  10. psycopg_toolkit-0.2.0/src/psycopg_toolkit/core/factory.py +25 -0
  11. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/core/transaction.py +26 -23
  12. psycopg_toolkit-0.2.0/src/psycopg_toolkit/exceptions.py +96 -0
  13. psycopg_toolkit-0.2.0/src/psycopg_toolkit/repositories/__init__.py +3 -0
  14. psycopg_toolkit-0.2.0/src/psycopg_toolkit/repositories/base.py +593 -0
  15. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/utils/__init__.py +1 -1
  16. psycopg_toolkit-0.2.0/src/psycopg_toolkit/utils/json_handler.py +111 -0
  17. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/src/psycopg_toolkit/utils/psychopg_helper.py +23 -61
  18. psycopg_toolkit-0.2.0/src/psycopg_toolkit/utils/type_inspector.py +200 -0
  19. psycopg_toolkit-0.1.7/pyproject.toml +0 -55
  20. psycopg_toolkit-0.1.7/src/psycopg_toolkit/exceptions.py +0 -48
  21. psycopg_toolkit-0.1.7/src/psycopg_toolkit/repositories/__init__.py +0 -5
  22. psycopg_toolkit-0.1.7/src/psycopg_toolkit/repositories/base.py +0 -363
  23. {psycopg_toolkit-0.1.7 → psycopg_toolkit-0.2.0}/LICENSE +0 -0
@@ -0,0 +1,167 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ .idea/
163
+
164
+ .claude/claudeignore
165
+
166
+
167
+
@@ -0,0 +1,27 @@
1
+ {
2
+ "terminal.integrated.env.osx": {
3
+ "PYTHONPATH": "${workspaceFolder}/src"
4
+ },
5
+ "terminal.integrated.env.linux": {
6
+ "PYTHONPATH": "${workspaceFolder}/src"
7
+ },
8
+ "terminal.integrated.env.windows": {
9
+ "PYTHONPATH": "${workspaceFolder}/src"
10
+ },
11
+ "python.envFile": "${workspaceFolder}/.env",
12
+ "python.testing.pytestEnabled": true,
13
+ "python.testing.unittestEnabled": false,
14
+ "python.testing.pytestArgs": [
15
+ "tests",
16
+ "-v",
17
+ "-s",
18
+ "--tb=short"
19
+ ],
20
+ "python.testing.unittestArgs": [
21
+ "-v",
22
+ "-s",
23
+ "./tests",
24
+ "-p",
25
+ "test_*.py"
26
+ ]
27
+ }
@@ -1,13 +1,18 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: psycopg-toolkit
3
- Version: 0.1.7
3
+ Version: 0.2.0
4
4
  Summary: A Python PostgreSQL database utility with connection pooling
5
+ Project-URL: Homepage, https://github.com/descoped/psycopg-toolkit
6
+ Project-URL: Repository, https://github.com/descoped/psycopg-toolkit
7
+ Project-URL: Documentation, https://github.com/descoped/psycopg-toolkit/tree/master/docs
8
+ Project-URL: Issues, https://github.com/descoped/psycopg-toolkit/issues
9
+ Author-email: Ove Ranheim <oranheim@gmail.com>
5
10
  License: MIT
6
- Keywords: postgresql,database,async,pool,psycopg
7
- Author: Ove Ranheim
8
- Author-email: oranheim@gmail.com
9
- Requires-Python: >=3.11,<4.0
10
- Classifier: Development Status :: 3 - Alpha
11
+ License-File: LICENSE
12
+ Keywords: async,database,jsonb,pool,postgresql,psycopg,repository-pattern
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Framework :: AsyncIO
15
+ Classifier: Framework :: Pydantic :: 2
11
16
  Classifier: Intended Audience :: Developers
12
17
  Classifier: License :: OSI Approved :: MIT License
13
18
  Classifier: Operating System :: OS Independent
@@ -16,19 +21,24 @@ Classifier: Programming Language :: Python :: 3.11
16
21
  Classifier: Programming Language :: Python :: 3.12
17
22
  Classifier: Programming Language :: Python :: 3.13
18
23
  Classifier: Topic :: Database
24
+ Classifier: Topic :: Database :: Database Engines/Servers
19
25
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
26
  Classifier: Typing :: Typed
21
- Requires-Dist: psycopg (>=3.2.3,<4.0.0)
22
- Requires-Dist: psycopg-pool (>=3.2.4,<4.0.0)
23
- Requires-Dist: pydantic (>=2.10.5,<3.0.0)
24
- Requires-Dist: tenacity (>=9.0.0,<10.0.0)
25
- Project-URL: Documentation, https://github.com/descoped/psycopg-toolkit/tree/master/docs
26
- Project-URL: Homepage, https://github.com/descoped/psycopg-toolkit
27
- Project-URL: Repository, https://github.com/descoped/psycopg-toolkit
27
+ Requires-Python: >=3.11
28
+ Requires-Dist: psycopg-pool>=3.2.4
29
+ Requires-Dist: psycopg>=3.2.3
30
+ Requires-Dist: pydantic>=2.10.5
31
+ Requires-Dist: tenacity>=9.0.0
28
32
  Description-Content-Type: text/markdown
29
33
 
30
34
  # Psycopg Toolkit
31
35
 
36
+ [![Build Status](https://github.com/descoped/psycopg-toolkit/actions/workflows/build-test.yml/badge.svg)](https://github.com/descoped/psycopg-toolkit/actions/workflows/build-test-native.yml)
37
+ [![Coverage](https://codecov.io/gh/descoped/psycopg-toolkit/branch/master/graph/badge.svg)](https://codecov.io/gh/descoped/psycopg-toolkit)
38
+ [![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
39
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
40
+ [![Release](https://img.shields.io/github/v/release/descoped/psycopg-toolkit)](https://github.com/descoped/psycopg-toolkit/releases)
41
+
32
42
  A robust PostgreSQL database toolkit providing enterprise-grade connection pooling and database management capabilities for Python applications.
33
43
 
34
44
  ## Features
@@ -36,6 +46,7 @@ A robust PostgreSQL database toolkit providing enterprise-grade connection pooli
36
46
  - Async-first design with connection pooling via `psycopg-pool`
37
47
  - Comprehensive transaction management with savepoint support
38
48
  - Type-safe repository pattern with Pydantic model validation
49
+ - JSONB support with automatic field detection and psycopg JSON adapters
39
50
  - SQL query builder with SQL injection protection
40
51
  - Database schema and test data lifecycle management
41
52
  - Automatic retry mechanism with exponential backoff
@@ -140,6 +151,45 @@ async with tm.transaction() as conn:
140
151
  user = await repo.get_by_id(user_id)
141
152
  ```
142
153
 
154
+ ### JSONB Support
155
+
156
+ ```python
157
+ from typing import Dict, List, Any
158
+ from pydantic import BaseModel
159
+ from psycopg_toolkit import BaseRepository
160
+
161
+ class UserProfile(BaseModel):
162
+ id: int
163
+ name: str
164
+ # These fields are automatically detected as JSONB
165
+ metadata: Dict[str, Any]
166
+ preferences: Dict[str, str]
167
+ tags: List[str]
168
+
169
+ class UserRepository(BaseRepository[UserProfile, int]):
170
+ def __init__(self, conn):
171
+ super().__init__(
172
+ db_connection=conn,
173
+ table_name="user_profiles",
174
+ model_class=UserProfile,
175
+ primary_key="id"
176
+ # auto_detect_json=True by default
177
+ )
178
+
179
+ # Usage - JSON fields handled automatically
180
+ user = UserProfile(
181
+ id=1,
182
+ name="John Doe",
183
+ metadata={"created_at": "2024-01-01", "source": "web"},
184
+ preferences={"theme": "dark", "language": "en"},
185
+ tags=["premium", "beta_tester"]
186
+ )
187
+
188
+ # JSONB fields automatically serialized/deserialized
189
+ created_user = await repo.create(user)
190
+ retrieved_user = await repo.get_by_id(1)
191
+ ```
192
+
143
193
  ### Schema Management
144
194
 
145
195
  ```python
@@ -185,21 +235,45 @@ except RecordNotFoundError:
185
235
 
186
236
  ## Documentation
187
237
 
188
- - [Database Management](https://github.com/descoped/psycopg-toolkit/blob/master/docs/database.md)
189
- - [Transaction Management](https://github.com/descoped/psycopg-toolkit/blob/master/docs/transaction_manager.md)
190
- - [Base Repository](https://github.com/descoped/psycopg-toolkit/blob/master/docs/base_repository.md)
191
- - [PsycopgHelper](https://github.com/descoped/psycopg-toolkit/blob/master/docs/psycopg_helper.md)
238
+ - [Database Management](docs/database.md)
239
+ - [Transaction Management](docs/transaction_manager.md)
240
+ - [Base Repository](docs/base_repository.md)
241
+ - [JSONB Support](docs/jsonb_support.md)
242
+ - [PsycopgHelper](docs/psycopg_helper.md)
192
243
 
193
244
  ## Running Tests
194
245
 
195
246
  ```bash
196
- # Install test dependencies
197
- poetry install --with test
247
+ # Install dependencies
248
+ uv sync --all-groups
249
+
250
+ # Run all tests except performance tests (default)
251
+ uv run pytest
252
+
253
+ # Run only performance tests
254
+ uv run pytest -m performance
198
255
 
199
- # Run tests
200
- poetry run pytest
256
+ # Run all tests including performance
257
+ uv run pytest -m ""
258
+
259
+ # Run specific test categories
260
+ uv run pytest tests/unit/ # Only unit tests
261
+ uv run pytest -m performance # Only performance tests
262
+
263
+ # Run with coverage
264
+ uv run pytest --cov=src/psycopg_toolkit --cov-report=html
201
265
  ```
202
266
 
267
+ ### Test Categories
268
+
269
+ The test suite is organized into three categories:
270
+
271
+ - **Unit tests**: Fast, isolated tests that don't require a database (in `tests/unit/`)
272
+ - **Integration tests**: Tests that require a real PostgreSQL database (in `tests/` root)
273
+ - **Performance tests**: Benchmarks and performance measurements (marked with `@pytest.mark.performance`)
274
+
275
+ Performance tests are excluded by default to keep the regular test runs fast. Use the `-m performance` flag to run them explicitly.
276
+
203
277
  ## Contributing
204
278
 
205
279
  1. Fork the repository
@@ -211,4 +285,3 @@ poetry run pytest
211
285
  ## License
212
286
 
213
287
  This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
214
-
@@ -1,5 +1,11 @@
1
1
  # Psycopg Toolkit
2
2
 
3
+ [![Build Status](https://github.com/descoped/psycopg-toolkit/actions/workflows/build-test.yml/badge.svg)](https://github.com/descoped/psycopg-toolkit/actions/workflows/build-test-native.yml)
4
+ [![Coverage](https://codecov.io/gh/descoped/psycopg-toolkit/branch/master/graph/badge.svg)](https://codecov.io/gh/descoped/psycopg-toolkit)
5
+ [![Python Version](https://img.shields.io/badge/python-3.11%2B-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![Release](https://img.shields.io/github/v/release/descoped/psycopg-toolkit)](https://github.com/descoped/psycopg-toolkit/releases)
8
+
3
9
  A robust PostgreSQL database toolkit providing enterprise-grade connection pooling and database management capabilities for Python applications.
4
10
 
5
11
  ## Features
@@ -7,6 +13,7 @@ A robust PostgreSQL database toolkit providing enterprise-grade connection pooli
7
13
  - Async-first design with connection pooling via `psycopg-pool`
8
14
  - Comprehensive transaction management with savepoint support
9
15
  - Type-safe repository pattern with Pydantic model validation
16
+ - JSONB support with automatic field detection and psycopg JSON adapters
10
17
  - SQL query builder with SQL injection protection
11
18
  - Database schema and test data lifecycle management
12
19
  - Automatic retry mechanism with exponential backoff
@@ -111,6 +118,45 @@ async with tm.transaction() as conn:
111
118
  user = await repo.get_by_id(user_id)
112
119
  ```
113
120
 
121
+ ### JSONB Support
122
+
123
+ ```python
124
+ from typing import Dict, List, Any
125
+ from pydantic import BaseModel
126
+ from psycopg_toolkit import BaseRepository
127
+
128
+ class UserProfile(BaseModel):
129
+ id: int
130
+ name: str
131
+ # These fields are automatically detected as JSONB
132
+ metadata: Dict[str, Any]
133
+ preferences: Dict[str, str]
134
+ tags: List[str]
135
+
136
+ class UserRepository(BaseRepository[UserProfile, int]):
137
+ def __init__(self, conn):
138
+ super().__init__(
139
+ db_connection=conn,
140
+ table_name="user_profiles",
141
+ model_class=UserProfile,
142
+ primary_key="id"
143
+ # auto_detect_json=True by default
144
+ )
145
+
146
+ # Usage - JSON fields handled automatically
147
+ user = UserProfile(
148
+ id=1,
149
+ name="John Doe",
150
+ metadata={"created_at": "2024-01-01", "source": "web"},
151
+ preferences={"theme": "dark", "language": "en"},
152
+ tags=["premium", "beta_tester"]
153
+ )
154
+
155
+ # JSONB fields automatically serialized/deserialized
156
+ created_user = await repo.create(user)
157
+ retrieved_user = await repo.get_by_id(1)
158
+ ```
159
+
114
160
  ### Schema Management
115
161
 
116
162
  ```python
@@ -156,21 +202,45 @@ except RecordNotFoundError:
156
202
 
157
203
  ## Documentation
158
204
 
159
- - [Database Management](https://github.com/descoped/psycopg-toolkit/blob/master/docs/database.md)
160
- - [Transaction Management](https://github.com/descoped/psycopg-toolkit/blob/master/docs/transaction_manager.md)
161
- - [Base Repository](https://github.com/descoped/psycopg-toolkit/blob/master/docs/base_repository.md)
162
- - [PsycopgHelper](https://github.com/descoped/psycopg-toolkit/blob/master/docs/psycopg_helper.md)
205
+ - [Database Management](docs/database.md)
206
+ - [Transaction Management](docs/transaction_manager.md)
207
+ - [Base Repository](docs/base_repository.md)
208
+ - [JSONB Support](docs/jsonb_support.md)
209
+ - [PsycopgHelper](docs/psycopg_helper.md)
163
210
 
164
211
  ## Running Tests
165
212
 
166
213
  ```bash
167
- # Install test dependencies
168
- poetry install --with test
214
+ # Install dependencies
215
+ uv sync --all-groups
216
+
217
+ # Run all tests except performance tests (default)
218
+ uv run pytest
219
+
220
+ # Run only performance tests
221
+ uv run pytest -m performance
169
222
 
170
- # Run tests
171
- poetry run pytest
223
+ # Run all tests including performance
224
+ uv run pytest -m ""
225
+
226
+ # Run specific test categories
227
+ uv run pytest tests/unit/ # Only unit tests
228
+ uv run pytest -m performance # Only performance tests
229
+
230
+ # Run with coverage
231
+ uv run pytest --cov=src/psycopg_toolkit --cov-report=html
172
232
  ```
173
233
 
234
+ ### Test Categories
235
+
236
+ The test suite is organized into three categories:
237
+
238
+ - **Unit tests**: Fast, isolated tests that don't require a database (in `tests/unit/`)
239
+ - **Integration tests**: Tests that require a real PostgreSQL database (in `tests/` root)
240
+ - **Performance tests**: Benchmarks and performance measurements (marked with `@pytest.mark.performance`)
241
+
242
+ Performance tests are excluded by default to keep the regular test runs fast. Use the `-m performance` flag to run them explicitly.
243
+
174
244
  ## Contributing
175
245
 
176
246
  1. Fork the repository
@@ -0,0 +1,194 @@
1
+ [project]
2
+ name = "psycopg-toolkit"
3
+ version = "0.2.0"
4
+ description = "A Python PostgreSQL database utility with connection pooling"
5
+ authors = [
6
+ { name = "Ove Ranheim", email = "oranheim@gmail.com" }
7
+ ]
8
+ requires-python = ">=3.11"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ keywords = ["postgresql", "database", "async", "pool", "psycopg", "jsonb", "repository-pattern"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Operating System :: OS Independent",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: Database",
21
+ "Topic :: Database :: Database Engines/Servers",
22
+ "Topic :: Software Development :: Libraries :: Python Modules",
23
+ "Typing :: Typed",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Framework :: AsyncIO",
26
+ "Framework :: Pydantic :: 2",
27
+ ]
28
+ dependencies = [
29
+ "psycopg>=3.2.3",
30
+ "psycopg-pool>=3.2.4",
31
+ "tenacity>=9.0.0",
32
+ "pydantic>=2.10.5",
33
+ ]
34
+
35
+ [dependency-groups]
36
+ test = [
37
+ "pytest>=8.3.0",
38
+ "pytest-asyncio>=0.25.2",
39
+ "pytest-cov>=6.0.0",
40
+ "testcontainers[postgresql]>=4.9.1",
41
+ "psutil>=6.1.0", # For performance benchmarks
42
+ ]
43
+ dev = [
44
+ "ruff>=0.8.0",
45
+ ]
46
+
47
+ [build-system]
48
+ requires = ["hatchling>=1.26.3"]
49
+ build-backend = "hatchling.build"
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["src/psycopg_toolkit"]
53
+
54
+ [tool.hatch.build]
55
+ exclude = [
56
+ "docs/*",
57
+ "examples/*",
58
+ "tests/*",
59
+ ".github/*",
60
+ "scripts/*",
61
+ "ai_docs/*",
62
+ "*.gif",
63
+ "*.png",
64
+ "dist/*",
65
+ "build/*",
66
+ ".pytest_cache",
67
+ "__pycache__",
68
+ "*.pyc",
69
+ ".coverage",
70
+ "htmlcov/*",
71
+ ".ruff_cache/*",
72
+ ".venv/*",
73
+ ".env",
74
+ "*.egg-info/",
75
+ ".claude/*",
76
+ "uv.lock",
77
+ ]
78
+
79
+ [project.urls]
80
+ Homepage = "https://github.com/descoped/psycopg-toolkit"
81
+ Repository = "https://github.com/descoped/psycopg-toolkit"
82
+ Documentation = "https://github.com/descoped/psycopg-toolkit/tree/master/docs"
83
+ Issues = "https://github.com/descoped/psycopg-toolkit/issues"
84
+
85
+ [[tool.uv.index]]
86
+ name = "pypi"
87
+ url = "https://pypi.org/simple/"
88
+ publish-url = "https://upload.pypi.org/legacy/"
89
+
90
+ [[tool.uv.index]]
91
+ name = "testpypi"
92
+ url = "https://test.pypi.org/simple/"
93
+ publish-url = "https://test.pypi.org/legacy/"
94
+
95
+ [tool.pytest.ini_options]
96
+ testpaths = ["tests"]
97
+ python_files = ["test_*.py"]
98
+ asyncio_mode = "auto"
99
+ asyncio_default_fixture_loop_scope = "function"
100
+ markers = [
101
+ "asyncio: mark test as async",
102
+ "performance: mark test as performance benchmark",
103
+ ]
104
+ addopts = [
105
+ "--verbose",
106
+ "--strict-markers",
107
+ "--tb=short",
108
+ "-m", "not performance", # Exclude performance tests by default
109
+ ]
110
+
111
+ [tool.coverage.run]
112
+ source = ["src/psycopg_toolkit"]
113
+ branch = true
114
+ omit = [
115
+ "*/tests/*",
116
+ "*/examples/*",
117
+ "*/__init__.py",
118
+ ]
119
+
120
+ [tool.coverage.report]
121
+ exclude_lines = [
122
+ "pragma: no cover",
123
+ "def __repr__",
124
+ "raise AssertionError",
125
+ "raise NotImplementedError",
126
+ "if __name__ == .__main__.:",
127
+ "if TYPE_CHECKING:",
128
+ "@abstractmethod",
129
+ "@abc.abstractmethod",
130
+ ]
131
+ precision = 2
132
+ show_missing = true
133
+ skip_covered = false
134
+
135
+ [tool.ruff]
136
+ target-version = "py311"
137
+ line-length = 120
138
+
139
+ [tool.ruff.lint]
140
+ select = [
141
+ "E", # pycodestyle errors
142
+ "W", # pycodestyle warnings
143
+ "F", # pyflakes
144
+ "I", # isort
145
+ "N", # pep8-naming
146
+ "UP", # pyupgrade
147
+ "C4", # flake8-comprehensions
148
+ "B", # flake8-bugbear
149
+ "A", # flake8-builtins
150
+ "T20", # flake8-print
151
+ "SIM", # flake8-simplify
152
+ "RUF", # Ruff-specific rules
153
+ "C90", # mccabe complexity
154
+ "PTH", # flake8-use-pathlib
155
+ "TCH", # flake8-type-checking
156
+ ]
157
+ ignore =[
158
+ "E501", # Line too long (handled by formatter)
159
+ "N818", # Exception name should be named with an Error suffix (backwards compatibility)
160
+ ]
161
+ # Your existing ignores + a few additions
162
+ extend-ignore = [
163
+ "S101", # Assert statements (tests need them)
164
+ "S608", # SQL injection (psycopg handles this)
165
+ ]
166
+
167
+ [tool.ruff.lint.per-file-ignores]
168
+ "tests/*" = [
169
+ "B017", # Assert raises on Exception - sometimes needed for testing
170
+ "C901", # Allow complex functions
171
+ "S101", # Allow assert statements
172
+ "S106", # Allow hardcoded passwords in test fixtures
173
+ "S105", # Allow hardcoded secrets in tests
174
+ "T201", # Print found (allow print statements)
175
+ ]
176
+ "examples/*" = [
177
+ "T201", # Allow print statements in examples
178
+ "T203", # Allow pprint in examples
179
+ "S106", # Allow hardcoded passwords in examples
180
+ ]
181
+
182
+ [tool.ruff.lint.pyupgrade]
183
+ keep-runtime-typing = true # For Pydantic
184
+
185
+ [tool.ruff.lint.pep8-naming]
186
+ ignore-names = ["model_*"] # For Pydantic models
187
+
188
+ [tool.ruff.format]
189
+ quote-style = "double"
190
+ indent-style = "space"
191
+ skip-magic-trailing-comma = false
192
+ line-ending = "auto"
193
+ docstring-code-format = true
194
+ docstring-code-line-length = "dynamic"