Skip to content

🐛 修复类型错误 - #75

Merged
shoucandanghehe merged 16 commits into
masterfrom
fix/pyright
Feb 26, 2026
Merged

shoucandanghehe merged 16 commits into
masterfrom
fix/pyright

Conversation

@shoucandanghehe

Copy link
Copy Markdown
Member

No description provided.

@codecov

codecov Bot commented Feb 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.73203% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.76%. Comparing base (cd87e1a) to head (ee1c408).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
nonebot/adapters/discord/event.py 84.37% 4 Missing and 1 partial ⚠️
nonebot/adapters/discord/bot.py 55.55% 4 Missing ⚠️
nonebot/adapters/discord/adapter.py 75.00% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 74.76% <96.73%> (-0.21%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.py with dedicated payload models for Discord gateway events
  • Removed event-related models from api/model.py to eliminate duplication
  • Centralized test doubles (DummyAdapter, DummyBot) in tests/fake/doubles.py with shared fixtures
  • Renamed Event.timestamp to Event.timestamp__ to avoid field conflicts with inherited models
  • Added defensive type checking in message handling and improved original_message property

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.

Comment thread tests/fake/doubles.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@shoucandanghehe
shoucandanghehe merged commit ddb84c2 into master Feb 26, 2026
18 checks passed
@shoucandanghehe
shoucandanghehe deleted the fix/pyright branch February 26, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants