From 719072426094618a32fc0c42e6bcea133e45ad1f Mon Sep 17 00:00:00 2001 From: Alexander Hess Date: Tue, 1 Dec 2026 13:11:32 +0100 Subject: [PATCH] Enable the "possibly-undefined" error code --- pyproject.toml | 2 ++ src/velofy/console/gridify.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9643082..0d943dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -476,6 +476,8 @@ enable_error_code = [ "ignore-without-code", # Report overrides of mutable attributes with incompatible types "mutable-override", + # Report variables that may be used before they are assigned + "possibly-undefined", ] # Check further edge cases that are rarely an issue in practice diff --git a/src/velofy/console/gridify.py b/src/velofy/console/gridify.py index 9cc0591..9da5e5d 100644 --- a/src/velofy/console/gridify.py +++ b/src/velofy/console/gridify.py @@ -36,9 +36,10 @@ def gridify() -> None: # pragma: no cover note:b1f68d24 # Because the number of assigned addresses is the same across # different `side_length`s, we can take the last `grid` from the `city`. + last_grid_id = grid.id # type: ignore[possibly-undefined] n_assigned = ( db.session.query(db.AddressPixelAssociation) - .filter(db.AddressPixelAssociation.grid_id == grid.id) + .filter(db.AddressPixelAssociation.grid_id == last_grid_id) .count() ) click.echo(