Repository navigation
🐛 修复类型错误 - #75
🐛 修复类型错误#75
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #75 +/- ##
==========================================
- Coverage 74.96% 74.76% -0.21%
==========================================
Files 34 37 +3
Lines 7090 7053 -37
Branches 362 371 +9
==========================================
- Hits 5315 5273 -42
- Misses 1709 1713 +4
- Partials 66 67 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
将重复的 DummyAdapter/DummyBot 和局部 fixture 收敛到 tests/fake 与 conftest,减少测试样板并提升一致性。顺带修复若干测试类型收窄问题,保持现有测试语义不变。
There was a problem hiding this comment.
Pull request overview
This PR refactors event models and test infrastructure to fix type errors. The main changes include:
Purpose: Consolidates event payload models into a dedicated module, removes unused TypedDict definitions, and centralizes test utilities to improve type safety and reduce code duplication.
Changes:
- Created new
api/models/gateway_events.pywith dedicated payload models for Discord gateway events - Removed event-related models from
api/model.pyto eliminate duplication - Centralized test doubles (
DummyAdapter,DummyBot) intests/fake/doubles.pywith shared fixtures - Renamed
Event.timestamptoEvent.timestamp__to avoid field conflicts with inherited models - Added defensive type checking in message handling and improved
original_messageproperty
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| nonebot/adapters/discord/api/models/gateway_events.py | New file with payload models for interaction, message, reaction, and typing events |
| nonebot/adapters/discord/api/models/init.py | Exports for new payload models |
| nonebot/adapters/discord/event.py | Updated to use new payload models as mixins; renamed timestamp field |
| nonebot/adapters/discord/api/model.py | Removed deprecated event models now in gateway_events.py |
| nonebot/adapters/discord/api/init.py | Updated exports after model refactoring |
| nonebot/adapters/discord/message.py | Removed unused TypedDict definitions that were only for TYPE_CHECKING |
| nonebot/adapters/discord/bot.py | Improved type annotations and message validation logic |
| nonebot/adapters/discord/adapter.py | Updated type annotations for BaseBot compatibility |
| nonebot/adapters/discord/exception.py | Added @override decorators to methods |
| nonebot/adapters/discord/commands/params.py | Made event parameter keyword-only in _solve method |
| tests/fake/doubles.py | New centralized test doubles for adapter and bot |
| tests/conftest.py | Added fixtures for dummy_adapter, dummy_adapter_list_response, dummy_bot |
| tests/test_*.py | Updated to use centralized test doubles instead of local definitions |
| tests/test_message_segment_validator.py | Added assertion to verify message_id is not UNSET |
| tests/test_interaction_user_id.py | Added required attachment_size_limit field to test payload |
| tests/test_event_forward_ref_rebuild.py | Fixed union type usage to avoid type checker issues |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 22 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.