Skip to content

Commit 41eb6ae

Browse files
committed
Fix mypy failure in Backend CI from django-stubs 6.0.3 upgrade
Two root causes introduced in quick succession during the 2026-04-23 batch of merges: 1. PR #1343 wired `Run mypy` into Backend CI with a per-module baseline in mypy.ini. The baseline captured every file that had type errors under django-stubs 6.0.2 (7208 errors across 357 files). 2. PR #1340 then bumped django-stubs 6.0.2 -> 6.0.3 in requirements/local.txt. 6.0.3's stricter ValuesQuerySet typing surfaced a new error on validate_v3_migration.py:303 -- a file that was type-clean under 6.0.2 and therefore NOT in the baseline. Result: Backend CI `linter` job fails on main and every PR branched off main. Additionally, the mirrors-mypy pre-commit hook still pinned django-stubs==6.0.2 while CI's `Run mypy` step installs 6.0.3 from requirements/local.txt -- the exact hook/CI drift that the comment above `additional_dependencies` warns against. This let the new error slip past pre-commit. Fix: - validate_v3_migration.py: use `.values_list("content_hash", "count")` so the loop yields a typed tuple instead of relying on subscripting an annotated ValuesQuerySet (which 6.0.3 types as an annotated model rather than a dict). Functionally identical; zero behaviour change. - .pre-commit-config.yaml: bump django-stubs pin to 6.0.3 so the hook and CI check against the same stub version again.
1 parent 55b6185 commit 41eb6ae

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ repos:
6161
# major breakages (e.g. pypdf 7, openai 3) for the same reason.
6262
additional_dependencies:
6363
# --- Type stubs -----------------------------------------------
64-
- django-stubs==6.0.2
64+
- django-stubs==6.0.3
6565
- djangorestframework-stubs==3.16.9
6666
- types-requests==2.33.0.20260408
6767
- types-PyYAML==6.0.12.20260408

opencontractserver/documents/management/commands/validate_v3_migration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,11 @@ def _check_structural_set_uniqueness(self, verbose):
298298
)
299299

300300
if verbose:
301-
for dup in duplicates[:5]:
301+
for content_hash, count in duplicates.values_list(
302+
"content_hash", "count"
303+
)[:5]:
302304
self.stdout.write(
303-
f" - Hash {dup['content_hash'][:16]}...: {dup['count']} duplicates"
305+
f" - Hash {content_hash[:16]}...: {count} duplicates"
304306
)
305307

306308
return {"passed": False, "duplicate_hashes": duplicate_count}

0 commit comments

Comments
 (0)