Skip to content

fix the diagnosis of typing error of decorator is very hard to read. #1115#2466

Open
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:1115
Open

fix the diagnosis of typing error of decorator is very hard to read. #1115#2466
asukaminato0721 wants to merge 1 commit intofacebook:mainfrom
asukaminato0721:1115

Conversation

@asukaminato0721
Copy link
Contributor

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.

@meta-cla meta-cla bot added the cla signed label Feb 19, 2026
@asukaminato0721 asukaminato0721 marked this pull request as ready for review February 19, 2026 18:35
Copilot AI review requested due to automatic review settings February 19, 2026 18:35
Copy link

Copilot AI left a comment

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 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_alias in solve.rs to 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.

@github-actions
Copy link

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

the diagnosis of typing error of decorator is very hard to read.

1 participant

Comments