Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: 支持子依赖定义 Pydantic 类型校验 #2310

Merged
merged 2 commits into from Aug 29, 2023

Conversation

yanyongyu
Copy link
Member

fix #2304

@yanyongyu yanyongyu added the enhancement New feature or request label Aug 28, 2023
@codecov
Copy link

codecov bot commented Aug 28, 2023

Codecov Report

Merging #2310 (49a5995) into master (562ec79) will increase coverage by 0.08%.
Report is 4 commits behind head on master.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2310      +/-   ##
==========================================
+ Coverage   90.46%   90.55%   +0.08%     
==========================================
  Files          46       46              
  Lines        3367     3399      +32     
==========================================
+ Hits         3046     3078      +32     
  Misses        321      321              
Flag Coverage Δ
unittests 90.55% <100.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
nonebot/dependencies/__init__.py 96.34% <100.00%> (+0.23%) ⬆️
nonebot/dependencies/utils.py 85.71% <100.00%> (-0.65%) ⬇️
nonebot/internal/params.py 98.92% <100.00%> (+0.19%) ⬆️

@github-actions
Copy link
Contributor

github-actions bot commented Aug 28, 2023

🚀 Deployed on https://deploy-preview-2310--nonebot2.netlify.app

@github-actions github-actions bot temporarily deployed to pull request August 28, 2023 07:27 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 28, 2023 07:42 Inactive
@A-kirami
Copy link
Contributor

A-kirami commented Aug 28, 2023

需要在依赖注入上添加validate参数才可转换类型,是否应当考虑默认转换类型?

也就是 validate: Union[bool, FieldInfo] = False 修改为 validate: Optional[FieldInfo] = None

@yanyongyu
Copy link
Member Author

由于pydantic校验存在副作用,如深拷贝数据等,所以不考虑默认启用

@yanyongyu yanyongyu merged commit f59271b into master Aug 29, 2023
24 checks passed
@yanyongyu yanyongyu deleted the feat/dep-validate branch August 29, 2023 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

Feature: 增强依赖注入以支持类型转换
3 participants