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][UP005] remove deprecated unittest alias #51834

Merged

Conversation

Ainavo
Copy link
Contributor

@Ainavo Ainavo commented Mar 19, 2023

PR types

Others

PR changes

Others

Describe

UP005 self.assertEqualsself.assertEqual 的别名,在 python3.2 之后已经弃用。

For historical reasons, some of the TestCase methods had one or more aliases that are now deprecated. The following table lists the correct names along with their deprecated aliases:

Method Name Deprecated alias Deprecated alias
assertEqual() failUnlessEqual assertEquals

—— Deprecated aliases

如上所述,可以通过引入 UP005 自动修复 python3.2 后弃用的 self.assertEquals,且转写后不会影响代码的语义,修复命令如下:

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

参考链接:

Tracking issue:

@Ainavo Ainavo changed the title [CodeStyle][UP005]remove_deprecated_unittest_alias [CodeStyle][UP005]remove deprecated unittest alias Mar 19, 2023
@SigureMo SigureMo changed the title [CodeStyle][UP005]remove deprecated unittest alias [CodeStyle][UP005] remove deprecated unittest alias Mar 19, 2023
@paddle-bot paddle-bot bot added the contributor External developers label Mar 19, 2023
SigureMo
SigureMo previously approved these changes Mar 20, 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

#49522,为近期的增量

@SigureMo
Copy link
Member

需要解决一下冲突

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

@SigureMo SigureMo merged commit f3ef748 into PaddlePaddle:develop Mar 21, 2023
@SigureMo SigureMo deleted the remove_deprecated_unittest_alias branch March 21, 2023 06:27
@Ainavo Ainavo restored the remove_deprecated_unittest_alias branch March 21, 2023 07:01
@Ainavo Ainavo deleted the remove_deprecated_unittest_alias branch March 21, 2023 07:03
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