Skip to content

Commit cfbcdb4

Browse files
authored
Format Python and Bash scripts using ruff and shfmt (#2115)
* Update uv.lock * Add ruff and shfmt to pyproject.toml * Add tools/ruff-format-all.sh * Add tools/shfmt-format-all.sh * Add exceptions for Python >=3.12 and vendored scripts * Apply `ruff check --fix` * Apply `ruff check --unsafe-fixes` * Address ruff check warnings * Remove `silent: true` for upload-man-docs
1 parent c0595c4 commit cfbcdb4

File tree

121 files changed

+3746
-3568
lines changed

Some content is hidden

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

121 files changed

+3746
-3568
lines changed

.evergreen/config_generator/components/abi_compliance_check.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
from shrub.v3.evg_command import EvgCommandType
2-
from shrub.v3.evg_command import s3_put
1+
from shrub.v3.evg_command import EvgCommandType, s3_put
32
from shrub.v3.evg_task import EvgTask
43

54
from config_generator.components.funcs.install_uv import InstallUV
6-
75
from config_generator.etc.function import Function
86
from config_generator.etc.utils import bash_exec
97

.evergreen/config_generator/components/c_std_compile.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
from shrub.v3.evg_task import EvgTask, EvgTaskRef
44

55
from config_generator.components.funcs.install_uv import InstallUV
6-
7-
from config_generator.etc.distros import find_large_distro
8-
from config_generator.etc.distros import make_distro_str
9-
from config_generator.etc.distros import compiler_to_vars
6+
from config_generator.etc.distros import compiler_to_vars, find_large_distro, make_distro_str
107
from config_generator.etc.function import Function
118
from config_generator.etc.utils import bash_exec
129

13-
1410
TAG = 'std-matrix'
1511

1612

@@ -95,10 +91,7 @@ def tasks():
9591
name=task_name,
9692
run_on=distro.name,
9793
tags=tags + [f'std-c{std}'],
98-
commands=[
99-
InstallUV.call(),
100-
StdCompile.call(vars=compile_vars | with_std)
101-
],
94+
commands=[InstallUV.call(), StdCompile.call(vars=compile_vars | with_std)],
10295
)
10396
)
10497

.evergreen/config_generator/components/clang_format.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
from shrub.v3.evg_build_variant import BuildVariant
22
from shrub.v3.evg_command import EvgCommandType
3-
from shrub.v3.evg_task import EvgTask
4-
from shrub.v3.evg_task import EvgTaskRef
3+
from shrub.v3.evg_task import EvgTask, EvgTaskRef
54

65
from config_generator.components.funcs.install_uv import InstallUV
76
from config_generator.etc.distros import find_small_distro
87
from config_generator.etc.function import Function
98
from config_generator.etc.utils import bash_exec
109

11-
12-
TAG = "clang-format"
10+
TAG = 'clang-format'
1311

1412

1513
class ClangFormat(Function):
1614
name = TAG
1715
commands = [
1816
bash_exec(
1917
command_type=EvgCommandType.TEST,
20-
working_dir="mongoc",
18+
working_dir='mongoc',
2119
env={
22-
"DRYRUN": "1",
20+
'DRYRUN': '1',
2321
},
2422
script='PATH="${UV_INSTALL_DIR}:$PATH" uv run --frozen --only-group=format tools/format.py --mode=check',
2523
),
@@ -46,7 +44,7 @@ def variants():
4644
BuildVariant(
4745
name=TAG,
4846
display_name=TAG,
49-
run_on=[find_small_distro("ubuntu2204").name],
50-
tasks=[EvgTaskRef(name=f".{TAG}")],
47+
run_on=[find_small_distro('ubuntu2204').name],
48+
tasks=[EvgTaskRef(name=f'.{TAG}')],
5149
),
5250
]

.evergreen/config_generator/components/cse/darwinssl.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
from shrub.v3.evg_task import EvgTaskRef
33

44
from config_generator.etc.compile import generate_compile_tasks
5-
65
from config_generator.etc.cse.compile import CompileCommon
76
from config_generator.etc.cse.test import generate_test_tasks
87

9-
108
SSL = 'darwinssl'
119
TAG = f'cse-matrix-{SSL}'
1210

@@ -52,9 +50,7 @@ def tasks():
5250

5351
MORE_TAGS = ['cse']
5452

55-
res += generate_compile_tasks(
56-
SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS
57-
)
53+
res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS)
5854

5955
res += generate_test_tasks(SSL, TAG, TEST_MATRIX)
6056

.evergreen/config_generator/components/cse/openssl.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
from shrub.v3.evg_build_variant import BuildVariant
22

33
from config_generator.etc.compile import generate_compile_tasks
4-
from config_generator.etc.function import merge_defns
5-
from config_generator.etc.utils import TaskRef
6-
74
from config_generator.etc.cse.compile import CompileCommon
85
from config_generator.etc.cse.test import generate_test_tasks
9-
6+
from config_generator.etc.function import merge_defns
7+
from config_generator.etc.utils import TaskRef
108

119
SSL = 'openssl'
1210
TAG = f'cse-matrix-{SSL}'
@@ -83,7 +81,7 @@ def tasks():
8381

8482
# PowerPC and zSeries are limited resources.
8583
for task in res:
86-
if any(pattern in task.run_on for pattern in ["power", "zseries"]):
84+
if any(pattern in task.run_on for pattern in ['power', 'zseries']):
8785
task.patchable = False
8886

8987
return res
@@ -98,11 +96,11 @@ def variants():
9896

9997
# PowerPC and zSeries are limited resources.
10098
for task in TASKS:
101-
if any(pattern in task.run_on for pattern in ["power", "zseries"]):
99+
if any(pattern in task.run_on for pattern in ['power', 'zseries']):
102100
tasks.append(
103101
TaskRef(
104102
name=task.name,
105-
batchtime=1440, # 1 day
103+
batchtime=1440, # 1 day
106104
)
107105
)
108106
else:

.evergreen/config_generator/components/cse/winssl.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
from shrub.v3.evg_task import EvgTaskRef
33

44
from config_generator.etc.compile import generate_compile_tasks
5-
65
from config_generator.etc.cse.compile import CompileCommon
76
from config_generator.etc.cse.test import generate_test_tasks
87

9-
108
SSL = 'winssl'
119
TAG = f'cse-matrix-{SSL}'
1210

@@ -50,9 +48,7 @@ def tasks():
5048

5149
MORE_TAGS = ['cse']
5250

53-
res += generate_compile_tasks(
54-
SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS
55-
)
51+
res += generate_compile_tasks(SSL, TAG, SASL_TO_FUNC, COMPILE_MATRIX, MORE_TAGS)
5652

5753
res += generate_test_tasks(SSL, TAG, TEST_MATRIX)
5854

0 commit comments

Comments
 (0)