Make mypy as strict as practical #13
1 changed files with 15 additions and 5 deletions
Type the relationships of Address
commit
2e03e58716
|
|
@ -11,6 +11,7 @@ from sqlalchemy.dialects import postgresql as psql
|
|||
from sqlalchemy.ext import hybrid as sa_hybrid
|
||||
|
||||
from velofy import config as pkg_config
|
||||
from velofy import db
|
||||
from velofy.db import meta
|
||||
from velofy.db import utils
|
||||
|
||||
|
|
@ -104,19 +105,28 @@ class Address(meta.Base):
|
|||
)
|
||||
|
||||
# Relationships
|
||||
city = orm.relationship("City", back_populates="addresses")
|
||||
restaurants = orm.relationship("Restaurant", back_populates="address")
|
||||
orders_picked_up = orm.relationship(
|
||||
city: orm.Mapped["db.City"] = orm.relationship(
|
||||
"City",
|
||||
back_populates="addresses",
|
||||
)
|
||||
restaurants: orm.Mapped[list["db.Restaurant"]] = orm.relationship(
|
||||
"Restaurant",
|
||||
back_populates="address",
|
||||
)
|
||||
orders_picked_up: orm.Mapped[list["db.Order"]] = orm.relationship(
|
||||
"Order",
|
||||
back_populates="pickup_address",
|
||||
foreign_keys="[Order.pickup_address_id]",
|
||||
)
|
||||
orders_delivered = orm.relationship(
|
||||
orders_delivered: orm.Mapped[list["db.Order"]] = orm.relationship(
|
||||
"Order",
|
||||
back_populates="delivery_address",
|
||||
foreign_keys="[Order.delivery_address_id]",
|
||||
)
|
||||
pixels = orm.relationship("AddressPixelAssociation", back_populates="address")
|
||||
pixels: orm.Mapped[list["db.AddressPixelAssociation"]] = orm.relationship(
|
||||
"AddressPixelAssociation",
|
||||
back_populates="address",
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Non-literal text representation."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue