sqlspec 0.6.0__tar.gz → 0.7.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.
Potentially problematic release.
This version of sqlspec might be problematic. Click here for more details.
- {sqlspec-0.6.0 → sqlspec-0.7.0}/.pre-commit-config.yaml +1 -1
- {sqlspec-0.6.0 → sqlspec-0.7.0}/PKG-INFO +8 -1
- sqlspec-0.7.0/base.py +9 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/pyproject.toml +85 -49
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/__metadata__.py +0 -2
- sqlspec-0.7.0/sqlspec/_serialization.py +71 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/_typing.py +69 -20
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/adbc/config.py +6 -11
- sqlspec-0.7.0/sqlspec/adapters/aiosqlite/__init__.py +3 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/aiosqlite/config.py +12 -14
- sqlspec-0.7.0/sqlspec/adapters/asyncmy/__init__.py +3 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/asyncmy/config.py +44 -44
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/asyncpg/config.py +26 -27
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/duckdb/config.py +73 -77
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/oracledb/config/_asyncio.py +9 -11
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/oracledb/config/_common.py +50 -52
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/oracledb/config/_sync.py +8 -10
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/psycopg/config/_async.py +7 -9
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/psycopg/config/_common.py +15 -17
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/psycopg/config/_sync.py +7 -9
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/sqlite/config.py +11 -13
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/base.py +14 -8
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/exceptions.py +4 -6
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/extensions/litestar/plugin.py +8 -7
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/filters.py +11 -13
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/typing.py +110 -127
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/utils/deprecation.py +8 -10
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/utils/fixtures.py +3 -5
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/utils/module_loader.py +4 -6
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/utils/text.py +2 -3
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_aiosqlite/test_config.py +1 -1
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_asyncpg/test_config.py +3 -3
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_duckdb/test_config.py +68 -67
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_oracledb/test_config.py +3 -2
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_psycopg/test_async_config.py +4 -4
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_psycopg/test_sync_config.py +4 -4
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_utils/test_module_loader.py +1 -1
- sqlspec-0.7.0/tools/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tools/sphinx_ext/__init__.py +1 -1
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tools/sphinx_ext/missing_references.py +29 -21
- {sqlspec-0.6.0 → sqlspec-0.7.0}/uv.lock +1143 -674
- sqlspec-0.6.0/sqlspec/__init__.py +0 -1
- sqlspec-0.6.0/sqlspec/_serialization.py +0 -24
- sqlspec-0.6.0/sqlspec/adapters/aiosqlite/__init__.py +0 -3
- sqlspec-0.6.0/sqlspec/adapters/asyncmy/__init__.py +0 -3
- {sqlspec-0.6.0 → sqlspec-0.7.0}/.gitignore +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/CONTRIBUTING.rst +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/LICENSE +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/Makefile +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/NOTICE +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/README.md +0 -0
- {sqlspec-0.6.0/sqlspec/adapters → sqlspec-0.7.0/sqlspec}/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/adapters/adbc → sqlspec-0.7.0/sqlspec/adapters}/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/adapters/asyncpg → sqlspec-0.7.0/sqlspec/adapters/adbc}/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/adapters/psycopg → sqlspec-0.7.0/sqlspec/adapters/asyncpg}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/duckdb/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/oracledb/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/oracledb/config/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/adapters/sqlite → sqlspec-0.7.0/sqlspec/adapters/psycopg}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/adapters/psycopg/config/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/extensions → sqlspec-0.7.0/sqlspec/adapters/sqlite}/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/extensions/litestar → sqlspec-0.7.0/sqlspec/extensions}/__init__.py +0 -0
- {sqlspec-0.6.0/sqlspec/utils → sqlspec-0.7.0/sqlspec/extensions/litestar}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/extensions/litestar/config.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/sqlspec/py.typed +0 -0
- {sqlspec-0.6.0/tests → sqlspec-0.7.0/sqlspec/utils}/__init__.py +0 -0
- {sqlspec-0.6.0/tests/integration → sqlspec-0.7.0/tests}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/conftest.py +0 -0
- {sqlspec-0.6.0/tests/unit → sqlspec-0.7.0/tests/integration}/__init__.py +0 -0
- {sqlspec-0.6.0/tests/unit/test_adapters → sqlspec-0.7.0/tests/unit}/__init__.py +0 -0
- {sqlspec-0.6.0/tests/unit/test_adapters/test_duckdb → sqlspec-0.7.0/tests/unit/test_adapters}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_asyncpg/__init__.py +0 -0
- {sqlspec-0.6.0/tests/unit/test_utils → sqlspec-0.7.0/tests/unit/test_adapters/test_duckdb}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_oracledb/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_sqlite/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_adapters/test_sqlite/test_config.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_base.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_typing.py +0 -0
- {sqlspec-0.6.0/tools → sqlspec-0.7.0/tests/unit/test_utils}/__init__.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tests/unit/test_utils/test_text.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tools/build_docs.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tools/pypi_readme.py +0 -0
- {sqlspec-0.6.0 → sqlspec-0.7.0}/tools/sphinx_ext/changelog.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlspec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: SQL Experiments in Python
|
|
5
5
|
Author-email: Cody Fincher <cody@litestar.dev>
|
|
6
6
|
Maintainer-email: Litestar Developers <hello@litestar.dev>
|
|
@@ -34,20 +34,27 @@ Provides-Extra: litestar
|
|
|
34
34
|
Requires-Dist: litestar; extra == 'litestar'
|
|
35
35
|
Provides-Extra: msgspec
|
|
36
36
|
Requires-Dist: msgspec; extra == 'msgspec'
|
|
37
|
+
Provides-Extra: nanoid
|
|
38
|
+
Requires-Dist: fastnanoid>=0.4.1; extra == 'nanoid'
|
|
37
39
|
Provides-Extra: oracledb
|
|
38
40
|
Requires-Dist: oracledb; extra == 'oracledb'
|
|
41
|
+
Provides-Extra: orjson
|
|
42
|
+
Requires-Dist: orjson; extra == 'orjson'
|
|
39
43
|
Provides-Extra: performance
|
|
40
44
|
Requires-Dist: sqlglot[rs]; extra == 'performance'
|
|
41
45
|
Provides-Extra: psycopg
|
|
42
46
|
Requires-Dist: psycopg[binary,pool]; extra == 'psycopg'
|
|
43
47
|
Provides-Extra: pydantic
|
|
44
48
|
Requires-Dist: pydantic; extra == 'pydantic'
|
|
49
|
+
Requires-Dist: pydantic-extra-types; extra == 'pydantic'
|
|
45
50
|
Provides-Extra: pymssql
|
|
46
51
|
Requires-Dist: pymssql; extra == 'pymssql'
|
|
47
52
|
Provides-Extra: pymysql
|
|
48
53
|
Requires-Dist: pymysql; extra == 'pymysql'
|
|
49
54
|
Provides-Extra: spanner
|
|
50
55
|
Requires-Dist: google-cloud-spanner; extra == 'spanner'
|
|
56
|
+
Provides-Extra: uuid
|
|
57
|
+
Requires-Dist: uuid-utils>=0.6.1; extra == 'uuid'
|
|
51
58
|
Description-Content-Type: text/markdown
|
|
52
59
|
|
|
53
60
|
# SQLSpec
|
sqlspec-0.7.0/base.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
from sqlspec.adapters.duckdb.config import DuckDBConfig
|
|
2
|
+
from sqlspec.base import ConfigManager
|
|
3
|
+
|
|
4
|
+
dbs = ConfigManager()
|
|
5
|
+
|
|
6
|
+
config = DuckDBConfig(database="test.duckdb", extensions=[{"name": "vss"}])
|
|
7
|
+
etl_db = dbs.add_config(config)
|
|
8
|
+
|
|
9
|
+
connection = dbs.get_connection(etl_db)
|
|
@@ -7,7 +7,7 @@ maintainers = [{ name = "Litestar Developers", email = "hello@litestar.dev" }]
|
|
|
7
7
|
name = "sqlspec"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
requires-python = ">=3.9, <4.0"
|
|
10
|
-
version = "0.
|
|
10
|
+
version = "0.7.0"
|
|
11
11
|
|
|
12
12
|
[project.optional-dependencies]
|
|
13
13
|
adbc = ["adbc-driver-manager", "pyarrow"]
|
|
@@ -21,15 +21,19 @@ fastapi = ["fastapi"]
|
|
|
21
21
|
flask = ["flask"]
|
|
22
22
|
litestar = ["litestar"]
|
|
23
23
|
msgspec = ["msgspec"]
|
|
24
|
+
nanoid = ["fastnanoid>=0.4.1"]
|
|
24
25
|
oracledb = ["oracledb"]
|
|
26
|
+
orjson = ["orjson"]
|
|
25
27
|
performance = ["sqlglot[rs]"]
|
|
26
28
|
psycopg = ["psycopg[binary,pool]"]
|
|
27
|
-
pydantic = ["pydantic"]
|
|
29
|
+
pydantic = ["pydantic", "pydantic-extra-types"]
|
|
28
30
|
pymssql = ["pymssql"]
|
|
29
31
|
pymysql = ["pymysql"]
|
|
30
32
|
spanner = ["google-cloud-spanner"]
|
|
33
|
+
uuid = ["uuid-utils>=0.6.1"]
|
|
31
34
|
|
|
32
35
|
[dependency-groups]
|
|
36
|
+
build = ["bump-my-version"]
|
|
33
37
|
dev = [
|
|
34
38
|
"adbc-driver-sqlite",
|
|
35
39
|
"adbc-driver-postgresql",
|
|
@@ -37,11 +41,11 @@ dev = [
|
|
|
37
41
|
{ include-group = "lint" },
|
|
38
42
|
{ include-group = "doc" },
|
|
39
43
|
{ include-group = "test" },
|
|
44
|
+
{ include-group = "build" },
|
|
40
45
|
]
|
|
41
46
|
doc = [
|
|
42
47
|
"auto-pytabs[sphinx]>=0.5.0",
|
|
43
|
-
"
|
|
44
|
-
"litestar-sphinx-theme @ git+https://github.com/litestar-org/litestar-sphinx-theme.git@v3",
|
|
48
|
+
"shibuya",
|
|
45
49
|
"sphinx>=7.0.0; python_version <= \"3.9\"",
|
|
46
50
|
"sphinx>=8.0.0; python_version >= \"3.10\"",
|
|
47
51
|
"sphinx-autobuild>=2021.3.14",
|
|
@@ -52,6 +56,8 @@ doc = [
|
|
|
52
56
|
"sphinx-paramlinks>=0.6.0",
|
|
53
57
|
"sphinx-togglebutton>=0.3.2",
|
|
54
58
|
"sphinx-toolbox>=3.8.1",
|
|
59
|
+
"myst-parser",
|
|
60
|
+
"sphinx-autodoc-typehints",
|
|
55
61
|
]
|
|
56
62
|
lint = [
|
|
57
63
|
"mypy>=1.13.0",
|
|
@@ -75,7 +81,6 @@ test = [
|
|
|
75
81
|
"pytest-xdist>=3.6.1",
|
|
76
82
|
]
|
|
77
83
|
|
|
78
|
-
|
|
79
84
|
[build-system]
|
|
80
85
|
build-backend = "hatchling.build"
|
|
81
86
|
requires = ["hatchling"]
|
|
@@ -92,6 +97,40 @@ include = ["NOTICE"]
|
|
|
92
97
|
packages = ["sqlspec"]
|
|
93
98
|
|
|
94
99
|
|
|
100
|
+
[tool.bumpversion]
|
|
101
|
+
allow_dirty = true
|
|
102
|
+
commit = false
|
|
103
|
+
commit_args = "--no-verify"
|
|
104
|
+
current_version = "0.33.1"
|
|
105
|
+
ignore_missing_files = false
|
|
106
|
+
ignore_missing_version = false
|
|
107
|
+
message = "chore(release): bump to v{new_version}"
|
|
108
|
+
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
109
|
+
regex = false
|
|
110
|
+
replace = "{new_version}"
|
|
111
|
+
search = "{current_version}"
|
|
112
|
+
serialize = ["{major}.{minor}.{patch}"]
|
|
113
|
+
sign_tags = false
|
|
114
|
+
tag = false
|
|
115
|
+
tag_message = "chore(release): v{new_version}"
|
|
116
|
+
tag_name = "v{new_version}"
|
|
117
|
+
|
|
118
|
+
[[tool.bumpversion.files]]
|
|
119
|
+
filename = "pyproject.toml"
|
|
120
|
+
replace = 'version = "{new_version}"'
|
|
121
|
+
search = 'version = "{current_version}"'
|
|
122
|
+
|
|
123
|
+
[[tool.bumpversion.files]]
|
|
124
|
+
filename = "uv.lock"
|
|
125
|
+
replace = """
|
|
126
|
+
name = "advanced-alchemy"
|
|
127
|
+
version = "{new_version}"
|
|
128
|
+
"""
|
|
129
|
+
search = """
|
|
130
|
+
name = "advanced-alchemy"
|
|
131
|
+
version = "{current_version}"
|
|
132
|
+
"""
|
|
133
|
+
|
|
95
134
|
[tool.codespell]
|
|
96
135
|
ignore-words-list = "te"
|
|
97
136
|
skip = 'uv.lock'
|
|
@@ -103,6 +142,7 @@ disable_warnings = ["no-data-collected", "module-not-measured", "module-not-impo
|
|
|
103
142
|
omit = ["*/tests/*"]
|
|
104
143
|
parallel = true
|
|
105
144
|
plugins = ["covdefaults"]
|
|
145
|
+
relative_files = true
|
|
106
146
|
source = ["sqlspec"]
|
|
107
147
|
|
|
108
148
|
[tool.coverage.report]
|
|
@@ -131,6 +171,17 @@ exclude_lines = [
|
|
|
131
171
|
addopts = "-ra -q --doctest-glob='*.md' --strict-markers --strict-config"
|
|
132
172
|
asyncio_default_fixture_loop_scope = "function"
|
|
133
173
|
asyncio_mode = "auto"
|
|
174
|
+
filterwarnings = [
|
|
175
|
+
"ignore::DeprecationWarning:pkg_resources.*",
|
|
176
|
+
"ignore:pkg_resources is deprecated as an API:DeprecationWarning",
|
|
177
|
+
"ignore::DeprecationWarning:pkg_resources",
|
|
178
|
+
"ignore::DeprecationWarning:google.rpc",
|
|
179
|
+
"ignore::DeprecationWarning:google.gcloud",
|
|
180
|
+
"ignore::DeprecationWarning:google.iam",
|
|
181
|
+
"ignore::DeprecationWarning:google",
|
|
182
|
+
"ignore::DeprecationWarning:websockets.connection",
|
|
183
|
+
"ignore::DeprecationWarning:websockets.legacy",
|
|
184
|
+
]
|
|
134
185
|
testpaths = ["tests"]
|
|
135
186
|
xfail_strict = true
|
|
136
187
|
|
|
@@ -176,45 +227,19 @@ reportUnnecessaryTypeIgnoreComments = true
|
|
|
176
227
|
strict-imports = false
|
|
177
228
|
|
|
178
229
|
[tool.ruff]
|
|
179
|
-
|
|
180
|
-
"A", # flake8-builtins
|
|
181
|
-
"B", # flake8-bugbear
|
|
182
|
-
"BLE", # flake8-blind-except
|
|
183
|
-
"C4", # flake8-comprehensions
|
|
184
|
-
"C90", # mccabe
|
|
185
|
-
"D", # pydocstyle
|
|
186
|
-
"DJ", # flake8-django
|
|
187
|
-
"DTZ", # flake8-datetimez
|
|
188
|
-
"E", # pycodestyle errors
|
|
189
|
-
"ERA", # eradicate
|
|
190
|
-
"EXE", # flake8-executable
|
|
191
|
-
"F", # pyflakes
|
|
192
|
-
"G", # flake8-logging-format
|
|
193
|
-
"I", # isort
|
|
194
|
-
"ICN", # flake8-import-conventions
|
|
195
|
-
"ISC", # flake8-implicit-str-concat
|
|
196
|
-
"N", # pep8-naming
|
|
197
|
-
"PIE", # flake8-pie
|
|
198
|
-
"PLC", # pylint - convention
|
|
199
|
-
"PLE", # pylint - error
|
|
200
|
-
"PLW", # pylint - warning
|
|
201
|
-
"PTH", # flake8-use-pathlib
|
|
202
|
-
"Q", # flake8-quotes
|
|
203
|
-
"RET", # flake8-return
|
|
204
|
-
"RUF", # Ruff-specific rules
|
|
205
|
-
"S", # flake8-bandit
|
|
206
|
-
"SIM", # flake8-simplify
|
|
207
|
-
"T10", # flake8-debugger
|
|
208
|
-
"T20", # flake8-print
|
|
209
|
-
"TC", # flake8-type-checking
|
|
210
|
-
"TID", # flake8-tidy-imports
|
|
211
|
-
"UP", # pyupgrade
|
|
212
|
-
"W", # pycodestyle - warning
|
|
213
|
-
"YTT", # flake8-2020
|
|
214
|
-
]
|
|
215
|
-
|
|
230
|
+
exclude = [".venv", "node_modules"]
|
|
216
231
|
line-length = 120
|
|
217
|
-
|
|
232
|
+
src = ["sqlspec", "tests", "docs/examples", "tools"]
|
|
233
|
+
target-version = "py39"
|
|
234
|
+
|
|
235
|
+
[tool.ruff.format]
|
|
236
|
+
docstring-code-format = true
|
|
237
|
+
docstring-code-line-length = 60
|
|
238
|
+
|
|
239
|
+
[tool.ruff.lint]
|
|
240
|
+
extend-safe-fixes = ["TC"]
|
|
241
|
+
fixable = ["ALL"]
|
|
242
|
+
ignore = [
|
|
218
243
|
"A003", # flake8-builtins - class attribute {name} is shadowing a python builtin
|
|
219
244
|
"B010", # flake8-bugbear - do not call setattr with a constant attribute value
|
|
220
245
|
"D100", # pydocstyle - missing docstring in public module
|
|
@@ -232,9 +257,18 @@ lint.ignore = [
|
|
|
232
257
|
"PLW2901", # pylint - for loop variable overwritten by assignment target
|
|
233
258
|
"RUF012", # Ruff-specific rule - annotated with classvar
|
|
234
259
|
"ISC001", # Ruff formatter incompatible
|
|
260
|
+
"A005", # flake8 - Module `x` shadows a Python standard-library module
|
|
261
|
+
"PLC0415", # pylint - `import` should be at the top of the file
|
|
262
|
+
"FA100", # Add `from __future__ import annotations` to simplify
|
|
263
|
+
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
|
|
264
|
+
"FBT001", # Boolean-typed positional argument in function definition
|
|
265
|
+
"FBT002", # Boolean default positional argument in function definition
|
|
266
|
+
"PLR0913", # pylint - Too many arguments in function definition
|
|
267
|
+
"ARG002", # Unused method argument
|
|
268
|
+
"ARG001", # Unused function argument
|
|
269
|
+
"CPY001", # pycodestyle - Missing Copywrite notice at the top of the file
|
|
235
270
|
]
|
|
236
|
-
|
|
237
|
-
target-version = "py39"
|
|
271
|
+
select = ["ALL"]
|
|
238
272
|
|
|
239
273
|
[tool.ruff.lint.pydocstyle]
|
|
240
274
|
convention = "google"
|
|
@@ -274,10 +308,12 @@ known-first-party = ["sqlspec", "tests"]
|
|
|
274
308
|
"SIM",
|
|
275
309
|
"TC",
|
|
276
310
|
"TRY",
|
|
311
|
+
"PT012",
|
|
312
|
+
"INP001",
|
|
277
313
|
]
|
|
278
|
-
"tools/**/*.*" = ["D", "ARG", "EM", "TRY", "G", "FBT", "S603", "F811", "PLW0127"]
|
|
314
|
+
"tools/**/*.*" = ["D", "ARG", "EM", "TRY", "G", "FBT", "S603", "F811", "PLW0127", "PLR0911"]
|
|
279
315
|
"tools/prepare_release.py" = ["S603", "S607"]
|
|
280
316
|
|
|
281
|
-
[tool.ruff.
|
|
282
|
-
|
|
283
|
-
|
|
317
|
+
[tool.ruff.lint.flake8-tidy-imports]
|
|
318
|
+
# Disallow all relative imports.
|
|
319
|
+
ban-relative-imports = "all"
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import enum
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from sqlspec._typing import PYDANTIC_INSTALLED, BaseModel
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _type_to_string(value: Any) -> str: # pragma: no cover
|
|
9
|
+
if isinstance(value, datetime.datetime):
|
|
10
|
+
return convert_datetime_to_gmt_iso(value)
|
|
11
|
+
if isinstance(value, datetime.date):
|
|
12
|
+
return convert_date_to_iso(value)
|
|
13
|
+
if isinstance(value, enum.Enum):
|
|
14
|
+
return str(value.value)
|
|
15
|
+
if PYDANTIC_INSTALLED and isinstance(value, BaseModel):
|
|
16
|
+
return value.model_dump_json()
|
|
17
|
+
try:
|
|
18
|
+
val = str(value)
|
|
19
|
+
except Exception as exc:
|
|
20
|
+
raise TypeError from exc
|
|
21
|
+
return val
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
from msgspec.json import Decoder, Encoder
|
|
26
|
+
|
|
27
|
+
encoder, decoder = Encoder(enc_hook=_type_to_string), Decoder()
|
|
28
|
+
decode_json = decoder.decode
|
|
29
|
+
|
|
30
|
+
def encode_json(data: Any) -> str: # pragma: no cover
|
|
31
|
+
return encoder.encode(data).decode("utf-8")
|
|
32
|
+
|
|
33
|
+
except ImportError:
|
|
34
|
+
try:
|
|
35
|
+
from orjson import ( # pyright: ignore[reportMissingImports]
|
|
36
|
+
OPT_NAIVE_UTC, # pyright: ignore[reportUnknownVariableType]
|
|
37
|
+
OPT_SERIALIZE_NUMPY, # pyright: ignore[reportUnknownVariableType]
|
|
38
|
+
OPT_SERIALIZE_UUID, # pyright: ignore[reportUnknownVariableType]
|
|
39
|
+
)
|
|
40
|
+
from orjson import dumps as _encode_json # pyright: ignore[reportUnknownVariableType,reportMissingImports]
|
|
41
|
+
from orjson import loads as decode_json # type: ignore[no-redef,assignment,unused-ignore]
|
|
42
|
+
|
|
43
|
+
def encode_json(data: Any) -> str: # pragma: no cover
|
|
44
|
+
return _encode_json(
|
|
45
|
+
data,
|
|
46
|
+
default=_type_to_string,
|
|
47
|
+
option=OPT_SERIALIZE_NUMPY | OPT_NAIVE_UTC | OPT_SERIALIZE_UUID,
|
|
48
|
+
).decode("utf-8")
|
|
49
|
+
|
|
50
|
+
except ImportError:
|
|
51
|
+
from json import dumps as encode_json # type: ignore[assignment]
|
|
52
|
+
from json import loads as decode_json # type: ignore[assignment]
|
|
53
|
+
|
|
54
|
+
__all__ = (
|
|
55
|
+
"convert_date_to_iso",
|
|
56
|
+
"convert_datetime_to_gmt_iso",
|
|
57
|
+
"decode_json",
|
|
58
|
+
"encode_json",
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def convert_datetime_to_gmt_iso(dt: datetime.datetime) -> str: # pragma: no cover
|
|
63
|
+
"""Handle datetime serialization for nested timestamps."""
|
|
64
|
+
if not dt.tzinfo:
|
|
65
|
+
dt = dt.replace(tzinfo=datetime.timezone.utc)
|
|
66
|
+
return dt.isoformat().replace("+00:00", "Z")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def convert_date_to_iso(dt: datetime.date) -> str: # pragma: no cover
|
|
70
|
+
"""Handle datetime serialization for nested timestamps."""
|
|
71
|
+
return dt.isoformat()
|
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
This is used to ensure compatibility when one or more of the libraries are installed.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
from __future__ import annotations
|
|
7
|
-
|
|
8
6
|
from enum import Enum
|
|
9
7
|
from typing import (
|
|
10
8
|
Any,
|
|
@@ -30,10 +28,15 @@ T = TypeVar("T")
|
|
|
30
28
|
T_co = TypeVar("T_co", covariant=True)
|
|
31
29
|
|
|
32
30
|
try:
|
|
33
|
-
from pydantic import
|
|
31
|
+
from pydantic import (
|
|
32
|
+
BaseModel,
|
|
33
|
+
FailFast, # pyright: ignore[reportGeneralTypeIssues,reportAssignmentType]
|
|
34
|
+
TypeAdapter,
|
|
35
|
+
)
|
|
34
36
|
|
|
35
37
|
PYDANTIC_INSTALLED = True
|
|
36
38
|
except ImportError:
|
|
39
|
+
from dataclasses import dataclass
|
|
37
40
|
|
|
38
41
|
@runtime_checkable
|
|
39
42
|
class BaseModel(Protocol): # type: ignore[no-redef]
|
|
@@ -41,10 +44,42 @@ except ImportError:
|
|
|
41
44
|
|
|
42
45
|
model_fields: ClassVar[dict[str, Any]]
|
|
43
46
|
|
|
44
|
-
def model_dump(
|
|
47
|
+
def model_dump(
|
|
48
|
+
self,
|
|
49
|
+
/,
|
|
50
|
+
*,
|
|
51
|
+
include: "Optional[Any]" = None,
|
|
52
|
+
exclude: "Optional[Any]" = None,
|
|
53
|
+
context: "Optional[Any]" = None,
|
|
54
|
+
by_alias: bool = False,
|
|
55
|
+
exclude_unset: bool = False,
|
|
56
|
+
exclude_defaults: bool = False,
|
|
57
|
+
exclude_none: bool = False,
|
|
58
|
+
round_trip: bool = False,
|
|
59
|
+
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True,
|
|
60
|
+
serialize_as_any: bool = False,
|
|
61
|
+
) -> "dict[str, Any]":
|
|
45
62
|
"""Placeholder"""
|
|
46
63
|
return {}
|
|
47
64
|
|
|
65
|
+
def model_dump_json(
|
|
66
|
+
self,
|
|
67
|
+
/,
|
|
68
|
+
*,
|
|
69
|
+
include: "Optional[Any]" = None,
|
|
70
|
+
exclude: "Optional[Any]" = None,
|
|
71
|
+
context: "Optional[Any]" = None,
|
|
72
|
+
by_alias: bool = False,
|
|
73
|
+
exclude_unset: bool = False,
|
|
74
|
+
exclude_defaults: bool = False,
|
|
75
|
+
exclude_none: bool = False,
|
|
76
|
+
round_trip: bool = False,
|
|
77
|
+
warnings: "Union[bool, Literal['none', 'warn', 'error']]" = True,
|
|
78
|
+
serialize_as_any: bool = False,
|
|
79
|
+
) -> str:
|
|
80
|
+
"""Placeholder"""
|
|
81
|
+
return ""
|
|
82
|
+
|
|
48
83
|
@runtime_checkable
|
|
49
84
|
class TypeAdapter(Protocol[T_co]): # type: ignore[no-redef]
|
|
50
85
|
"""Placeholder Implementation"""
|
|
@@ -53,9 +88,9 @@ except ImportError:
|
|
|
53
88
|
self,
|
|
54
89
|
type: Any, # noqa: A002
|
|
55
90
|
*,
|
|
56
|
-
config: Any
|
|
91
|
+
config: "Optional[Any]" = None,
|
|
57
92
|
_parent_depth: int = 2,
|
|
58
|
-
module: str
|
|
93
|
+
module: "Optional[str]" = None,
|
|
59
94
|
) -> None:
|
|
60
95
|
"""Init"""
|
|
61
96
|
|
|
@@ -64,19 +99,19 @@ except ImportError:
|
|
|
64
99
|
object: Any, # noqa: A002
|
|
65
100
|
/,
|
|
66
101
|
*,
|
|
67
|
-
strict: bool
|
|
68
|
-
from_attributes: bool
|
|
69
|
-
context: dict[str, Any]
|
|
70
|
-
|
|
102
|
+
strict: "Optional[bool]" = None,
|
|
103
|
+
from_attributes: "Optional[bool]" = None,
|
|
104
|
+
context: "Optional[dict[str, Any]]" = None,
|
|
105
|
+
experimental_allow_partial: "Union[bool, Literal['off', 'on', 'trailing-strings']]" = False,
|
|
106
|
+
) -> "T_co":
|
|
71
107
|
"""Stub"""
|
|
72
108
|
return cast("T_co", object)
|
|
73
109
|
|
|
74
|
-
@
|
|
75
|
-
class FailFast
|
|
110
|
+
@dataclass
|
|
111
|
+
class FailFast: # type: ignore[no-redef]
|
|
76
112
|
"""Placeholder Implementation for FailFast"""
|
|
77
113
|
|
|
78
|
-
|
|
79
|
-
"""Init"""
|
|
114
|
+
fail_fast: bool = True
|
|
80
115
|
|
|
81
116
|
PYDANTIC_INSTALLED = False # pyright: ignore[reportConstantRedefinition]
|
|
82
117
|
|
|
@@ -84,22 +119,36 @@ try:
|
|
|
84
119
|
from msgspec import (
|
|
85
120
|
UNSET,
|
|
86
121
|
Struct,
|
|
87
|
-
UnsetType, # pyright: ignore[reportAssignmentType]
|
|
122
|
+
UnsetType, # pyright: ignore[reportAssignmentType,reportGeneralTypeIssues]
|
|
88
123
|
convert,
|
|
89
124
|
)
|
|
90
125
|
|
|
91
126
|
MSGSPEC_INSTALLED: bool = True
|
|
92
127
|
except ImportError:
|
|
93
128
|
import enum
|
|
129
|
+
from collections.abc import Iterable
|
|
130
|
+
from typing import TYPE_CHECKING, Callable, Optional, Union
|
|
131
|
+
|
|
132
|
+
if TYPE_CHECKING:
|
|
133
|
+
from collections.abc import Iterable
|
|
94
134
|
|
|
95
135
|
@dataclass_transform()
|
|
96
136
|
@runtime_checkable
|
|
97
137
|
class Struct(Protocol): # type: ignore[no-redef]
|
|
98
138
|
"""Placeholder Implementation"""
|
|
99
139
|
|
|
100
|
-
__struct_fields__: ClassVar[tuple[str, ...]]
|
|
101
|
-
|
|
102
|
-
def convert(
|
|
140
|
+
__struct_fields__: "ClassVar[tuple[str, ...]]"
|
|
141
|
+
|
|
142
|
+
def convert( # type: ignore[no-redef]
|
|
143
|
+
obj: Any,
|
|
144
|
+
type: "Union[Any, type[T]]", # noqa: A002
|
|
145
|
+
*,
|
|
146
|
+
strict: bool = True,
|
|
147
|
+
from_attributes: bool = False,
|
|
148
|
+
dec_hook: "Optional[Callable[[type, Any], Any]]" = None,
|
|
149
|
+
builtin_types: "Union[Iterable[type], None]" = None,
|
|
150
|
+
str_keys: bool = False,
|
|
151
|
+
) -> "Union[T, Any]":
|
|
103
152
|
"""Placeholder implementation"""
|
|
104
153
|
return {}
|
|
105
154
|
|
|
@@ -124,11 +173,11 @@ except ImportError:
|
|
|
124
173
|
def __init__(self, backend: Any, data_as_builtins: Any) -> None:
|
|
125
174
|
"""Placeholder init"""
|
|
126
175
|
|
|
127
|
-
def create_instance(self, **kwargs: Any) -> T:
|
|
176
|
+
def create_instance(self, **kwargs: Any) -> "T":
|
|
128
177
|
"""Placeholder implementation"""
|
|
129
178
|
return cast("T", kwargs)
|
|
130
179
|
|
|
131
|
-
def update_instance(self, instance: T, **kwargs: Any) -> T:
|
|
180
|
+
def update_instance(self, instance: "T", **kwargs: Any) -> "T":
|
|
132
181
|
"""Placeholder implementation"""
|
|
133
182
|
return cast("T", kwargs)
|
|
134
183
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
from contextlib import contextmanager
|
|
4
2
|
from dataclasses import dataclass
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
6
4
|
|
|
7
5
|
from sqlspec.base import NoPoolSyncConfig
|
|
8
6
|
from sqlspec.typing import Empty, EmptyType
|
|
@@ -24,18 +22,15 @@ class AdbcDatabaseConfig(NoPoolSyncConfig["Connection"]):
|
|
|
24
22
|
ADBC Driver Manager.([1](https://arrow.apache.org/adbc/current/python/api/adbc_driver_manager.html))
|
|
25
23
|
"""
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
__is_async = False
|
|
29
|
-
|
|
30
|
-
uri: str | EmptyType = Empty
|
|
25
|
+
uri: "Union[str, EmptyType]" = Empty
|
|
31
26
|
"""Database URI"""
|
|
32
|
-
driver_name: str
|
|
27
|
+
driver_name: "Union[str, EmptyType]" = Empty
|
|
33
28
|
"""Name of the ADBC driver to use"""
|
|
34
|
-
db_kwargs: dict[str, Any]
|
|
29
|
+
db_kwargs: "Optional[dict[str, Any]]" = None
|
|
35
30
|
"""Additional database-specific connection parameters"""
|
|
36
31
|
|
|
37
32
|
@property
|
|
38
|
-
def connection_params(self) -> dict[str, Any]:
|
|
33
|
+
def connection_params(self) -> "dict[str, Any]":
|
|
39
34
|
"""Return the connection parameters as a dict."""
|
|
40
35
|
return {
|
|
41
36
|
k: v
|
|
@@ -44,7 +39,7 @@ class AdbcDatabaseConfig(NoPoolSyncConfig["Connection"]):
|
|
|
44
39
|
}
|
|
45
40
|
|
|
46
41
|
@contextmanager
|
|
47
|
-
def provide_connection(self, *args: Any, **kwargs: Any) -> Generator[Connection, None, None]:
|
|
42
|
+
def provide_connection(self, *args: "Any", **kwargs: "Any") -> "Generator[Connection, None, None]":
|
|
48
43
|
"""Create and provide a database connection."""
|
|
49
44
|
from adbc_driver_manager.dbapi import connect
|
|
50
45
|
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
1
|
from contextlib import asynccontextmanager
|
|
4
2
|
from dataclasses import dataclass, field
|
|
5
|
-
from typing import TYPE_CHECKING, Any
|
|
3
|
+
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
6
4
|
|
|
7
5
|
from sqlspec.base import NoPoolSyncConfig
|
|
8
6
|
from sqlspec.exceptions import ImproperConfigurationError
|
|
@@ -28,25 +26,25 @@ class AiosqliteConfig(NoPoolSyncConfig["Connection"]):
|
|
|
28
26
|
For details see: https://github.com/omnilib/aiosqlite/blob/main/aiosqlite/__init__.pyi
|
|
29
27
|
"""
|
|
30
28
|
|
|
31
|
-
database: str = field(default=":memory:")
|
|
29
|
+
database: "Union[str, EmptyType]" = field(default=":memory:")
|
|
32
30
|
"""The path to the database file to be opened. Pass ":memory:" to open a connection to a database that resides in RAM instead of on disk."""
|
|
33
|
-
timeout: float
|
|
31
|
+
timeout: "Union[float, EmptyType]" = field(default=Empty)
|
|
34
32
|
"""How many seconds the connection should wait before raising an OperationalError when a table is locked. If another thread or process has acquired a shared lock, a wait for the specified timeout occurs."""
|
|
35
|
-
detect_types: int
|
|
33
|
+
detect_types: "Union[int, EmptyType]" = field(default=Empty)
|
|
36
34
|
"""Control whether and how data types are detected. It can be 0 (default) or a combination of PARSE_DECLTYPES and PARSE_COLNAMES."""
|
|
37
|
-
isolation_level: Literal[
|
|
35
|
+
isolation_level: "Optional[Union[Literal['DEFERRED', 'IMMEDIATE', 'EXCLUSIVE'], EmptyType]]" = field(default=Empty)
|
|
38
36
|
"""The isolation_level of the connection. This can be None for autocommit mode or one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE"."""
|
|
39
|
-
check_same_thread: bool
|
|
37
|
+
check_same_thread: "Union[bool, EmptyType]" = field(default=Empty)
|
|
40
38
|
"""If True (default), ProgrammingError is raised if the database connection is used by a thread other than the one that created it. If False, the connection may be shared across multiple threads."""
|
|
41
|
-
factory: type[SQLite3Connection]
|
|
39
|
+
factory: "Union[type[SQLite3Connection], EmptyType]" = field(default=Empty)
|
|
42
40
|
"""A custom Connection class factory. If given, must be a callable that returns a Connection instance."""
|
|
43
|
-
cached_statements: int
|
|
41
|
+
cached_statements: "Union[int, EmptyType]" = field(default=Empty)
|
|
44
42
|
"""The number of statements that SQLite will cache for this connection. The default is 128."""
|
|
45
|
-
uri: bool
|
|
43
|
+
uri: "Union[bool, EmptyType]" = field(default=Empty)
|
|
46
44
|
"""If set to True, database is interpreted as a URI with supported options."""
|
|
47
45
|
|
|
48
46
|
@property
|
|
49
|
-
def connection_config_dict(self) -> dict[str, Any]:
|
|
47
|
+
def connection_config_dict(self) -> "dict[str, Any]":
|
|
50
48
|
"""Return the connection configuration as a dict.
|
|
51
49
|
|
|
52
50
|
Returns:
|
|
@@ -54,7 +52,7 @@ class AiosqliteConfig(NoPoolSyncConfig["Connection"]):
|
|
|
54
52
|
"""
|
|
55
53
|
return dataclass_to_dict(self, exclude_empty=True, convert_nested=False)
|
|
56
54
|
|
|
57
|
-
async def create_connection(self) -> Connection:
|
|
55
|
+
async def create_connection(self) -> "Connection":
|
|
58
56
|
"""Create and return a new database connection.
|
|
59
57
|
|
|
60
58
|
Returns:
|
|
@@ -72,7 +70,7 @@ class AiosqliteConfig(NoPoolSyncConfig["Connection"]):
|
|
|
72
70
|
raise ImproperConfigurationError(msg) from e
|
|
73
71
|
|
|
74
72
|
@asynccontextmanager
|
|
75
|
-
async def provide_connection(self, *args: Any, **kwargs: Any) -> AsyncGenerator[Connection, None]:
|
|
73
|
+
async def provide_connection(self, *args: "Any", **kwargs: "Any") -> "AsyncGenerator[Connection, None]":
|
|
76
74
|
"""Create and provide a database connection.
|
|
77
75
|
|
|
78
76
|
Yields:
|