Skip to content

typing: graduate the extract test domain out of the mypy baseline#1924

Merged
JSv4 merged 2 commits into
mainfrom
claude/confident-bardeen-fW6q3
Jun 5, 2026
Merged

typing: graduate the extract test domain out of the mypy baseline#1924
JSv4 merged 2 commits into
mainfrom
claude/confident-bardeen-fW6q3

Conversation

@JSv4

@JSv4 JSv4 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Continues the mypy baseline drain tracked in #1738 (the #1331 → #1335 → #1447 cadence). After the config tail (#1748), the tests.permissioning.* subpackage (#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 (corpus / document / annotation / agent / extract / misc): 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 defined 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.

How

Every surfaced error was the same one: a graphene.test.Client assigned to self.client shadows the inherited django.test.TestCase.client, which has no .execute() (mypy resolves self.client.execute(...) through Django's client → [attr-defined]). The established fix from the prior chunks (#1776 / #1851 / #1866 / #1877) applies cleanly:

All changes are type-level. No production code is modified; no test assertions or logic change.

Test plan

  • mypy --config-file mypy.ini opencontractserver configSuccess: no issues found in 1263 source files, run in a venv mirroring the .pre-commit-config.yaml pin 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 (CI requirements/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 on mypy.ini, the baseline, and the changelog fragment.
  • All 6 modules py_compile cleanly; renamed test classes have no external subclassers.
  • scripts/collate_changelog.py --check passes (added changelog.d/1738-extract-tests-mypy.changed.md).
  • Backend CI (backend.yml linter + test jobs) — the authoritative runtime check.

Note on local testing: the Dockerized backend suite could not be exercised in the authoring container (the Docker daemon is unavailable — no /var/run/docker.sock), matching the prior #1738 chunks. mypy was run via a venv mirroring the pre-commit pin set. The changes are behaviour-neutral (a self-contained instance-attribute rename, validated by mypy under both pins + py_compile + a no-external-subclassers check), so CI's backend job is relied on for the runtime check.

Refs #1738

https://claude.ai/code/session_01EF8XiHoMM2PPb7zxjEn7KU


Generated by Claude Code

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
@claude

claude Bot commented Jun 4, 2026

Copy link
Copy Markdown

Code Review — PR #1924: Graduate the extract test domain out of the mypy baseline

Overview: This is the next installment in the mypy baseline drain (#1738), graduating 6 extract-domain test modules out of ignore_errors coverage. The fix is mechanically uniform: rename self.client (a graphene.test.Client) to self.graphene_client to stop shadowing django.test.TestCase.client, eliminating all 42 surfaced [attr-defined] errors. No production code is modified.


What's Good


Minor Observations (non-blocking)

  1. No explicit type annotation for self.graphene_client. The attribute could be annotated self.graphene_client: Client in setUp (or as a class-level annotation) to make mypy's inference explicit. This is not required — the rename alone clears the errors — and prior chunks didn't add annotations either, so this is consistent. Worth a future-pass consideration once the full batch is done.

  2. Black reformatting on one call in test_extract_queries.py. One call was split across lines after the longer attribute name pushed it past the line-length limit. This is correct formatting; just confirming it's intentional rather than a semantic change.

  3. No Docker CI run locally. The PR is transparent about this. The change is a pure rename with no logic delta, so backend CI is the authoritative gate — acceptable given the track record of prior identical chunks all passing CI.


Summary

Clean, 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.

@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown

Graduates the extract test domain (6 modules) out of the mypy baseline - see full review below.

@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code Review - PR 1924: Graduate extract test domain out of mypy baseline

Overview

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.

@JSv4 JSv4 merged commit 629624f into main Jun 5, 2026
10 checks passed
@JSv4 JSv4 deleted the claude/confident-bardeen-fW6q3 branch June 5, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants