test: make WordExtractor close test deterministic#35654
Closed
princepal9120 wants to merge 2 commits into
Closed
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-29 01:59:49.835362992 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-29 01:59:37.600256147 +0000
@@ -4466,21 +4466,21 @@
ERROR Argument `SimpleNamespace` is not assignable to parameter `document_model` with type `Document | None` in function `core.rag.extractor.notion_extractor.NotionExtractor.update_last_edited_time` [bad-argument-type]
--> tests/unit_tests/core/rag/extractor/test_notion_extractor.py:435:43
ERROR Type `object` is not iterable [not-iterable]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:92:9
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:90:9
ERROR `Any | None` is not assignable to attribute `FILES_URL` with type `str` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:211:33
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:209:33
ERROR `Any | None` is not assignable to attribute `INTERNAL_FILES_URL` with type `str` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:212:42
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:210:42
ERROR `Literal['Dify']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:233:14
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:231:14
ERROR `Literal[' HYPERLINK "http://example.com" ']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:286:22
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:284:22
ERROR `Literal['Example']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:298:15
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:296:15
ERROR `Literal['Dify']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:688:14
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:689:14
ERROR `Literal['john@test.com']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:728:14
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:729:14
ERROR Argument `Literal['semantic_search']` is not assignable to parameter `retrieval_method` with type `RetrievalMethod` in function `core.rag.index_processor.processor.paragraph_index_processor.ParagraphIndexProcessor.retrieve` [bad-argument-type]
--> tests/unit_tests/core/rag/indexing/processor/test_paragraph_index_processor.py:246:39
ERROR Argument `Literal['semantic_search']` is not assignable to parameter `retrieval_method` with type `RetrievalMethod` in function `core.rag.index_processor.processor.parent_child_index_processor.ParentChildIndexProcessor.retrieve` [bad-argument-type]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-29 02:09:59.613376192 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-29 02:09:46.417242726 +0000
@@ -4466,17 +4466,17 @@
ERROR Argument `SimpleNamespace` is not assignable to parameter `document_model` with type `Document | None` in function `core.rag.extractor.notion_extractor.NotionExtractor.update_last_edited_time` [bad-argument-type]
--> tests/unit_tests/core/rag/extractor/test_notion_extractor.py:435:43
ERROR Type `object` is not iterable [not-iterable]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:92:9
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:90:9
ERROR `Any | None` is not assignable to attribute `FILES_URL` with type `str` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:211:33
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:209:33
ERROR `Any | None` is not assignable to attribute `INTERNAL_FILES_URL` with type `str` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:212:42
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:210:42
ERROR `Literal['Dify']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:233:14
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:231:14
ERROR `Literal[' HYPERLINK "http://example.com" ']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:286:22
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:284:22
ERROR `Literal['Example']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
- --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:298:15
+ --> tests/unit_tests/core/rag/extractor/test_word_extractor.py:296:15
ERROR `Literal['Dify']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
--> tests/unit_tests/core/rag/extractor/test_word_extractor.py:688:14
ERROR `Literal['john@test.com']` is not assignable to attribute `text` with type `Ellipsis` [bad-assignment]
|
5 tasks
Member
|
Thanks for the contribution, @princepal9120 — really appreciate the thorough write-up and the clean refactor here. Closing this in favor of #35652, which was opened a few hours earlier and targets the same flake (#35651). To keep things fair, we're going FIFO on duplicates, so the older PR got the merge. Your approach (custom awaitable + |
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.
Summary
WordExtractor.close()coverage deterministic.AsyncMock/GC assertion with a direct awaitable close-result stub.gc,warnings, andAsyncMockimports.Why
The previous test could observe coroutine warnings emitted by earlier tests, which made the assertion flaky and unrelated to
WordExtractor.close()itself.Validation
python3 -m py_compile api/tests/unit_tests/core/rag/extractor/test_word_extractor.pyNot run: targeted pytest, because dependency setup failed locally with
No space left on devicewhile downloading packages.Fixes #35651
close #35652