Repository navigation
fix Preliminary support for class decorators #2752 - #2773
asukaminato0721 wants to merge 1 commit into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR enhances Pyrefly’s solver to type-check class decorator application so the decorated class name can be rebound to the decorator’s return type (e.g., @remote turning a class name into an ActorHandle[...]), and adds a regression test covering this behavior.
Changes:
- Apply non-dataclass-transform class decorators during
Binding::ClassDeftype solving to infer the post-decoration value type. - Extend
untype_opt/expr_untypehandling forType::KwCalland name lookups to better support the new decorator behavior. - Add a new decorator test case ensuring a class decorator can rebind the class value.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pyrefly/lib/test/decorators.rs |
Adds a regression testcase for a class decorator that rebinds the class symbol to an ActorHandle[T]. |
pyrefly/lib/alt/solve.rs |
Implements class-decorator application during solving and adjusts untyping/name handling to support the new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@migeed-z why does this get classified as "improvement" lol |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
This pull request has been imported. If you are a Meta employee, you can view this in D115174934. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
a170432 to
79825c9
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
79825c9 to
0e17b96
Compare
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
0e17b96 to
94e8ee9
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
|
Note: #2294 generally supersedes this, this is a much more restrictive subset of the bigger change where we fully interpret class decorators. At the moment I think we should take #2294 instead, but there are questions, particularly around backward compatibility. If we take #2294 but make the existing mypy-like behavior our default, then it is likely we might want to merge this change |
|
Closing this in favor of #2294, which we want to get over the line |
|
Closing this PR because linked issue #2752 was closed. |
Summary
Fixes #2752
applying class decorators to the runtime class-value bindingm while preserving the original class object when a decorator still returns a usable type form.
Test Plan
add test