Make mypy work again #8

Merged
alexander merged 16 commits from fix-mypy into develop 2026-11-30 14:13:44 +01:00

2026-11-30

Remove the no longer used engine and connection globals
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m52s
Only `session` is used in the package.
Bound to the `engine`, it connects on its first query
instead of when the package is imported.
2026-11-30 14:03:26 +01:00
Query order history via the db.session
The query then runs in the same transaction as the `db.session`

For that, `addresses_mock` now replaces only `session.query()`
instead of the whole `db.session`.
2026-11-30 13:59:34 +01:00
Remove obsolete exceptions from the mypy config
`nox` and `pytest` are not imported in the package,
and the other libraries ship their own types by now
2026-11-30 13:23:29 +01:00
Run mypy in the "lint" session
It needs the dependencies of `velofy` installed,
and it now also reports "# type: ignore" comments without an error code
or that are not needed anymore
2026-11-30 13:15:27 +01:00
Remove no longer needed "# type: ignore" comments
With the ORM columns annotated, `mypy` understands these lines on its own
2026-11-30 13:11:52 +01:00
Raise an error if Path._directions is not set ...
... instead of failing inside `json.loads()` on `None`
2026-11-30 12:50:31 +01:00
Raise an error if an Order timestamp is not set
Like `Order.time_to_delivery` already does,
instead of failing with a `TypeError` on `None`
2026-11-30 12:43:33 +01:00
Rename the restaurants list ...
... because it shadowed the `restaurants` parameter, a `bool`
2026-11-30 12:33:17 +01:00
Return a bool from Order.corrected ...
... because the `or` chain over nullable columns could return `None`
2026-11-30 12:29:09 +01:00
Avoid queries that may return None
The last `grid` of the loop already belongs to the `city`,
and `.scalar()` returns the maximum or `None` without indexing a row
2026-11-30 11:39:56 +01:00
Annotate the defaults in Address.draw()
The `**kwargs` for `folium.Circle()` are not all strings
2026-11-30 11:38:27 +01:00
Type the database placeholders for mypy
The test fixtures replace the `None` placeholders, and `velofy.configuration` already ensures that "DATABASE_URI" is set outside of tests
2026-11-30 11:36:01 +01:00
Accept any arguments in the R console callbacks
`rpy2` names the parameter `s`, so `_msg` did not match its signature
2026-11-30 11:33:59 +01:00
Exclude folium from the "untyped-call" check
`folium` has no type annotations, so every call into it counted as untyped
2026-11-30 11:33:19 +01:00
Annotate the ORM columns with orm.Mapped
Since SQLAlchemy 2.0, `orm.mapped_column()` with an annotation
lets `mypy` see `pixel.id` as an `int` instead of a `Column[int]`.
2026-11-30 11:22:04 +01:00