Remove the quotes from the type annotations
All checks were successful
CI / Tests (test-types) (push) Successful in 1m46s
CI / Tests (test) (push) Successful in 1m47s
CI / Tests (test-with-3.15) (push) Successful in 1m51s
CI / Lint (push) Successful in 2m8s

PEP 649 makes them unnecessary,
and `sqlalchemy` v2.1 resolves the lazy annotations of the models.
This commit is contained in:
Alexander Hess 2026-12-03 13:02:47 +01:00
commit 3b52ee0525
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
14 changed files with 22 additions and 22 deletions

View file

@ -105,25 +105,25 @@ class Address(meta.Base):
) )
# Relationships # Relationships
city: orm.Mapped["db.City"] = orm.relationship( city: orm.Mapped[db.City] = orm.relationship(
"City", "City",
back_populates="addresses", back_populates="addresses",
) )
restaurants: orm.Mapped[list["db.Restaurant"]] = orm.relationship( restaurants: orm.Mapped[list[db.Restaurant]] = orm.relationship(
"Restaurant", "Restaurant",
back_populates="address", back_populates="address",
) )
orders_picked_up: orm.Mapped[list["db.Order"]] = orm.relationship( orders_picked_up: orm.Mapped[list[db.Order]] = orm.relationship(
"Order", "Order",
back_populates="pickup_address", back_populates="pickup_address",
foreign_keys="[Order.pickup_address_id]", foreign_keys="[Order.pickup_address_id]",
) )
orders_delivered: orm.Mapped[list["db.Order"]] = orm.relationship( orders_delivered: orm.Mapped[list[db.Order]] = orm.relationship(
"Order", "Order",
back_populates="delivery_address", back_populates="delivery_address",
foreign_keys="[Order.delivery_address_id]", foreign_keys="[Order.delivery_address_id]",
) )
pixels: orm.Mapped[list["db.AddressPixelAssociation"]] = orm.relationship( pixels: orm.Mapped[list[db.AddressPixelAssociation]] = orm.relationship(
"AddressPixelAssociation", "AddressPixelAssociation",
back_populates="address", back_populates="address",
) )

View file

@ -180,7 +180,7 @@ class Path(meta.Base):
return paths return paths
@classmethod @classmethod
def from_order(cls, order: "db.Order", *, google_maps: bool = False) -> t.Self: def from_order(cls, order: db.Order, *, google_maps: bool = False) -> t.Self:
"""Calculate the path for an `Order` object. """Calculate the path for an `Order` object.
The path goes from the `Order.pickup_address` to the `Order.delivery_address`. The path goes from the `Order.pickup_address` to the `Order.delivery_address`.

View file

@ -69,7 +69,7 @@ class AddressPixelAssociation(meta.Base):
"Address", "Address",
back_populates="pixels", back_populates="pixels",
) )
pixel: orm.Mapped["db.Pixel"] = orm.relationship( pixel: orm.Mapped[db.Pixel] = orm.relationship(
"Pixel", "Pixel",
back_populates="addresses", back_populates="addresses",
) )

View file

@ -69,11 +69,11 @@ class City(meta.Base):
"Address", "Address",
back_populates="city", back_populates="city",
) )
grids: orm.Mapped[list["db.Grid"]] = orm.relationship( grids: orm.Mapped[list[db.Grid]] = orm.relationship(
"Grid", "Grid",
back_populates="city", back_populates="city",
) )
replays: orm.Mapped[list["db.ReplaySimulation"]] = orm.relationship( replays: orm.Mapped[list[db.ReplaySimulation]] = orm.relationship(
"ReplaySimulation", "ReplaySimulation",
back_populates="city", back_populates="city",
) )

View file

@ -69,7 +69,7 @@ class Courier(meta.Base):
) )
# Relationships # Relationships
orders: orm.Mapped[list["db.Order"]] = orm.relationship( orders: orm.Mapped[list[db.Order]] = orm.relationship(
"Order", "Order",
back_populates="courier", back_populates="courier",
) )

View file

@ -28,7 +28,7 @@ class Customer(meta.Base):
return f"<{self.__class__.__name__}(#{self.id})>" return f"<{self.__class__.__name__}(#{self.id})>"
# Relationships # Relationships
orders: orm.Mapped[list["db.Order"]] = orm.relationship( orders: orm.Mapped[list[db.Order]] = orm.relationship(
"Order", "Order",
back_populates="customer", back_populates="customer",
) )

View file

@ -175,7 +175,7 @@ class Forecast(meta.Base):
) )
# Relationships # Relationships
pixel: orm.Mapped["db.Pixel"] = orm.relationship( pixel: orm.Mapped[db.Pixel] = orm.relationship(
"Pixel", "Pixel",
back_populates="forecasts", back_populates="forecasts",
) )
@ -190,7 +190,7 @@ class Forecast(meta.Base):
@classmethod @classmethod
def from_dataframe( def from_dataframe(
cls, cls,
pixel: "db.Pixel", pixel: db.Pixel,
time_step: int, time_step: int,
train_horizon: int, train_horizon: int,
model: str, model: str,

View file

@ -54,7 +54,7 @@ class Grid(meta.Base):
"City", "City",
back_populates="grids", back_populates="grids",
) )
pixels: orm.Mapped[list["db.Pixel"]] = orm.relationship( pixels: orm.Mapped[list[db.Pixel]] = orm.relationship(
"Pixel", "Pixel",
back_populates="grid", back_populates="grid",
) )

View file

@ -497,7 +497,7 @@ class Order(meta.Base):
"Customer", "Customer",
back_populates="orders", back_populates="orders",
) )
restaurant: orm.Mapped["db.Restaurant"] = orm.relationship( restaurant: orm.Mapped[db.Restaurant] = orm.relationship(
"Restaurant", "Restaurant",
back_populates="orders", back_populates="orders",
primaryjoin="Restaurant.id == Order.restaurant_id", primaryjoin="Restaurant.id == Order.restaurant_id",
@ -516,7 +516,7 @@ class Order(meta.Base):
back_populates="orders_delivered", back_populates="orders_delivered",
foreign_keys="[Order.delivery_address_id]", foreign_keys="[Order.delivery_address_id]",
) )
replays: orm.Mapped[list["db.ReplayedOrder"]] = orm.relationship( replays: orm.Mapped[list[db.ReplayedOrder]] = orm.relationship(
"ReplayedOrder", "ReplayedOrder",
back_populates="actual", back_populates="actual",
) )

View file

@ -138,7 +138,7 @@ class Pixel(meta.Base):
return location return location
@functools.cached_property @functools.cached_property
def restaurants(self) -> list["db.Restaurant"]: # pragma: no cover def restaurants(self) -> list[db.Restaurant]: # pragma: no cover
"""Obtain all `Restaurant`s in `self`.""" """Obtain all `Restaurant`s in `self`."""
return list( return list(
db.session.scalars( db.session.scalars(

View file

@ -376,7 +376,7 @@ class ReplayedOrder(meta.Base):
) )
# Relationships # Relationships
simulation: orm.Mapped["db.ReplaySimulation"] = orm.relationship( simulation: orm.Mapped[db.ReplaySimulation] = orm.relationship(
"ReplaySimulation", "ReplaySimulation",
back_populates="orders", back_populates="orders",
) )
@ -400,7 +400,7 @@ class ReplayedOrder(meta.Base):
return self.actual.customer return self.actual.customer
@property @property
def restaurant(self) -> "db.Restaurant": def restaurant(self) -> db.Restaurant:
"""`.restaurant` of the actual `Order`.""" """`.restaurant` of the actual `Order`."""
return self.actual.restaurant return self.actual.restaurant

View file

@ -55,7 +55,7 @@ class ReplaySimulation(meta.Base):
"City", "City",
back_populates="replays", back_populates="replays",
) )
orders: orm.Mapped[list["db.ReplayedOrder"]] = orm.relationship( orders: orm.Mapped[list[db.ReplayedOrder]] = orm.relationship(
"ReplayedOrder", "ReplayedOrder",
back_populates="simulation", back_populates="simulation",
) )

View file

@ -129,7 +129,7 @@ class Location:
return self._normalized_northing return self._normalized_northing
def relate_to(self, other: "Location") -> None: def relate_to(self, other: Location) -> None:
"""Make the origin in the lower-left corner relative to `other`. """Make the origin in the lower-left corner relative to `other`.
The `.x` and `.y` properties are the `.easting` and `.northing` values The `.x` and `.y` properties are the `.easting` and `.northing` values

View file

@ -559,7 +559,7 @@ class OrderHistory:
pixel_id: int, pixel_id: int,
predict_day: dt.date, predict_day: dt.date,
train_horizon: int, train_horizon: int,
) -> "models.ForecastingModelABC": ) -> models.ForecastingModelABC:
"""Choose the most promising forecasting `*Model` for tactical purposes. """Choose the most promising forecasting `*Model` for tactical purposes.
The rules are deduced from "Table 1: Top-3 models by ..." in the article The rules are deduced from "Table 1: Top-3 models by ..." in the article