fix the diagnosis of typing error of decorator is very hard to read. #1115#2466
fix the diagnosis of typing error of decorator is very hard to read. #1115#2466asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes the readability of decorator error messages by preserving union type alias names in nested type positions. Previously, union type aliases like ResponseReturnValue = int | str | bytes | dict[str, int] | list[int] would be fully expanded in error messages, making them extremely difficult to read. Now, non-generic union type aliases maintain their names, resulting in more concise and readable error messages.
Changes:
- Modified
wrap_type_aliasinsolve.rsto set display names on non-generic union type aliases - Added test to verify union alias names are preserved in callable return types
- Added test to verify decorator error messages use union alias names instead of fully expanded types
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pyrefly/lib/alt/solve.rs | Added logic to set display_name on non-generic union type aliases and their Type-wrapped variants |
| pyrefly/lib/test/type_alias.rs | Added test verifying union alias names appear in reveal_type output for callable return types |
| pyrefly/lib/test/decorators.rs | Added test verifying decorator error messages use union alias names for better readability |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Summary
Fixes #1115
Fixed union alias display so non-generic union type aliases keep their name in nested type positions, which makes decorator error messages readable.
Test Plan
add tests to check this.