Commit graph

485 commits

Author SHA1 Message Date
54e21109e7
Query with select() in Restaurant
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The delivery addresses are now selected with a subquery in one statement.
2026-12-01 23:37:57 +01:00
9d2a4139b7
Query with select() in City
`Session.query()` is the legacy API in SQLAlchemy 2.x.

The addresses with restaurants are now selected with a subquery in one statement.
2026-12-01 23:35:21 +01:00
53e1859ee8
Query with select() in Grid and Path
`Session.query()` is the legacy API in SQLAlchemy 2.x.

Unlike `Query`, `select()` does not deduplicate single entities from a `JOIN`;
so, `Grid.gridify()` calls `.unique()` explicitly.

The `addresses_mock` fixtures mock the new call chain.
2026-12-01 23:29:39 +01:00
1f5a39f83a
Query with select() in velofy.console
`Session.query()` is the legacy API in SQLAlchemy 2.x.
2026-12-01 23:21:00 +01:00
c1f04c65aa
Count rows with select() in the tests
`Session.query()` is the legacy API in SQLAlchemy 2.x.
2026-12-01 23:17:57 +01:00
455af6dfdb
Merge branch 'orm-review' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m46s
Reviewed-on: #16
2026-12-01 23:06:03 +01:00
248c1ae600
Ignore the foreign keys into the original data
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
The migrations create foreign keys from the `CLEAN_SCHEMA`
into the `ORIGINAL_SCHEMA` to ensure the cleaned data still
refer to the original data.

The ORM models do not know the original tables.
Also, print the `diff` as indented JSON.
2026-12-01 22:58:01 +01:00
25ed8c744b
Recreate checks stored by an old PostgreSQL version
Before version 14, PostgreSQL stored `EXTRACT(...)` as `date_part(...)`,
and the rendering of `IN (...)` changed as well.

The checks created in 2021 express the same rules as the ORM models
but render differently. See the docstring of the migration for details.
2026-12-01 22:56:12 +01:00
69d3be4a53
Rename constraints to follow the naming convention
Earlier migrations named some constraints without `op.f()`,
a column rename did not rename the unique constraint containing the column,
and the "ordered_timestamps_N" checks in "orders" were shifted by one
compared to the ORM.

See the docstring of the migration for details.
2026-12-01 22:49:36 +01:00
7d53abc057
Avoid lazy loads in .__repr__()
`ReplaySimulation`, `ReplayedOrder`, and `Forecast` accessed
relationships in their `.__repr__()`, which emits queries
or fails for detached instances.

They now use the foreign key columns.
2026-12-01 22:34:38 +01:00
1f9d0effae
Cache City.map with functools.cached_property
This replaces the manual caching in the uninitialized
`._map` attribute with a `hasattr()` check.

`.clear_map()` now only discards the cached map.
2026-12-01 22:27:28 +01:00
2a627072d8
Make grids.side_length not nullable
The ORM always defined `Grid.side_length` with `nullable=False`,
but the migration that created the "grids" table did not; the
live database contains no `NULL`s.
2026-12-01 22:20:06 +01:00
db2e00216d
Simplify the docstrings of the migrations
The "Revision" and "Revises" lines and the revision hashes in `upgrade()`
and `downgrade()` repeated the `revision` and `down_revision` variables;
the creation date is in the file name.
2026-12-01 22:20:06 +01:00
f532aae588
Test grids with the same side length in different cities
Regression test for the removed `unique=True` on `Grid.side_length`.
2026-12-01 22:20:06 +01:00
b36a3d1cd6
Allow the same Grid.side_length across cities
The `unique=True` on `Grid.side_length`
made the side length unique across all cities.

The intended rule is the `UniqueConstraint("city_id", "side_length")`,
which the migrations already implement; so, no migration is needed.
2026-12-01 21:58:29 +01:00
731299bb6e
Add nox session "verify-db-objects"
The new "verify-db-objects" session creates the ORM objects
with `.create_all()` in a temporary database and compares
them with the `CLEAN_SCHEMA` of a "live" database using `sqlalchemy-diff`
2026-12-01 21:53:31 +01:00
69b9d53704
Merge branch 'add-typeguard' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m47s
Reviewed-on: #15
2026-12-01 17:54:25 +01:00
cfd8d33049
Rename the "doctest" session into "test-docstrings"
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m46s
2026-12-01 17:14:48 +01:00
f47c87f51f
Add the "test-types" session as a pre-commit hook 2026-12-01 17:14:47 +01:00
2f313e7e3a
Pull out the TEST_DEPENDENCIES 2026-12-01 17:13:14 +01:00
5f7d3108de
Check the type annotations at runtime with typeguard 2026-12-01 17:07:00 +01:00
893b6bd8f1
Seed the random fake data in the tests 2026-12-01 15:51:24 +01:00
e4711875ca
Use a pd.DataFrame as the sentinel in test_totals_is_cached 2026-12-01 15:46:54 +01:00
f92fd35ce3
Revert to bare pd.Series in OrderHistory
`typeguard` evaluates the annotations at runtime where `pd.Series[int]` raises a `TypeError`
2026-12-01 15:31:58 +01:00
8abc93987e
Generate the fake coordinates as floats
Also, remove the misleading comment in `Location`
2026-12-01 15:27:53 +01:00
3b8b041a3e
Merge branch 'add-pyright' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m2s
Reviewed-on: #14
2026-12-01 15:18:18 +01:00
9a0dbb8ad8
Introduce TYPECHECK_LOCATIONS in the noxfile
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 2m2s
2026-12-01 15:05:54 +01:00
96b5a07f20
Add pyright to the "lint" session 2026-12-01 15:00:26 +01:00
66265c8808
Pass an explicit empty list to OrderedSet() 2026-12-01 14:50:16 +01:00
804a4a0966
Iterate over the rows in Forecast.from_dataframe() 2026-12-01 14:49:15 +01:00
77806b14b9
Declare the name of the forecasting models as a class variable 2026-12-01 14:45:37 +01:00
c74a7b81f1
Merge branch 'stricter-mypy' into develop
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m56s
Reviewed-on: #13
2026-12-01 14:26:52 +01:00
081d6f7fd9
Type the time series of OrderHistory as pd.Series[int]
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m55s
2026-12-01 14:23:14 +01:00
d6b798a736
Type-check scripts/ 2026-12-01 14:05:34 +01:00
f7a6aa1881
Type-check noxfile.py 2026-12-01 14:03:44 +01:00
369957c06b
Narrow the untyped calls of folium.PolyLine 2026-12-01 13:38:00 +01:00
883a3ab8cc
Enable the "truthy-iterable" error code 2026-12-01 13:11:47 +01:00
9da2d0b703
Enable the "truthy-bool" error code 2026-12-01 13:11:46 +01:00
fef268321a
Enable the "redundant-expr" error code 2026-12-01 13:11:45 +01:00
7190724260
Enable the "possibly-undefined" error code 2026-12-01 13:11:32 +01:00
dafc695693
Enable the "mutable-override" error code 2026-12-01 13:11:31 +01:00
a4c1574135
Enable the "deprecated" error code 2026-12-01 13:11:30 +01:00
784d5c8ca0
Enable "warn_unreachable"
Also, remove the dead `isinstance()` check in `Location.relate_to()`
2026-12-01 13:07:53 +01:00
0a5f8f6c55
Enable "warn_return_any" 2026-12-01 12:39:45 +01:00
bbc00e2f1c
Enable "disallow_any_unimported" 2026-12-01 12:39:44 +01:00
0d2aab4211
Use t.Self for methods returning their own class 2026-12-01 12:38:04 +01:00
76982126f4
Type the relationships of Restaurant 2026-12-01 12:38:04 +01:00
5ad3fb538d
Type the relationships of ReplaySimulation 2026-12-01 12:38:04 +01:00
4be6078327
Type the relationships of ReplayedOrder
Also, move the `db` import to the top, which makes some quotes unnecessary
2026-12-01 12:38:03 +01:00
699e7f0443
Type the relationships of Pixel 2026-12-01 12:38:03 +01:00