Skip to content

Commit 1f6fa8f

Browse files
explanatory note for English (#74457)
1 parent 6256392 commit 1f6fa8f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

python/paddle/utils/decorator_utils.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,48 +37,48 @@
3737

3838

3939
class DecoratorBase(Generic[_P, _R]):
40-
"""装饰器基类,提供通用装饰器框架
40+
"""Decorative base class, providing a universal decorative framework.
4141
42-
子类只需实现 `process` 方法定义核心逻辑
42+
Subclass only needs to implement the 'process' method to define the core logic.
4343
"""
4444

4545
def __init__(self, *args: Any, **kwargs: Any) -> None:
46-
"""初始化装饰器参数"""
46+
"""Initialize decorator parameters"""
4747
self.args = args
4848
self.kwargs = kwargs
4949

5050
def __call__(self, func: _DecoratedFunc[_P, _R]) -> _DecoratedFunc[_P, _R]:
51-
"""作为装饰器应用的入口点"""
51+
"""As an entry point for decorative applications"""
5252

5353
@functools.wraps(func)
5454
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> _R:
55-
# 预处理参数
55+
# Pretreatment parameters
5656
processed_args, processed_kwargs = self.process(args, kwargs)
57-
# 调用原函数
57+
# Call the original function
5858
return func(*processed_args, **processed_kwargs)
5959

60-
# 保留原始签名
60+
# Keep original signature
6161
wrapper.__signature__ = inspect.signature(func)
6262
return cast("_DecoratedFunc[_P, _R]", wrapper)
6363

6464
def process(
6565
self, args: tuple[Any, ...], kwargs: dict[str, Any]
6666
) -> tuple[tuple[Any, ...], dict[str, Any]]:
67-
"""子类必须实现的核心处理方法
67+
"""Core processing methods that subclasses must implement.
6868
6969
Args:
70-
args: 位置参数
71-
kwargs: 关键字参数
70+
args: positional parameter
71+
kwargs: Keyword Argument
7272
7373
Returns:
74-
处理后的 (args, kwargs) 元组
74+
Processed tuples (args, kwargs)
7575
"""
7676
raise NotImplementedError("Subclasses must implement this method")
7777

7878

79-
# 示例实现:参数别名装饰器
79+
# Example implementation: Parameter alias decorator
8080
class ParamAliasDecorator(DecoratorBase[_P, _R]):
81-
"""参数别名处理的装饰器实现"""
81+
"""Implementation of Decorator for Parameter Alias Processing"""
8282

8383
def __init__(self, alias_mapping: dict[str, Iterable[str]]) -> None:
8484
super().__init__()

0 commit comments

Comments
 (0)