Repository navigation
refactor(models): remove the last standalone legacy db.session properties on Dataset - #41911
Merged
asukaminato0721 merged 2 commits intoSep 7, 2026
Conversation
keith991001
requested review from
JohnJyong,
QuantumGhost and
laipz8200
as code owners
September 7, 2026 07:13
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-09-07 07:15:01.952868156 +0000
+++ /tmp/pyrefly_pr.txt 2026-09-07 07:14:53.940827094 +0000
@@ -1002,6 +1002,12 @@
--> tests/test_containers_integration_tests/services/test_dataset_service_delete_dataset.py:25:20
ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_dataset_service_delete_dataset.py:32:20
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/services/test_dataset_service_delete_dataset.py:145:13
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/services/test_dataset_service_document.py:627:59
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/services/test_dataset_service_document.py:665:13
ERROR Argument `Literal['active']` is not assignable to parameter `status` with type `AccountStatus | SQLCoreOperations[AccountStatus]` in function `models.account.Account.__init__` [bad-argument-type]
--> tests/test_containers_integration_tests/services/test_dataset_service_permissions.py:38:20
ERROR Argument `Literal['normal']` is not assignable to parameter `status` with type `SQLCoreOperations[TenantStatus] | TenantStatus` in function `models.account.Tenant.__init__` [bad-argument-type]
@@ -1406,11 +1412,11 @@
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:123:20
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:295:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:298:22
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:419:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:422:22
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:495:36
@@ -1418,23 +1424,23 @@
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:498:26
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:552:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:555:22
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:638:36
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:641:26
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:751:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:754:22
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:845:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:848:22
ERROR Argument `IndexTechniqueType | None` is not assignable to parameter `indexing_technique` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:999:32
-ERROR Argument `str | None` is not assignable to parameter `doc_form` with type `str` in function `celery.app.task.Task.__call__` [bad-argument-type]
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_dataset_task.py:1002:22
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:101:23
@@ -1482,6 +1488,14 @@
--> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1057:23
ERROR Object of class `NoneType` has no attribute `id` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_clean_notion_document_task.py:1070:23
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/tasks/test_create_segment_to_index_task.py:229:95
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/tasks/test_create_segment_to_index_task.py:555:95
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/tasks/test_create_segment_to_index_task.py:986:95
+ERROR Object of class `Dataset` has no attribute `doc_form` [missing-attribute]
+ --> tests/test_containers_integration_tests/tasks/test_create_segment_to_index_task.py:1060:95
ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
--> tests/test_containers_integration_tests/tasks/test_deal_dataset_vector_index_task.py:227:16
ERROR Object of class `NoneType` has no attribute `indexing_status` [missing-attribute]
|
Contributor
Pyrefly Type Coverage
|
asukaminato0721
approved these changes
Sep 7, 2026
This was referenced Sep 8, 2026
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.
Important
Summary
Part of #40372, follow-up to #41647 / #41794.
Removes the last three standalone
Datasetlegacy@propertyaccessors inapi/models/dataset.pythat reach for the globaldb.sessioninternally — each a thin wrapper around an existing session-awareget_*twin:Dataset.word_count→get_word_count(session=...)Dataset.doc_form→get_doc_form(session=...)Dataset.tags→get_tags(session=...)These were deferred in earlier slices because their names collide with same-named columns on
Documentand other models; a receiver-level, untruncated sweep across production, serializers (DatasetDetailResponseSourcecovers response validation), events, and tests found exactly one production reader: thedataset_was_deletedevent handler readdataset.doc_formtwice. It now callsget_doc_form(session=db.session())once at the boundary and reuses the value, per the established pattern.Not touching
Dataset.available_segment_count(claimed by another contributor on the issue) or the to_dict-blocked group (direction proposal pending on the issue).Tests
The three
get_*twins keep their existing unit coverage intest_dataset_models.py. Updated the container-integration tests that read the removed properties: oneword_countassertion and sevendoc_formcall sites intest_batch_clean_document_task.py, all switched to theget_*twins with the test session.Screenshots
N/A (backend-only refactor).
Checklist
make lint && make type-check(backend) andvp staged(frontend) to appease the lint godsFrom Claude Code