Make mypy work again #8

Merged
alexander merged 16 commits from fix-mypy into develop 2026-11-30 14:13:44 +01:00
Owner
  • Configure mypy properly
  • Fix all typing issues
  • Make mypy part of the nox session "lint"
- Configure `mypy` properly - Fix all typing issues - Make `mypy` part of the `nox` session "lint"
Since SQLAlchemy 2.0, `orm.mapped_column()` with an annotation
lets `mypy` see `pixel.id` as an `int` instead of a `Column[int]`.
`folium` has no type annotations, so every call into it counted as untyped
`rpy2` names the parameter `s`, so `_msg` did not match its signature
The test fixtures replace the `None` placeholders, and `velofy.configuration` already ensures that "DATABASE_URI" is set outside of tests
The `**kwargs` for `folium.Circle()` are not all strings
The last `grid` of the loop already belongs to the `city`,
and `.scalar()` returns the maximum or `None` without indexing a row
Like in the other modules
... because the `or` chain over nullable columns could return `None`
... because it shadowed the `restaurants` parameter, a `bool`
Like `Order.time_to_delivery` already does,
instead of failing with a `TypeError` on `None`
... instead of failing inside `json.loads()` on `None`
With the ORM columns annotated, `mypy` understands these lines on its own
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
`nox` and `pytest` are not imported in the package,
and the other libraries ship their own types by now
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`.
Remove the no longer used engine and connection globals
All checks were successful
CI / Checks (Python 3.13) (push) Successful in 1m52s
2b112f46e2
Only `session` is used in the package.
Bound to the `engine`, it connects on its first query
instead of when the package is imported.
alexander merged commit a85ba4c4c4 into develop 2026-11-30 14:13:44 +01:00
alexander deleted branch fix-mypy 2026-11-30 14:13:44 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
alexander/velofy!8
No description provided.