Skip to content

refactor(api): extract AppModelConfig TypedDict definitions into separate module#34543

Open
jonathanchang31 wants to merge 2 commits intolanggenius:mainfrom
jonathanchang31:refactor/extract-app-model-config-types
Open

refactor(api): extract AppModelConfig TypedDict definitions into separate module#34543
jonathanchang31 wants to merge 2 commits intolanggenius:mainfrom
jonathanchang31:refactor/extract-app-model-config-types

Conversation

@jonathanchang31
Copy link
Copy Markdown
Contributor

@jonathanchang31 jonathanchang31 commented Apr 3, 2026

Summary

  • Extract all TypedDict definitions related to AppModelConfig from api/models/model.py into a new api/models/app_model_config_types.py module
  • Re-export all types from model.py to maintain backward compatibility with existing imports

Test plan

  • Verify all existing imports from models.model still resolve correctly
  • Run existing test suite to confirm no regressions

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint and make type-check (backend) and cd web && npx lint-staged (frontend) to appease the lint gods

Part of #31096

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-04 02:34:09.187964727 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-04 02:34:00.057996252 +0000
@@ -328,11 +328,11 @@
 ERROR Argument `str | None` is not assignable to parameter `value` with type `SQLCoreOperations[str] | str` in function `sqlalchemy.orm.base.Mapped.__set__` [bad-argument-type]
    --> services/conversation_service.py:131:33
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2107:56
+    --> services/dataset_service.py:2105:56
 ERROR `dict[str, bool | dict[str, Any] | str | None]` is not assignable to variable `data_source_info` with type `dict[str, bool | str]` [bad-assignment]
-    --> services/dataset_service.py:2620:44
+    --> services/dataset_service.py:2617:44
 ERROR `None` is not assignable to attribute `rules` with type `Never` [bad-assignment]
-    --> services/dataset_service.py:2795:51
+    --> services/dataset_service.py:2790:51
 ERROR Class member `DocumentIndexingTaskProxy.NORMAL_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
   --> services/document_indexing_proxy/document_indexing_task_proxy.py:11:5
 ERROR Class member `DocumentIndexingTaskProxy.PRIORITY_TASK_FUNC` overrides parent class `BatchDocumentIndexingProxy` in an inconsistent manner [bad-override]
@@ -6335,9 +6335,9 @@
 ERROR `in` is not supported between `Literal['not found']` and `None` [not-iterable]
    --> tests/unit_tests/services/retention/workflow_run/test_restore_archived_workflow_run.py:906:16
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_annotation_service.py:1214:59
+    --> tests/unit_tests/services/test_annotation_service.py:1438:59
 ERROR TypedDict `AnnotationSettingDisabledDict` does not have key `embedding_model` [bad-typed-dict-key]
-    --> tests/unit_tests/services/test_annotation_service.py:1251:27
+    --> tests/unit_tests/services/test_annotation_service.py:1486:27
 ERROR Object of class `FunctionType` has no attribute `reset_mock` [missing-attribute]
    --> tests/unit_tests/services/test_app_dsl_service.py:214:5
 ERROR Object of class `FunctionType` has no attribute `assert_called_once` [missing-attribute]
@@ -6457,53 +6457,53 @@
 ERROR Object of class `FakeAccount` has no attribute `current_tenant_id` [missing-attribute]
    --> tests/unit_tests/services/test_dataset_service_document.py:455:9
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:812:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:814:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:835:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:837:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:872:70
+   --> tests/unit_tests/services/test_dataset_service_document.py:878:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:920:65
+   --> tests/unit_tests/services/test_dataset_service_document.py:928:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:949:70
+   --> tests/unit_tests/services/test_dataset_service_document.py:961:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.document_create_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:970:59
+   --> tests/unit_tests/services/test_dataset_service_document.py:982:59
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.document_create_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:979:59
+   --> tests/unit_tests/services/test_dataset_service_document.py:991:59
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.data_source_args_validate` [bad-argument-type]
-   --> tests/unit_tests/services/test_dataset_service_document.py:997:55
+    --> tests/unit_tests/services/test_dataset_service_document.py:1009:55
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.data_source_args_validate` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1018:55
+    --> tests/unit_tests/services/test_dataset_service_document.py:1030:55
 ERROR Argument `list[PreProcessingRule] | None` is not assignable to parameter `obj` with type `Sized` in function `len` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1069:20
+    --> tests/unit_tests/services/test_dataset_service_document.py:1081:20
 ERROR `None` is not subscriptable [unsupported-operation]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1070:16
+    --> tests/unit_tests/services/test_dataset_service_document.py:1082:16
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1174:72
+    --> tests/unit_tests/services/test_dataset_service_document.py:1186:72
 ERROR `SimpleNamespace` is not assignable to attribute `process_rule` with type `ProcessRule | None` [bad-assignment]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1179:41
+    --> tests/unit_tests/services/test_dataset_service_document.py:1191:41
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1218:38
+    --> tests/unit_tests/services/test_dataset_service_document.py:1231:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1298:38
+    --> tests/unit_tests/services/test_dataset_service_document.py:1313:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1349:38
+    --> tests/unit_tests/services/test_dataset_service_document.py:1364:38
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1503:70
+    --> tests/unit_tests/services/test_dataset_service_document.py:1523:70
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1530:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1550:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1553:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1573:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1568:65
+    --> tests/unit_tests/services/test_dataset_service_document.py:1588:65
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.DocumentService.update_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1603:70
+    --> tests/unit_tests/services/test_dataset_service_document.py:1627:70
 ERROR Object of class `NoneType` has no attribute `rules` [missing-attribute]
-    --> tests/unit_tests/services/test_dataset_service_document.py:1902:22
+    --> tests/unit_tests/services/test_dataset_service_document.py:1930:22
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:2016:42
+    --> tests/unit_tests/services/test_dataset_service_document.py:2054:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset_process_rule` with type `DatasetProcessRule | None` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
-    --> tests/unit_tests/services/test_dataset_service_document.py:2039:42
+    --> tests/unit_tests/services/test_dataset_service_document.py:2077:42
 ERROR Argument `SimpleNamespace` is not assignable to parameter `knowledge_config` with type `KnowledgeConfig` in function `services.dataset_service.DocumentService.save_document_with_dataset_id` [bad-argument-type]
    --> tests/unit_tests/services/test_dataset_service_lock_not_owned.py:103:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `services.dataset_service.SegmentService.create_child_chunk` [bad-argument-type]

@jonathanchang31 jonathanchang31 changed the title Refactor/extract app model config types refactor(api): extract AppModelConfig TypedDict definitions into separate module Apr 4, 2026
@jonathanchang31
Copy link
Copy Markdown
Contributor Author

@asukaminato0721 plz review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant