[MAINTENANCE] Add @override at the 106 sites mypy flags in the excluded library modules

Author: joshua-staufferCreated Sep 14, 2026Updated Sep 17, 2026
Labelshelp wantedgood first issuemaintenanceready-for-workclaimed🔔 reminder-sent

Part of #12188.

What to do

Add the @override decorator at every method mypy flags with explicit-override in the 45 library modules currently excluded from the type-check — 106 sites in 41 files — and change nothing else. Import it from great_expectations.compatibility.typing_extensions, never from typing_extensions directly (ruff's banned-API rule rejects the direct import).

This is a separate, decorator-only pull request on purpose: the two typing changes that follow (#12190, #12191) carry real signature decisions, and 106 mechanical decorator lines would dilute those reviews. Derive the site list from mypy's own diagnostics rather than by reading class hierarchies — a site mypy flags is an override by definition, so the sweep cannot mis-decorate a method that overrides nothing. Done means: under the measurement below, explicit-override reports zero, and the diff contains only decorator lines and their imports.

Where

  • great_expectations/expectations/core/*.py — 97 sites in 36 files.
  • great_expectations/render/renderer/*.py and render/renderer/content_block/*.py — 9 sites in 5 files.
  • pyproject.toml and scripts/mypy_relaxation_inventory.jsonunchanged in the committed diff. You edit them locally to see the diagnostics (below) and revert before committing; lifting the exclusions is #12190 and #12191.

How to verify

Files named on mypy's command line are checked even when an exclude pattern covers them, so this runs against the 45 modules without touching pyproject.toml; --cache-dir=/dev/null keeps the count independent of whatever an earlier run left in .mypy_cache:

bash
mypy --cache-dir=/dev/null --warn-unused-ignores --disallow-untyped-decorators great_expectations/expectations/core/*.py great_expectations/render/renderer/*.py great_expectations/render/renderer/content_block/*.py > /tmp/mypy-library.txt || true
grep -c 'explicit-override' /tmp/mypy-library.txt
! grep -q 'explicit-override' /tmp/mypy-library.txt

Before: the count prints 106 and the last line exits 1 (at 3798c021b; the run's total is 272 errors — the other 166 are #12190 and #12191's work, leave them). After: the count prints 0 and the last line exits 0; the same 166 remain; pytest tests/expectations/core tests/render passes as it does today; git diff --stat lists only .py files under the two directories above.

Requirements

  1. When the 45 exclusions are lifted locally and invoke type-check --ci runs on the merged change, it reports no explicit-override error.
  2. The committed diff must contain only @override decorator lines and from great_expectations.compatibility.typing_extensions import override imports — no signature, annotation, body, or ordering change anywhere.
  3. pytest tests/expectations/core tests/render must pass with the same outcomes as before, with no test modified.
  4. Data Docs built from the same input before and after the change must be byte-identical apart from run ids and timestamps (this is a decorator-only diff, so the check is expected to be trivially clean — say in the PR that you ran it).
  5. If a flagged site cannot take the decorator mechanically — a property, a nested override, anything the pattern does not fit — resolve it by hand and list it in the PR.

Out of scope: removing any exclude pattern (#12190, #12191); any type fix or signature change; the follow_imports = 'silent' block (#12192); anything under tests/ (#12128) or contrib/.

Order

  • Blocks #12190 — the expectation-core lift's review should contain only real typing decisions.

Notes

  • The exclusion patterns are relative and unanchored: 'expectations/core/expect_column_values_to_be_null\.py', with no great_expectations/ prefix. Search the exclude list for expectations/core/ and render/renderer/, not for the full path.
  • 24 of the 36 expectations/core/ files already import override from the compatibility module; add the import only where it is missing.
  • The shipped check cannot see these files, so CI on this PR proves ruff and the test suites, not the 106 → 0 — that is why the measurement above lifts the exclusions locally. #12190 and #12191 re-prove it when the files enter the checked set.

Source: fivetran/great_expectations