typing: graduate the extract test domain out of the mypy baseline#1924
Conversation
Continues the mypy baseline drain (issue #1738, the #1331 -> #1335 -> #1447 cadence). After the config tail (#1748), tests.permissioning.* (#1768), and the annotation (#1776) / document (#1851) / corpus (#1866) / agent (#1877) leaf-file chunks, this is the next cohesive batch from the issue's tests.* batching plan: the extract domain. Removes the 6 [mypy-opencontractserver.tests.test_*] ignore_errors blocks for the structured-data-extraction feature -- Extracts plus their Fieldsets/Columns, Datacells, and metadata columns (all in opencontractserver/extracts/models.py): test_extract_mutations, test_extract_queries, test_extract_tasks, test_datacell_mutations, test_column_mutations, test_metadata_columns_graphql. Prunes the corresponding 57 lines from docs/typing/mypy_baseline.txt (3648 -> 3591) and fixes the 42 errors that surface. Every surfaced error was the same: a graphene.test.Client assigned to self.client shadows django.test.TestCase.client (which has no .execute()). Renamed self.client -> self.graphene_client in the 5 GraphQL test modules -- a behaviour-equivalent rename, since the assignment already shadowed the Django client at runtime and every read was .execute(). test_extract_tasks needed no code change: its historical set_permissions_for_obj_to_user arg-type errors no longer reproduce under django-stubs==6.0.5. Full project surface (mypy --config-file mypy.ini opencontractserver config) stays clean under both the pre-commit pin (mypy==2.0.0) and CI's pin (mypy==2.1.0). Refs #1738
Code Review — PR #1924: Graduate the extract test domain out of the mypy baselineOverview: This is the next installment in the mypy baseline drain (#1738), graduating 6 extract-domain test modules out of What's Good
Minor Observations (non-blocking)
SummaryClean, low-risk PR with no issues to block merge. The change is behaviour-neutral, fully consistent with the pattern established across prior #1738 chunks, and correctly documented. Approving pending backend CI green. |
…een-fW6q3 # Conflicts: # mypy.ini
|
Graduates the extract test domain (6 modules) out of the mypy baseline - see full review below. |
Code Review - PR 1924: Graduate extract test domain out of mypy baselineOverview Graduates 6 test modules (test_extract_mutations, test_extract_queries, test_extract_tasks, test_datacell_mutations, test_column_mutations, test_metadata_columns_graphql) out of the mypy baseline as part of the ongoing 1738 drain. Root cause was a graphene.test.Client assigned to self.client shadowing django.test.TestCase.client (no .execute()). Fixed by renaming self.client -> self.graphene_client uniformly across 5 files. test_extract_tasks needed no code change. Code Quality Consistent with established pattern - identical rename approach to prior 1738 chunks (1776, 1851, 1866, 1877). Same root cause, same fix, correctly applied. Rename is genuinely behavior-equivalent: self.client was already shadowing the Django test client at runtime; every read was .execute(). The rename also eliminates a latent footgun - a future self.client.get() call would silently hit the graphene client at runtime, but mypy now catches it. Baseline pruning is accurate: 57 lines removed from docs/typing/mypy_baseline.txt exactly match the 6 graduated modules. mypy.ini comment block properly updated with the new graduates, keeping the audit trail intact. test_extract_tasks silent graduation is correctly explained: the prior set_permissions_for_obj_to_user arg-type errors no longer reproducing under django-stubs==6.0.5 is consistent with prior chunks - improved stubs, not a suppression. Changelog fragment follows project conventions (changelog.d/1738-extract-tests-mypy.changed.md, changed type, no section headers). Potential Issues Minor: one cosmetic reformat in test_extract_queries.py at test_full_datacell_list_no_args_capped_at_server_max splits a single-line execute() call to two lines. Harmless, consistent with black, but an incidental diff. CI is the runtime gate: Docker was unavailable during authoring, so no actual test run was performed. Pure attribute rename with no logic delta - risk is low, but CI backend job is the authoritative check. No issues with test_extract_tasks block removal: removing ignore_errors = True that no longer matches any errors is strictly correct. Summary Clean, low-risk, mechanical maintenance PR that follows the established mypy drain pattern exactly. Rename is correctly scoped, baseline pruning is accurate, documentation is up to date. No concerns beyond the standard CI dependency for runtime verification. |
Summary
Continues the mypy baseline drain tracked in #1738 (the
#1331 → #1335 → #1447cadence). After the config tail (#1748), thetests.permissioning.*subpackage (#1768), and theannotation(#1776) /document(#1851) /corpus(#1866) /agent(#1877) leaf-file chunks, this is the next cohesive batch from the issue'stests.*batching plan (corpus / document / annotation / agent / extract / misc): theextractdomain.Removes the 6
[mypy-opencontractserver.tests.test_*]ignore_errorsblocks for the structured-data-extraction feature — Extracts plus their Fieldsets/Columns, Datacells, and metadata columns (all defined inopencontractserver/extracts/models.py):test_extract_mutationstest_extract_queriestest_extract_taskstest_datacell_mutationstest_column_mutationstest_metadata_columns_graphqlPrunes the corresponding 57 lines from
docs/typing/mypy_baseline.txt(3648 → 3591) and fixes the 42 errors that surface.How
Every surfaced error was the same one: a
graphene.test.Clientassigned toself.clientshadows the inheriteddjango.test.TestCase.client, which has no.execute()(mypy resolvesself.client.execute(...)through Django's client →[attr-defined]). The established fix from the prior chunks (#1776 / #1851 / #1866 / #1877) applies cleanly:self.client→self.graphene_clientrename in the 5 GraphQL test modules. This is behaviour-equivalent: the assignment already shadowed Django'sTestCase.clientat runtime, every read in these files was.execute(), and no other module subclasses these test classes (verified). The rename is uniform — no otherself.clientusage (no real Django.get/.post/.force_login) exists in any of the files.test_extract_tasksneeded no code change — only block removal + baseline pruning. Its historicalset_permissions_for_obj_to_userarg-typeerrors no longer reproduce underdjango-stubs==6.0.5(the same observation typing: graduate tests.test_annotation_* chunk out of mypy baseline #1776 / typing: graduate tests.test_document_* chunk out of the mypy baseline #1851 / typing: graduate tests.test_agent* chunk out of the mypy baseline #1877 made for the other chunks).All changes are type-level. No production code is modified; no test assertions or logic change.
Test plan
mypy --config-file mypy.ini opencontractserver config→Success: no issues found in 1263 source files, run in a venv mirroring the.pre-commit-config.yamlpin set, under both pinned toolchains:mypy==2.0.0/django-stubs==6.0.5(pre-commit)mypy==2.1.0/django-stubs==6.0.5(CIrequirements/local.txt)pyupgrade --py39-plus/black==26.1.0/isort==6.0.1/flake8==7.2.0(+flake8-isort) clean on all 6 files; trailing-whitespace / EOF hooks clean onmypy.ini, the baseline, and the changelog fragment.py_compilecleanly; renamed test classes have no external subclassers.scripts/collate_changelog.py --checkpasses (addedchangelog.d/1738-extract-tests-mypy.changed.md).backend.ymllinter + test jobs) — the authoritative runtime check.Refs #1738
https://claude.ai/code/session_01EF8XiHoMM2PPb7zxjEn7KU
Generated by Claude Code