Skip to content

Conversation

zhengshengning
Copy link
Contributor

@zhengshengning zhengshengning commented Aug 15, 2025

PR Category

Operator Mechanism

PR Types

Improvements

Description

原来的装饰器实现会导致被装饰的函数类型提示丢失,这里进行修复。

def decorator(func: Callable[_InputT, _RetT]) -> Callable[_InputT, _RetT]:
    def wrapper(*args: _InputT.args, **kwargs: _InputT.kwargs) -> _RetT:
    ....

pcard-67164

Copy link

paddle-bot bot commented Aug 15, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@6bd5e66). Learn more about missing BASE report.

Additional details and impacted files
@@             Coverage Diff             @@
##             develop    #74629   +/-   ##
===========================================
  Coverage           ?   100.00%           
===========================================
  Files              ?         1           
  Lines              ?        16           
  Branches           ?         0           
===========================================
  Hits               ?        16           
  Misses             ?         0           
  Partials           ?         0           

☔ 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.

@SigureMo SigureMo changed the title [API compatibility] Fix the loss of conductive information in modifier types [API compatibility][Typing] Fix the loss of conductive information in modifier types Aug 15, 2025
@SigureMo SigureMo requested review from SigureMo and Copilot August 15, 2025 11:14
Copy link
Contributor

@Copilot 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 improves type annotations for decorator functions to preserve type information and enhance static type checking. The main goal is to fix the loss of type information that occurred when using decorators on functions, making the codebase more type-safe and improving developer experience with better IDE support.

  • Replaces generic _F TypeVar with more specific ParamSpec and return type annotations
  • Updates all decorator implementations to preserve input parameter types and return types
  • Adds proper type annotations using typing_extensions.ParamSpec for better type inference

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit e4e9446 into PaddlePaddle:develop Aug 15, 2025
115 of 120 checks passed
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.

3 participants