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][ruff] clean I001 ignore - Part 2 #60466

Merged
merged 2 commits into from
Dec 29, 2023

Conversation

gouzil
Copy link
Member

@gouzil gouzil commented Dec 29, 2023

PR types

Others

PR changes

Others

Description

相关链接:

Copy link

paddle-bot bot commented Dec 29, 2023

你的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.

@paddle-bot paddle-bot bot added the contributor External developers label Dec 29, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Dec 29, 2023
'StackTransform',
'StickBreakingTransform',
'TanhTransform',
]
Copy link
Member

Choose a reason for hiding this comment

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

这会改 API 吧,为啥要这么改?

Copy link
Member Author

Choose a reason for hiding this comment

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

修改前:

python
Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> dir(paddle.distribution)
['AbsTransform', 'AffineTransform', 'Bernoulli', 'Beta', 'Binomial', 'Categorical', 'Cauchy', 'ChainTransform', 'ContinuousBernoulli', 'Dirichlet', 'Distribution', 'ExpTransform', 'ExponentialFamily', 'Geometric', 'Gumbel', 'Independent', 'IndependentTransform', 'Laplace', 'LogNormal', 'Multinomial', 'MultivariateNormal', 'Normal', 'Poisson', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'TransformedDistribution', 'Uniform', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'bernoulli', 'beta', 'binomial', 'categorical', 'cauchy', 'constraint', 'continuous_bernoulli', 'dirichlet', 'distribution', 'exponential_family', 'geometric', 'gumbel', 'independent', 'kl', 'kl_divergence', 'laplace', 'lognormal', 'multinomial', 'multivariate_normal', 'normal', 'poisson', 'register_kl', 'transform', 'transformed_distribution', 'uniform', 'variable']
>>> len(dir(paddle.distribution))
69
>>> dir(paddle.distribution.transform)
['AbsTransform', 'AffineTransform', 'ChainTransform', 'ExpTransform', 'F', 'IndependentTransform', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'Type', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'constraint', 'distribution', 'enum', 'math', 'paddle', 'transformed_distribution', 'typing', 'variable']
>>> len(dir(paddle.distribution.transform))
32
>>>

修改后:

python
Python 3.11.5 (main, Sep 11 2023, 08:31:25) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> dir(paddle.distribution)
['AbsTransform', 'AffineTransform', 'Bernoulli', 'Beta', 'Binomial', 'Categorical', 'Cauchy', 'ChainTransform', 'ContinuousBernoulli', 'Dirichlet', 'Distribution', 'ExpTransform', 'ExponentialFamily', 'Geometric', 'Gumbel', 'Independent', 'IndependentTransform', 'Laplace', 'LogNormal', 'Multinomial', 'MultivariateNormal', 'Normal', 'Poisson', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'TransformedDistribution', 'Uniform', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'bernoulli', 'beta', 'binomial', 'categorical', 'cauchy', 'constraint', 'continuous_bernoulli', 'dirichlet', 'distribution', 'exponential_family', 'geometric', 'gumbel', 'independent', 'kl', 'kl_divergence', 'laplace', 'lognormal', 'multinomial', 'multivariate_normal', 'normal', 'poisson', 'register_kl', 'transform', 'transformed_distribution', 'uniform', 'variable']
>>> len(dir(paddle.distribution))
69
>>> dir(paddle.distribution.transform)
['AbsTransform', 'AffineTransform', 'ChainTransform', 'ExpTransform', 'F', 'IndependentTransform', 'PowerTransform', 'ReshapeTransform', 'SigmoidTransform', 'SoftmaxTransform', 'StackTransform', 'StickBreakingTransform', 'TanhTransform', 'Transform', 'Type', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'constraint', 'distribution', 'enum', 'math', 'paddle', 'transformed_distribution', 'typing', 'variable']
>>> len(dir(paddle.distribution.transform))
31
>>>

paddle.distribution.transform下少了一个__all__这个只有python/paddle/distribution/__init__.py在使用

Copy link
Member

Choose a reason for hiding this comment

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

API 是看 __all__ 不是看 dir

Copy link
Member Author

Choose a reason for hiding this comment

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

根据文档: Importing * From a Package, 移除会导致在from paddle.distribution.transform import *Type被导入,所以回滚了

Copy link
Member

Choose a reason for hiding this comment

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

这不是关键,关键是 Paddle 的 API 是看 __all__

Copy link
Member Author

@gouzil gouzil Dec 29, 2023

Choose a reason for hiding this comment

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

Paddle 的 API 似乎只看 __init__.py 下的

@gouzil gouzil requested a review from SigureMo December 29, 2023 15:03
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 5bc7a59 into PaddlePaddle:develop Dec 29, 2023
Wanglongzhi2001 pushed a commit to Wanglongzhi2001/Paddle that referenced this pull request Jan 7, 2024
@gouzil gouzil deleted the noqa_clean_19 branch April 23, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants