|
| 1 | +- **Graduated the `conversation & threading` test domain out of the mypy |
| 2 | + baseline (#1738).** Removed the 7 `[mypy-opencontractserver.tests.test_*]` |
| 3 | + `ignore_errors` blocks for the chat/threads feature: |
| 4 | + `test_conversation_mutations_graphql`, `test_conversation_permissions`, |
| 5 | + `test_conversation_query`, `test_conversation_search`, |
| 6 | + `test_long_conversation_api`, `test_thread_corpus_actions`, |
| 7 | + `test_threading`. Pruned the corresponding 433 lines from |
| 8 | + `docs/typing/mypy_baseline.txt` (3375 → 2942) and fixed the 361 errors that |
| 9 | + actually surface. The baseline had drifted: e.g. `test_conversation_search` |
| 10 | + fell 77 → 23 (its historical `set_permissions_for_obj_to_user` arg-type |
| 11 | + errors no longer reproduce under `django-stubs==6.0.5`), while |
| 12 | + `test_conversation_permissions` grew 86 → 159 after recent edits. Fixes use |
| 13 | + the established patterns — class-level annotations for |
| 14 | + `setUpClass`/`setUpTestData` attributes (the recommended fix from #1479), the |
| 15 | + graphene `self.client` → `self.graphene_client` rename (3 files), and |
| 16 | + `assert ... is not None` narrowing of Optional ORM/embedding returns. The |
| 17 | + three `setUpClass`-heavy files also swapped their module-level |
| 18 | + `User = get_user_model()` alias for the concrete |
| 19 | + `from opencontractserver.users.models import User` import, since mypy rejects |
| 20 | + a `get_user_model()` variable as a type annotation. |
| 21 | +- **Declared the `_skip_signals` fixture flag on `InstanceUserCanMixin` |
| 22 | + (`opencontractserver/shared/user_can_mixin.py`).** `_skip_signals` is an |
| 23 | + out-of-band attribute that tests/fixtures and one production path |
| 24 | + (`llms/tools/moderation_tools.py`) set on model instances so the signal |
| 25 | + handlers in `*/signals.py` skip their side effects (notifications, badge |
| 26 | + awards, corpus-action triggers). It was undeclared, which forced a |
| 27 | + `# type: ignore[attr-defined]` in `moderation_tools.py` and produced 26 |
| 28 | + `attr-defined` errors in `test_thread_corpus_actions`. Declaring it once as |
| 29 | + `_skip_signals: bool` on the mixin shared by `BaseOCModel` *and* the |
| 30 | + `TreeNode`-rooted `Corpus` / `CorpusFolder` (a type-only bare annotation; |
| 31 | + Django's model metaclass ignores it at runtime, so the presence-based |
| 32 | + `hasattr`/`getattr` guards still behave identically) removes the existing |
| 33 | + ignore, clears all 26 test errors, and types the flag across both model |
| 34 | + lineages — future-proofing the other still-baselined tests that use it on |
| 35 | + `Conversation`/`ChatMessage` (`test_badges`, `test_leaderboard`, |
| 36 | + `test_notifications`) as well as on `Corpus` (`test_caml_intelligence_block`). |
| 37 | + The full |
| 38 | + project surface (`mypy --config-file mypy.ini opencontractserver config`) |
| 39 | + stays clean under both the pre-commit pin (`mypy==2.0.0`) and CI's pin |
| 40 | + (`mypy==2.1.0`). |
0 commit comments