Skip to content

Commit b87baad

Browse files
committed
Update line-length to 120 and update dependencies
1 parent 6a0dd9b commit b87baad

File tree

24 files changed

+174
-273
lines changed

24 files changed

+174
-273
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dev-dependencies:
3737

3838
update-dependencies:
3939
uv lock --upgrade
40+
uv sync --all-groups --frozen
4041

4142
migrate:
4243
uv run alembic upgrade heads

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ testpaths = [
116116

117117
[tool.ruff]
118118
target-version = "py39"
119+
line-length = 120
119120
extend-exclude = [
120121
"docs",
121122
]

src/common/di_container.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,4 @@ def function(
6565
bind=SQLAlchemyBindManager.provided.get_bind.call(),
6666
model_class=BookModel,
6767
)
68-
BookEventGatewayInterface: Factory[BookEventGatewayInterface] = Factory(
69-
NullEventGateway
70-
)
68+
BookEventGatewayInterface: Factory[BookEventGatewayInterface] = Factory(NullEventGateway)

src/common/dramatiq.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def decode(self, data: bytes) -> MessageData:
2222
try:
2323
return orjson.loads(data)
2424
except orjson.JSONDecodeError as e:
25-
raise DecodeError(
26-
"failed to decode message %r" % (data,), data, e
27-
) from None
25+
raise DecodeError("failed to decode message %r" % (data,), data, e) from None
2826

2927

3028
def init_dramatiq(config: AppConfig):

src/common/logs/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def init_logger(config: AppConfig) -> None:
4444

4545
log_level = logging.DEBUG if config.DEBUG else logging.INFO
4646
if config.ENVIRONMENT in ["local", "test"]:
47-
shared_processors.append(
48-
structlog.processors.TimeStamper(fmt="%d-%m-%Y %H:%M:%S", utc=True)
49-
)
47+
shared_processors.append(structlog.processors.TimeStamper(fmt="%d-%m-%Y %H:%M:%S", utc=True))
5048
stdlib_processors.append(structlog.dev.ConsoleRenderer())
5149
else:
5250
shared_processors.append(structlog.processors.TimeStamper(fmt="iso", utc=True))

src/common/utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
def apply_decorator_to_methods(
2-
decorator, protected_methods: bool = False, private_methods: bool = False
3-
):
1+
def apply_decorator_to_methods(decorator, protected_methods: bool = False, private_methods: bool = False):
42
"""
53
Class decorator to apply a given function or coroutine decorator
64
to all functions and coroutines within a class.

src/domains/books/_gateway_interfaces.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ async def save(self, book: BookModel) -> BookModel: ...
1212
async def find(
1313
self,
1414
search_params: Union[None, Mapping[str, Any]] = None,
15-
order_by: Union[
16-
None, Iterable[Union[str, Tuple[str, Literal["asc", "desc"]]]]
17-
] = None,
15+
order_by: Union[None, Iterable[Union[str, Tuple[str, Literal["asc", "desc"]]]]] = None,
1816
) -> List[BookModel]: ...
1917

2018

src/domains/books/_service.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ class BookService:
2222
@inject
2323
def __init__(
2424
self,
25-
book_repository: BookRepositoryInterface = Provide[
26-
BookRepositoryInterface.__name__
27-
],
28-
event_gateway: BookEventGatewayInterface = Provide[
29-
BookEventGatewayInterface.__name__
30-
],
25+
book_repository: BookRepositoryInterface = Provide[BookRepositoryInterface.__name__],
26+
event_gateway: BookEventGatewayInterface = Provide[BookEventGatewayInterface.__name__],
3127
) -> None:
3228
super().__init__()
3329
self._book_repository = book_repository
@@ -37,14 +33,10 @@ async def create_book(self, book: BookData) -> Book:
3733
# Example of CPU intensive task ran in a different thread
3834
# Using processes could be better, but it would bring technical complexity
3935
# https://anyio.readthedocs.io/en/3.x/subprocesses.html#running-functions-in-worker-processes
40-
book_data_altered: dict = await to_thread.run_sync(
41-
self._some_cpu_intensive_blocking_task, book.model_dump()
42-
)
36+
book_data_altered: dict = await to_thread.run_sync(self._some_cpu_intensive_blocking_task, book.model_dump())
4337

4438
book_model = BookModel(**book_data_altered)
45-
book = Book.model_validate(
46-
await self._book_repository.save(book_model), from_attributes=True
47-
)
39+
book = Book.model_validate(await self._book_repository.save(book_model), from_attributes=True)
4840

4941
# Example of CPU intensive task ran in a dramatiq task. We should not rely on
5042
# dramatiq if we need to wait the operation result.
@@ -53,9 +45,7 @@ async def create_book(self, book: BookData) -> Book:
5345
book_cpu_intensive_task.send(book_id=str(book.book_id))
5446

5547
await self._event_gateway.emit(
56-
BookCreatedV1.event_factory(
57-
data=BookCreatedV1Data.model_validate(book_model, from_attributes=True)
58-
)
48+
BookCreatedV1.event_factory(data=BookCreatedV1Data.model_validate(book_model, from_attributes=True))
5949
)
6050
return book
6151

src/domains/books/events.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ class BookCreatedV1(CloudEvent):
2323
Field(default="/book_service", validate_default=True),
2424
metadata.FieldSource,
2525
]
26-
type: Annotated[
27-
Literal["book.created.v1"], Field(default="book.created.v1"), metadata.FieldType
28-
]
26+
type: Annotated[Literal["book.created.v1"], Field(default="book.created.v1"), metadata.FieldType]
2927
dataschema: Annotated[
3028
URI,
3129
Field(default=_dataschema_url("book.created.v1"), validate_default=True),
@@ -61,9 +59,7 @@ class BookUpdatedV1(CloudEvent):
6159
Field(default="/book_service", validate_default=True),
6260
metadata.FieldSource,
6361
]
64-
type: Annotated[
65-
Literal["book.updated.v1"], Field(default="book.updated.v1"), metadata.FieldType
66-
]
62+
type: Annotated[Literal["book.updated.v1"], Field(default="book.updated.v1"), metadata.FieldType]
6763
dataschema: Annotated[
6864
URI,
6965
Field(default=_dataschema_url("book.updated.v1"), validate_default=True),

src/gateways/event.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44

55
class NullEventGateway:
6-
async def emit(
7-
self, event: CloudEvent
8-
) -> None: # pragma: no cover # No need to test this
6+
async def emit(self, event: CloudEvent) -> None: # pragma: no cover # No need to test this
97
logger = get_logger()
108
await logger.ainfo(
119
"Event emitted",

0 commit comments

Comments
 (0)