Type the relationships of ReplayedOrder
Also, move the `db` import to the top, which makes some quotes unnecessary
This commit is contained in:
parent
699e7f0443
commit
4be6078327
1 changed files with 15 additions and 9 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue