Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3732 +/- ##
==========================================
+ Coverage 93.81% 93.83% +0.01%
==========================================
Files 48 48
Lines 4350 4360 +10
==========================================
+ Hits 4081 4091 +10
Misses 269 269
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:
|
|
🚀 Deployed to https://deploy-preview-3732--nonebot2.netlify.app |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where log level configuration cannot accept integer type values. The solution implements a LegacyUnionField that forces Pydantic v2 to use left-to-right union validation mode, ensuring integers are properly parsed before attempting string conversion.
Key Changes:
- Introduces
LegacyUnionFieldhelper to maintain Pydantic v1-style union type validation behavior - Updates
Config.log_levelfield to useLegacyUnionFieldinstead of plain default value - Adds test coverage for
Union[int, str]field types
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| nonebot/compat.py | Adds LegacyUnionField implementation for Pydantic v2 with left-to-right union mode, uses Field alias for v1 |
| nonebot/config.py | Updates log_level field to use LegacyUnionField for proper int/str union handling |
| tests/test_config.py | Adds test case with int_str field to verify union type behavior |
| tests/.env.example | Adds test data for integer value in environment variable |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fix #3724