typing: graduate tests.test_admin* chunk out of the mypy baseline (#1738) - #2165
Closed
feiiiiii5 wants to merge 1 commit into
Closed
Conversation
…en-Source-Legal#1738) Removed the two `[mypy-opencontractserver.tests.test_admin]` and `[mypy-opencontractserver.tests.test_admin_auth]` `ignore_errors` blocks and pruned the corresponding 122 lines from `docs/typing/mypy_baseline.txt` (2942 → 2820). Fixes follow the established patterns from earlier Open-Source-Legal#1738 graduation passes — the `get_user_model()` → direct `User` import swap, class-level annotations for `setUpTestData` attributes, and `# type: ignore` on Django-stubs gaps (`_MonkeyPatchedWSGIResponse.url`, `ModelAdmin`'s optional `AdminSite`). No production code changed. The 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`).
Author
|
Closing this typing cleanup — I'm trimming my open PRs and won't be actively following up on it. The mypy-baseline graduation stands on its own if it's wanted later; the branch stays on my fork for an easy reopen. Thanks! |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1738. Graduates the
tests.test_admin*chunk (2 files) out of the mypy baseline — the Auth0 admin authentication tests + the Django admin views tests.What changed
mypy.ini— removed 2ignore_errorsblocks:[mypy-opencontractserver.tests.test_admin][mypy-opencontractserver.tests.test_admin_auth]docs/typing/mypy_baseline.txt— pruned the corresponding 122 lines (2942 → 2820).Per-file fixes
test_admin.py(6 errors)User = get_user_model()alias for the concretefrom opencontractserver.users.models import Userimport (mypy rejects aget_user_model()variable as a type annotation).obj: objecttoobj: Modelso_meta/pkresolve.# type: ignore[arg-type]onCorpusAdmin(Corpus, None)—ModelAdmin's second-argAdminSiteis genuinely optional at runtime but typed as required.# type: ignore[method-assign]on theMock()reassignment ofmessage_user— intentional test isolation.test_admin_auth.py(116 errors)get_user_model()→ direct import swap.TestCaseclasses that storeUserinstances onsetUpTestData(cls):TestAdminClaimsSync.userTestAuth0SuperuserAllowlist.userTestAuth0AdminBackend.{staff_user, non_staff_user, inactive_staff, superuser}TestAdminLoginView.{staff_user, regular_user}TestAdminLogoutView.staff_userTestGetUserByPayloadWithClaimSync.userTestAdminLoginRateLimit.staff_user# type: ignore[attr-defined]onresponse.urlredirects — django-stubs'_MonkeyPatchedWSGIResponsedoesn't expose.urleven though Django's test client always sets it on 302s.Verification
mypy --config-file mypy.ini opencontractserver config→ `Success: no issues found in 1513 source files` (both pre-commitmypy==2.0.0and CImypy==2.1.0pins).python scripts/collate_changelog.py --check→ `OK: 252 changelog fragment(s) valid`.Patterns used (consistent with earlier #1738 graduation passes)
get_user_model()→ direct import: established in theconversation & threadingpass.setUpTestDataannotations: recommended fix from typing: graduate opencontractserver.discovery.tests.test_discovery_views from mypy baseline #1479.# type: ignore[attr-defined]on_MonkeyPatchedWSGIResponse.url: stub gap (test client always sets.urlon 302s).