Skip to content

Commit 1196fe6

Browse files
authored
Add the ty for type checking (#70)
1 parent aa61a31 commit 1196fe6

File tree

5 files changed

+157
-115
lines changed

5 files changed

+157
-115
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,11 @@ repos:
2323
- '-o'
2424
- 'requirements.txt'
2525
- '--no-hashes'
26+
27+
- repo: local
28+
hooks:
29+
- id: ty
30+
language: python
31+
name: ty
32+
pass_filenames: false
33+
entry: uv run ty check sqlalchemy_crud_plus

pyproject.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ repository = "https://github.com/fastapi-practices/sqlalchemy-crud-plus"
2828

2929
[dependency-groups]
3030
dev = [
31-
"pytest>=8.1.1",
32-
"aiosqlite>=0.20.0",
33-
"pytest-asyncio>=0.23.6",
31+
"pytest>=8.4.0",
32+
"aiosqlite>=0.21.0",
33+
"pytest-asyncio>=1.2.0",
34+
"ty>=0.0.1a23",
3435
]
3536
lint = [
36-
"pre-commit>=3.5.0",
37+
"pre-commit>=4.3.0",
3738
]
3839

3940
[tool.uv]

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ platformdirs==4.5.0
3131
pluggy==1.6.0
3232
# via pytest
3333
pre-commit==4.3.0
34-
pydantic==2.12.0
34+
pydantic==2.12.2
3535
# via sqlalchemy-crud-plus
36-
pydantic-core==2.41.1
36+
pydantic-core==2.41.4
3737
# via pydantic
3838
pygments==2.19.2
3939
# via pytest
@@ -46,6 +46,7 @@ sqlalchemy==2.0.44
4646
# via sqlalchemy-crud-plus
4747
tomli==2.3.0 ; python_full_version < '3.11'
4848
# via pytest
49+
ty==0.0.1a23
4950
typing-extensions==4.15.0
5051
# via
5152
# aiosqlite

sqlalchemy_crud_plus/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ def build_load_strategies(model: type[Model], load_strategies: LoadStrategies |
356356
try:
357357
attr = getattr(model, column)
358358
strategy_func = strategies_map.get(strategy_name)
359-
options.append(strategy_func(attr))
359+
if strategy_func:
360+
options.append(strategy_func(attr))
360361
except AttributeError:
361362
raise ModelColumnError(f'Invalid relationship column: {column}')
362363

0 commit comments

Comments
 (0)