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] update ruff v0.0.289 and black 23.9.1 #57145

Merged
merged 7 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
select = C,E,W
exclude =
./build,
# Exclude fluid directory
./python/paddle/base/**,
# Exclude third-party libraries
./third_party/**,
./python/paddle/utils/gast/**,
Expand All @@ -27,3 +25,10 @@ ignore =
per-file-ignores =
# These files need tabs for testing.
test/dygraph_to_static/test_error.py:E101,W191

# temp ignore base directory
python/paddle/base/*:
E713,
E712,
E266,
E714
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ repos:
)$
# For Python files
- repo: https://github.com/psf/black.git
rev: 23.3.0
rev: 23.9.1
hooks:
- id: black
files: (.*\.(py|pyi|bzl)|BUILD|.*\.BUILD|WORKSPACE)$
Expand All @@ -66,7 +66,7 @@ repos:
- id: flake8
args: ["--config=.flake8"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.272
rev: v0.0.289
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --no-cache]
Expand Down
386 changes: 385 additions & 1 deletion pyproject.toml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion python/paddle/distributed/auto_parallel/static/planner_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import os
import pickle
import sys

import numpy as np

Expand Down Expand Up @@ -175,7 +176,7 @@ def plan(self):
self._completer.complete_forward_annotation()

if os.getenv("PADDLE_AUTO_PARALLEL_STAGE", "run") != "run":
quit()
sys.exit()

# parse forward sub block
self._dist_context.block_state.parse_forward_blocks(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2397,7 +2397,7 @@ def run_or_quit(self):
self._logger.info(
"The process will be quitted when just tune not run."
)
quit()
sys.exit()

def tune(self):
begin = time.time()
Expand Down
16 changes: 4 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,7 @@ def run(self):
)
# write version.py and cuda_env_config_py to python_source_dir
write_version_py(
filename='{}/python/paddle/version/__init__.py'.format(
paddle_source_dir
)
filename=f'{paddle_source_dir}/python/paddle/version/__init__.py'
)
write_cuda_env_config_py(
filename=f'{paddle_source_dir}/python/paddle/cuda_env.py'
Expand Down Expand Up @@ -1622,11 +1620,7 @@ def submodules_not_exists_or_empty(folder):
cwd=TOP_DIR,
)
end = time.time()
print(
' --- Submodule initialization took {:.2f} sec'.format(
end - start
)
)
print(f' --- Submodule initialization took {end - start:.2f} sec')
except Exception:
print(' --- Submodule initalization failed')
print('Please run:\n\tgit submodule update --init --recursive')
Expand Down Expand Up @@ -1656,7 +1650,7 @@ def main():
sys.path.insert(1, env_dict_path)
from env_dict import env_dict

global env_dict
global env_dict # noqa: F811
global paddle_binary_dir, paddle_source_dir

paddle_binary_dir = env_dict.get("PADDLE_BINARY_DIR")
Expand All @@ -1667,9 +1661,7 @@ def main():
package_name = env_dict.get("PACKAGE_NAME")

write_version_py(
filename='{}/python/paddle/version/__init__.py'.format(
paddle_binary_dir
)
filename=f'{paddle_binary_dir}/python/paddle/version/__init__.py'
)
write_cuda_env_config_py(
filename=f'{paddle_binary_dir}/python/paddle/cuda_env.py'
Expand Down
1 change: 0 additions & 1 deletion test/legacy_test/test_math_op_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import unittest

import numpy
import numpy as np
from decorator_helper import prog_scope

Expand Down
1 change: 0 additions & 1 deletion test/legacy_test/test_rnn_cell_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import sys
import unittest

import numpy
import numpy as np

sys.path.append("../../test/rnn")
Expand Down