Make mypy as strict as practical #13

Merged
alexander merged 32 commits from stricter-mypy into develop 2026-12-01 14:26:52 +01:00
Showing only changes of commit 4be6078327 - Show all commits

Type the relationships of ReplayedOrder

Also, move the `db` import to the top, which makes some quotes unnecessary
Alexander Hess 2026-12-01 11:14:29 +01:00
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -5,6 +5,7 @@ import datetime as dt
import sqlalchemy as sa
from sqlalchemy import orm
from velofy import db
from velofy.db import meta
@ -396,9 +397,17 @@ class ReplayedOrder(meta.Base):
)
# Relationships
simulation = orm.relationship("ReplaySimulation", back_populates="orders")
actual = orm.relationship("Order", back_populates="replays")
courier = orm.relationship("Courier")
simulation: orm.Mapped["db.ReplaySimulation"] = orm.relationship(
"ReplaySimulation",
back_populates="orders",
)
actual: orm.Mapped[db.Order] = orm.relationship(
"Order",
back_populates="replays",
)
courier: orm.Mapped[db.Courier | None] = orm.relationship(
"Courier",
)
def __repr__(self) -> str:
"""Non-literal text representation."""
@ -407,7 +416,7 @@ class ReplayedOrder(meta.Base):
# Convenience properties
@property
def customer(self) -> "db.Customer":
def customer(self) -> db.Customer:
"""`.customer` of the actual `Order`."""
return self.actual.customer
@ -417,14 +426,11 @@ class ReplayedOrder(meta.Base):
return self.actual.restaurant
@property
def pickup_address(self) -> "db.Address":
def pickup_address(self) -> db.Address:
"""`.pickup_address` of the actual `Order`."""
return self.actual.pickup_address
@property
def delivery_address(self) -> "db.Address":
def delivery_address(self) -> db.Address:
"""`.delivery_address` of the actual `Order`."""
return self.actual.delivery_address
from velofy import db # noqa:E402 isort:skip