improve dict check in py #15500

Open
opened 2026-02-21 19:22:02 -05:00 by yindo · 6 comments
Owner

Originally created by @asukaminato0721 on GitHub (Jul 18, 2025).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

now a lot of type is bare dict

rg ": dict\)" --glob "*.py" | wc -l
165

use pydantic can reduce many dup pattern like

if not field:
    raise ValueError...

example #24837

2. Additional context or comments

https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Originally created by @asukaminato0721 on GitHub (Jul 18, 2025). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] Please do not modify this template :) and fill in all the required fields. ### 1. Is this request related to a challenge you're experiencing? Tell me about your story. now a lot of type is bare dict ``` rg ": dict\)" --glob "*.py" | wc -l 165 ``` use pydantic can reduce many dup pattern like ```py if not field: raise ValueError... ``` example #24837 ### 2. Additional context or comments https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/ ### 3. Can you help us with this feature? - [x] I am interested in contributing to this feature.
yindo added the 💪 enhancementgood first issue labels 2026-02-21 19:22:02 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 24, 2025):

Hi, @asukaminato0721. I'm Dosu, and I'm helping the Dify team manage their backlog and am marking this issue as stale.

Issue Summary

  • You proposed improving dictionary type checks in the Python codebase by replacing many bare dicts with Pydantic models.
  • The goal is to reduce repetitive validation and improve code robustness.
  • You referenced a blog about parsing versus validating to support your suggestion.
  • There has been no further activity or discussion on this proposal since it was opened.

Next Steps

  • Please let me know if this enhancement is still relevant for the latest version of Dify by commenting on this issue.
  • If I don’t hear back within 15 days, this issue will be automatically closed.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 24, 2025): Hi, @asukaminato0721. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog and am marking this issue as stale. **Issue Summary** - You proposed improving dictionary type checks in the Python codebase by replacing many bare dicts with Pydantic models. - The goal is to reduce repetitive validation and improve code robustness. - You referenced a blog about parsing versus validating to support your suggestion. - There has been no further activity or discussion on this proposal since it was opened. **Next Steps** - Please let me know if this enhancement is still relevant for the latest version of Dify by commenting on this issue. - If I don’t hear back within 15 days, this issue will be automatically closed. Thanks for your understanding and contribution!
Author
Owner

@asukaminato0721 commented on GitHub (Aug 24, 2025):

I think use *args, **kwargs is more pythonic...

@asukaminato0721 commented on GitHub (Aug 24, 2025): I think use *args, **kwargs is more pythonic...
Author
Owner

@dosubot[bot] commented on GitHub (Aug 24, 2025):

@crazywoola The user prefers using *args and **kwargs as a more pythonic approach instead of switching to Pydantic models for dictionary type checks. Could you please assist with this perspective on the enhancement?

@dosubot[bot] commented on GitHub (Aug 24, 2025): @crazywoola The user prefers using *args and **kwargs as a more pythonic approach instead of switching to Pydantic models for dictionary type checks. Could you please assist with this perspective on the enhancement?
Author
Owner

@asukaminato0721 commented on GitHub (Aug 31, 2025):

use __pydantic_extra__ can find all the undocumented fields for future work.

@asukaminato0721 commented on GitHub (Aug 31, 2025): use `__pydantic_extra__` can find all the undocumented fields for future work.
Author
Owner

@asukaminato0721 commented on GitHub (Aug 31, 2025):

Ref https://en.m.wikipedia.org/wiki/Strangler_fig_pattern

@asukaminato0721 commented on GitHub (Aug 31, 2025): Ref https://en.m.wikipedia.org/wiki/Strangler_fig_pattern
Author
Owner

@asukaminato0721 commented on GitHub (Jan 24, 2026):

cc @hyoban

@asukaminato0721 commented on GitHub (Jan 24, 2026): cc @hyoban
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#15500