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

Fix: 修复 MessageSegment 在有额外数据时报错 #1055

Merged
merged 4 commits into from
Jun 20, 2022

Conversation

yanyongyu
Copy link
Member

当 dict 存在额外数据时会导致报错

from pydantic import parse_obj_as
# error
parse_obj_as(MessageSegment, {"type": "test", "extra": "something"})

@yanyongyu yanyongyu added the bug Something isn't working label Jun 19, 2022
@yanyongyu yanyongyu requested a review from mnixry June 19, 2022 09:39
@yanyongyu yanyongyu changed the title Fix: 修复 MessageSegment 不严谨的检查 Fix: 修复 MessageSegment 在有额外数据时报错 Jun 19, 2022
@codecov
Copy link

codecov bot commented Jun 19, 2022

Codecov Report

Merging #1055 (ff2c3a5) into master (a82ce00) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1055      +/-   ##
==========================================
+ Coverage   77.95%   77.97%   +0.01%     
==========================================
  Files          42       42              
  Lines        3162     3164       +2     
==========================================
+ Hits         2465     2467       +2     
  Misses        697      697              
Flag Coverage Δ
unittests 77.97% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
nonebot/internal/adapter/message.py 98.02% <100.00%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a82ce00...ff2c3a5. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 19, 2022

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

@github-actions github-actions bot temporarily deployed to pull request June 19, 2022 09:42 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 19, 2022 09:57 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 19, 2022 10:02 Inactive
@github-actions github-actions bot temporarily deployed to pull request June 19, 2022 10:08 Inactive
Copy link
Member

@mnixry mnixry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有办法让额外数据留下了吗👀

@yanyongyu
Copy link
Member Author

没有办法让额外数据留下了吗eyes

没有,在nonebot里就只应该存在type和data这也和onebot无关,只能说这个pr允许了从一个杂乱的dict里提取需要的type和data

@yanyongyu yanyongyu merged commit f119701 into master Jun 20, 2022
@yanyongyu yanyongyu deleted the fix/segment-parse-error branch June 20, 2022 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants