Replace the __future__ imports ...
... with quoted annotations where needed
This commit is contained in:
parent
ef0888619e
commit
cd74b343bc
11 changed files with 18 additions and 40 deletions
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Address` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import functools
|
||||
import typing as t
|
||||
|
|
@ -171,7 +169,7 @@ class Address(meta.Base):
|
|||
"""
|
||||
return self.location.y
|
||||
|
||||
def clear_map(self) -> Address: # pragma: no cover
|
||||
def clear_map(self) -> "Address": # pragma: no cover
|
||||
"""Shortcut to the `.city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Model for the `Path` relationship between two `Address` objects."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import itertools
|
||||
import json
|
||||
|
|
@ -126,7 +124,7 @@ class Path(meta.Base):
|
|||
cls,
|
||||
*addresses: db.Address,
|
||||
google_maps: bool = False,
|
||||
) -> list[Path]:
|
||||
) -> list["Path"]:
|
||||
"""Calculate pair-wise paths for `Address` objects.
|
||||
|
||||
This is the main constructor method for the class.
|
||||
|
|
@ -183,7 +181,7 @@ class Path(meta.Base):
|
|||
return paths
|
||||
|
||||
@classmethod
|
||||
def from_order(cls, order: db.Order, *, google_maps: bool = False) -> Path:
|
||||
def from_order(cls, order: "db.Order", *, google_maps: bool = False) -> "Path":
|
||||
"""Calculate the path for an `Order` object.
|
||||
|
||||
The path goes from the `Order.pickup_address` to the `Order.delivery_address`.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `City` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
|
||||
import folium
|
||||
|
|
@ -120,7 +118,7 @@ class City(meta.Base):
|
|||
"""
|
||||
return self.northeast.northing - self.southwest.northing
|
||||
|
||||
def clear_map(self) -> City: # pragma: no cover
|
||||
def clear_map(self) -> "City": # pragma: no cover
|
||||
"""Create a new `folium.Map` object aligned with the city's viewport.
|
||||
|
||||
The map is available via the `.map` property. Note that it is mutable
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Customer` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import folium
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
|
@ -30,7 +28,7 @@ class Customer(meta.Base):
|
|||
# Relationships
|
||||
orders = orm.relationship("Order", back_populates="customer")
|
||||
|
||||
def clear_map(self) -> Customer: # pragma: no cover
|
||||
def clear_map(self) -> "Customer": # pragma: no cover
|
||||
"""Shortcut to the `...city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Forecast` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import math
|
||||
|
||||
|
|
@ -187,12 +185,12 @@ class Forecast(meta.Base):
|
|||
@classmethod
|
||||
def from_dataframe(
|
||||
cls,
|
||||
pixel: db.Pixel,
|
||||
pixel: "db.Pixel",
|
||||
time_step: int,
|
||||
train_horizon: int,
|
||||
model: str,
|
||||
data: pd.DataFrame,
|
||||
) -> list[db.Forecast]:
|
||||
) -> list["db.Forecast"]:
|
||||
"""Convert results from the forecasting `*Model`s into `Forecast` objects.
|
||||
|
||||
This is an alternative constructor method.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Grid` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import typing as t
|
||||
|
||||
import folium
|
||||
|
|
@ -67,7 +65,7 @@ class Grid(meta.Base):
|
|||
return round((self.side_length**2) / 1_000_000, 1)
|
||||
|
||||
@classmethod
|
||||
def gridify(cls, city: db.City, side_length: int) -> db.Grid:
|
||||
def gridify(cls, city: db.City, side_length: int) -> "db.Grid":
|
||||
"""Create a fully populated `Grid` for a `city`.
|
||||
|
||||
The `Grid` contains only `Pixel`s that have at least one
|
||||
|
|
@ -122,7 +120,7 @@ class Grid(meta.Base):
|
|||
|
||||
return grid
|
||||
|
||||
def clear_map(self) -> Grid: # pragma: no cover
|
||||
def clear_map(self) -> "Grid": # pragma: no cover
|
||||
"""Shortcut to the `.city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Pixel` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
|
||||
import folium
|
||||
|
|
@ -130,7 +128,7 @@ class Pixel(meta.Base):
|
|||
return location
|
||||
|
||||
@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`."""
|
||||
return (
|
||||
db.session.query(db.Restaurant)
|
||||
|
|
@ -142,7 +140,7 @@ class Pixel(meta.Base):
|
|||
.all()
|
||||
)
|
||||
|
||||
def clear_map(self) -> Pixel: # pragma: no cover
|
||||
def clear_map(self) -> "Pixel": # pragma: no cover
|
||||
"""Shortcut to the `.city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `ReplayedOrder` model for the replay simulations."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
|
||||
import sqlalchemy as sa
|
||||
|
|
@ -409,22 +407,22 @@ 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
|
||||
|
||||
@property
|
||||
def restaurant(self) -> db.Restaurant:
|
||||
def restaurant(self) -> "db.Restaurant":
|
||||
"""`.restaurant` of the actual `Order`."""
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Provide the ORM's `Restaurant` model."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
|
||||
import folium
|
||||
|
|
@ -75,7 +73,7 @@ class Restaurant(meta.Base):
|
|||
"""Non-literal text representation."""
|
||||
return f"<{self.__class__.__name__}({self.name})>"
|
||||
|
||||
def clear_map(self) -> Restaurant: # pragma: no cover
|
||||
def clear_map(self) -> "Restaurant": # pragma: no cover
|
||||
"""Shortcut to the `.address.city.clear_map()` method.
|
||||
|
||||
Returns:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""A `Location` class to unify working with coordinates."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import utm
|
||||
|
||||
|
||||
|
|
@ -132,7 +130,7 @@ class Location:
|
|||
|
||||
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`.
|
||||
|
||||
The `.x` and `.y` properties are the `.easting` and `.northing` values
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
"""Obtain and work with time series data."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import typing as t
|
||||
|
||||
|
|
@ -566,7 +564,7 @@ class OrderHistory:
|
|||
pixel_id: int,
|
||||
predict_day: dt.date,
|
||||
train_horizon: int,
|
||||
) -> models.ForecastingModelABC:
|
||||
) -> "models.ForecastingModelABC":
|
||||
"""Choose the most promising forecasting `*Model` for tactical purposes.
|
||||
|
||||
The rules are deduced from "Table 1: Top-3 models by ..." in the article
|
||||
|
|
|
|||
Loading…
Reference in a new issue