Skip to content

Commit c6b5f80

Browse files
Address linting issues identified by Ruff
1 parent b02aba1 commit c6b5f80

File tree

65 files changed

+947
-2037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+947
-2037
lines changed

.github/ruff.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ exclude = [
88
"dist/",
99
".venv/",
1010
"__pycache__/",
11-
"uprotocol/cloudevent/cloudevents_pb2.py"
11+
"uprotocol/cloudevent/cloudevents_pb2.py",
12+
"uprotocol/proto/*"
1213
]
1314

1415
[lint]
@@ -34,5 +35,3 @@ quote-style = "preserve"
3435
indent-style = "space"
3536
docstring-code-format = true
3637
docstring-code-line-length = 100
37-
38-

clean_project.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
SPDX-FileCopyrightText: Copyright (c) 2023 Contributors to the
2+
SPDX-FileCopyrightText: Copyright (c) 2023 Contributors to the
33
Eclipse Foundation
44
55
See the NOTICE file(s) distributed with this work for additional

scripts/pull_and_compile_protos.py

+19-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
SPDX-FileCopyrightText: Copyright (c) 2023 Contributors to the
2+
SPDX-FileCopyrightText: Copyright (c) 2023 Contributors to the
33
Eclipse Foundation
44
55
See the NOTICE file(s) distributed with this work for additional
@@ -34,36 +34,41 @@
3434
PROTO_OUTPUT_DIR = os.path.abspath("../uprotocol/proto")
3535

3636

37-
def clone_or_pull(repo_url, PROTO_REPO_DIR):
37+
def clone_or_pull(repo_url, proto_repo_dir):
3838
try:
39-
repo = Repo.clone_from(repo_url, PROTO_REPO_DIR)
40-
print(f"Repository cloned successfully from {repo_url} to {PROTO_REPO_DIR}")
39+
repo = Repo.clone_from(repo_url, proto_repo_dir)
40+
print(f"Repository cloned successfully from {repo_url} to {proto_repo_dir}")
4141
# Checkout the specific tag
4242
repo.git.checkout(TAG_NAME)
4343
except git.exc.GitCommandError:
4444
try:
4545
git_pull_command = ["git", "pull", "origin", TAG_NAME]
46-
subprocess.run(git_pull_command, cwd=PROTO_REPO_DIR, check=True)
46+
subprocess.run(git_pull_command, cwd=proto_repo_dir, check=True)
4747
print("Git pull successful after clone failure.")
4848
except subprocess.CalledProcessError as pull_error:
4949
print(f"Error during Git pull: {pull_error}")
5050

5151

5252
def execute_maven_command(project_dir, command):
5353
try:
54-
with subprocess.Popen(command, cwd=os.path.join(os.getcwd(), project_dir), shell=True, stdout=subprocess.PIPE,
55-
stderr=subprocess.PIPE, text=True) as process:
54+
with subprocess.Popen(
55+
command,
56+
cwd=os.path.join(os.getcwd(), project_dir),
57+
shell=True,
58+
stdout=subprocess.PIPE,
59+
stderr=subprocess.PIPE,
60+
text=True,
61+
) as process:
5662
stdout, stderr = process.communicate()
5763
print(stdout)
5864

5965
if process.returncode != 0:
6066
print(f"Error: {stderr}")
6167
else:
6268
print("Maven command executed successfully.")
63-
src_directory = os.path.join(os.getcwd(), project_dir, "target", "generated-sources", "protobuf",
64-
"python")
65-
# if not os.path.exists(PROTO_OUTPUT_DIR):
66-
# os.makedirs(PROTO_OUTPUT_DIR)
69+
src_directory = os.path.join(
70+
os.getcwd(), project_dir, "target", "generated-sources", "protobuf", "python"
71+
)
6772

6873
shutil.copytree(src_directory, PROTO_OUTPUT_DIR, dirs_exist_ok=True)
6974
process_python_protofiles(PROTO_OUTPUT_DIR)
@@ -89,8 +94,9 @@ def process_python_protofiles(directory):
8994
file_path = os.path.join(root, file)
9095
replace_in_file(file_path, r'import uri_pb2', 'import uprotocol.proto.uri_pb2')
9196
replace_in_file(file_path, r'import uuid_pb2', 'import uprotocol.proto.uuid_pb2')
92-
replace_in_file(file_path, r'import uprotocol_options_pb2',
93-
'import uprotocol.proto.uprotocol_options_pb2')
97+
replace_in_file(
98+
file_path, r'import uprotocol_options_pb2', 'import uprotocol.proto.uprotocol_options_pb2'
99+
)
94100
replace_in_file(file_path, r'import uattributes_pb2', 'import uprotocol.proto.uattributes_pb2')
95101
replace_in_file(file_path, r'import upayload_pb2', 'import uprotocol.proto.upayload_pb2')
96102
replace_in_file(file_path, r'import ustatus_pb2', 'import uprotocol.proto.ustatus_pb2')

0 commit comments

Comments
 (0)