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
Fix: 修复 dotenv 配置项为 None 将会跳过赋值 #2143
Conversation
# Conflicts: # nonebot/plugin/on.py
Codecov Report
@@ Coverage Diff @@
## master #2143 +/- ##
==========================================
- Coverage 89.73% 89.70% -0.03%
==========================================
Files 46 46
Lines 3340 3343 +3
==========================================
+ Hits 2997 2999 +2
- Misses 343 344 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
🚀 Deployed on https://deploy-preview-2143--nonebot2.netlify.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该替换这两行的默认值为 pydantic.fields.Undefined 然后下面改为is not undefined
Lines 47 to 49 in 3bee189
env_val: Optional[str] = None | |
for env_name in field.field_info.extra["env_names"]: | |
env_val = env_vars.get(env_name) |
env_val: Optional[str] = Undefined #46
for env_name in field.field_info.extra["env_names"]: #47
env_val = env_vars.get(env_name) #48
# ...
if is_complex:
# ...
elif env_val is not Undefined:
d[field.alias] = env_val 这样改好像会导致pydantic报错
|
49行get的默认值呢? |
感觉是bug #2142