notifications-api icon indicating copy to clipboard operation
notifications-api copied to clipboard

Enforce Static type checking on CI

Open DilwoarH opened this issue 1 month ago • 2 comments

What

This pull request introduces several improvements and refactorings across the codebase, with a focus on type safety, static type checking, and code clarity. The most significant changes include the addition of static type checks to the test workflow, enhanced type annotations throughout the Python code, and interface updates for email clients. Below is a summary of the most important changes grouped by theme.

Why

These changes collectively improve the codebase's maintainability, reliability, and readiness for static analysis.

Ticket

https://trello.com/c/52qyrWvq/1509-enforce-type-checking-at-ci-stage

DilwoarH avatar Nov 11 '25 13:11 DilwoarH

Should also consider not type checking files in app/migrations. We exclude them from other static analysis: https://github.com/alphagov/notifications-api/blob/e5ec819200270c43d8fb1f0e2c4882cc36d6564d/ruff.toml#L7

quis avatar Nov 12 '25 11:11 quis

I am running this branch on my computer, and make test is failing because of missing stubs ([import-untyped]) and an attribute error ([attr-defined]). You can also see these errors in the pipeline. You will probably need to fix the stub errors by running mypy --install-types in the make bootstrap command, and handle the attribute errors in the mypy.ini file.

spatel033 avatar Nov 13 '25 13:11 spatel033