Skip to content

Commit b6cf024

Browse files
authored
Merge pull request #15 from gravy-jones-locker/annotation-handling
Implemented Annotation Handling
2 parents 0aaa4d8 + 5e9eeeb commit b6cf024

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ exclude: '^docs/conf.py'
22

33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
5+
rev: v4.4.0
66
hooks:
77
- id: trailing-whitespace
88
- id: check-added-large-files
@@ -28,18 +28,18 @@ repos:
2828
# --remove-unused-variables,
2929
# ]
3030
- repo: https://github.com/hadialqattan/pycln
31-
rev: v2.1.1
31+
rev: v2.1.3
3232
hooks:
3333
- id: pycln
3434
args: [--config=setup.cfg]
3535

3636
- repo: https://github.com/pycqa/isort
37-
rev: 5.10.1
37+
rev: 5.12.0
3838
hooks:
3939
- id: isort
4040

4141
- repo: https://github.com/psf/black
42-
rev: 22.8.0
42+
rev: 23.3.0
4343
hooks:
4444
- id: black
4545
language_version: python3
@@ -52,7 +52,7 @@ repos:
5252
# additional_dependencies: [black]
5353

5454
- repo: https://github.com/PyCQA/flake8
55-
rev: 5.0.4
55+
rev: 6.0.0
5656
hooks:
5757
- id: flake8
5858
## You can add flake8 plugins via `additional_dependencies`:

src/strawberry_sqlalchemy_mapper/mapper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,18 @@ def convert(type_: Any) -> Any:
617617
continue
618618
if key in mapper.columns or key in mapper.relationships:
619619
continue
620-
if isinstance(descriptor, AssociationProxy):
620+
if key in model.__annotations__:
621+
annotation = eval(model.__annotations__[key])
622+
for (
623+
sqlalchemy_type,
624+
strawberry_type,
625+
) in self.sqlalchemy_type_to_strawberry_type_map.items():
626+
if isinstance(annotation, sqlalchemy_type):
627+
self._add_annotation(
628+
type_, key, strawberry_type, generated_field_keys
629+
)
630+
break
631+
elif isinstance(descriptor, AssociationProxy):
621632
strawberry_type = self._get_association_proxy_annotation(
622633
mapper, key, descriptor
623634
)

0 commit comments

Comments
 (0)