Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle][UP008] remove super call with parameters #51812

Merged
merged 2 commits into from
Mar 20, 2023

Conversation

Ainavo
Copy link
Contributor

@Ainavo Ainavo commented Mar 18, 2023

PR types

Others

PR changes

Others

Describe

UP008 :使用 super() 代替 super(__class__, self),以自动构造绑定到定义方法的类的超类型实例,以及该方法当前作用的实例(或类方法的类对象)。

This PEP proposes syntactic sugar for use of the super type to automatically construct instances of the super type binding to the class that a method was defined in, and the instance (or class object for classmethods) that the method is currently acting upon.

# new example
super().foo(1, 2)
# old example
super(Foo, self).foo(1, 2)

—— PEP 3135 – New Super

如上所述,可以通过引入 UP008 的 relu 对代码进行自动修复 ,且转写后不会影响代码的语义,修复命令如下:

# 安装 ruff 0.0.254
pip install ruff==0.0.254
# 确定本 rule 自动修复方案合适,因此直接使用命令自动修复
ruff --select UP008 . --fix

此外,将 docstring 和 Markdown 里的一些相关代码一并手动替换掉

@paddle-bot paddle-bot bot added the contributor External developers label Mar 18, 2023
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.

LGTM

@luotao1 luotao1 merged commit 81f3f6b into PaddlePaddle:develop Mar 20, 2023
@Ainavo Ainavo deleted the add_UP008_for_ruff_api branch March 20, 2023 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants