Skip to content

Commit 33a7ebf

Browse files
committed
Fix typing
Signed-off-by: Federico Busetti <[email protected]>
1 parent 6a1e43d commit 33a7ebf

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ exclude_also = [
9797
[tool.mypy]
9898
files = ["src", "tests"]
9999
exclude = ["alembic"]
100-
plugins = "pydantic.mypy,strawberry.ext.mypy_plugin"
100+
# Pydantic plugin causes some issues
101+
#plugins = "pydantic.mypy,strawberry.ext.mypy_plugin"
102+
plugins = "strawberry.ext.mypy_plugin"
103+
python_version = "3.9"
101104

102105
# We can remove celery by installing `celery-types` but needs
103106
# at least python 3.10. For now we maintain the override.

src/bootstrap/bootstrap.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import cast
2+
13
from celery import Celery
24
from dependency_injector.containers import DynamicContainer
35
from dependency_injector.providers import Object
@@ -18,8 +20,11 @@ class InitReference(BaseModel):
1820

1921

2022
def application_init(app_config: AppConfig) -> InitReference:
21-
container = Container(
22-
config=Object(app_config),
23+
container = cast(
24+
DynamicContainer, # Make mypy happy
25+
Container(
26+
config=Object(app_config),
27+
),
2328
)
2429
init_logger(app_config)
2530
init_storage()

src/domains/books/_service.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ async def create_book(self, book: BookData) -> Book:
4949

5050
await self._event_gateway.emit(
5151
BookCreatedV1(
52-
data=BookCreatedV1Data(
53-
book_id=book_model.book_id,
54-
title=book_model.title,
55-
author_name=book_model.author_name,
56-
)
52+
data=BookCreatedV1Data.model_validate(book_model, from_attributes=True)
5753
)
5854
)
5955
return book

0 commit comments

Comments
 (0)