Skip to content

Commit 9f0dbb6

Browse files
Add Python autoformatter (#513)
* Add Python autoformatter (no actual formatting yet) * Don't need a venv! * Run formatter! * Run formatter on everything else * Remove --verbose * Some cleanups * Reformat with magic trailing comma skipped
1 parent fbfa2d0 commit 9f0dbb6

File tree

265 files changed

+7414
-7379
lines changed

Some content is hidden

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

265 files changed

+7414
-7379
lines changed

.github/workflows/basic_checks.yml

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -86,26 +86,25 @@ jobs:
8686
8787
style-check:
8888
runs-on: ubuntu-latest
89-
container:
90-
image: ghcr.io/armmbed/mbed-os-env:master-latest
91-
9289
steps:
9390

9491
- name: Checkout repo
95-
uses: actions/checkout@v4
92+
uses: actions/checkout@v5
9693
with:
9794
fetch-depth: 0
95+
96+
- name: Install Formatters
97+
run: |
98+
sudo apt-get update -y
99+
sudo apt-get install astyle aspell
98100
99-
-
100-
name: UTF-8 Check
101+
- name: UTF-8 Check
101102
run: |
102103
git config --global --add safe.directory "$GITHUB_WORKSPACE"
103104
# Make sure we're not introducing any text which is not UTF-8 encoded
104105
git diff origin/${GITHUB_BASE_REF} -U0 | ( grep -a '^+' || true ) | ( ! grep -axv '.*' )
105-
106106
107-
-
108-
name: astyle checks
107+
- name: astyle checks
109108
run: |
110109
set -x
111110
git config --global --add safe.directory "$GITHUB_WORKSPACE"
@@ -134,11 +133,26 @@ jobs:
134133
tee BUILD/badlibs |
135134
sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
136135
# Assert that all assembler files are named correctly
137-
# The strange command below asserts that there are exactly 0 libraries
136+
# The strange command below asserts that there are exactly 0 files
138137
# that do end with .s
139138
find -name "*.s" | tee BUILD/badasm |
140139
sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
141140
141+
# Set up the oldest python version that's currently still supported by Python (as of Fall 2025)
142+
- uses: actions/setup-python@v6
143+
with:
144+
python-version: '3.9'
145+
146+
- name: Install Python packages
147+
run: |
148+
pip install -e ./tools[linters]
149+
150+
- name: Check Python Formatting
151+
run: |
152+
cd tools
153+
ruff format --diff
154+
155+
142156
docs-check:
143157
runs-on: ubuntu-latest
144158

@@ -162,46 +176,39 @@ jobs:
162176
python-tests:
163177
runs-on: ubuntu-latest
164178
steps:
165-
-
166-
name: Checkout repo
167-
uses: actions/checkout@v4
168-
169-
- name: Install python3-venv
170-
run: |
171-
sudo apt-get update
172-
sudo apt-get install -y python3-venv
179+
- name: Checkout repo
180+
uses: actions/checkout@v5
181+
182+
# Set up the oldest python version that's currently still supported by Python (as of Fall 2025)
183+
- uses: actions/setup-python@v6
184+
with:
185+
python-version: '3.9'
173186

174187
- name: Install Python packages
175188
run: |
176-
python3 -m venv venv
177-
source venv/bin/activate
178189
pip install -e ./tools[unit-tests]
179190
180191
- name: Python Tests
181192
run: |
182-
source venv/bin/activate
183193
tools/run_python_tests.sh
184194
185195
check-cmsis-mcu-descriptions-matches-target-list:
186196
runs-on: ubuntu-latest
187197
steps:
188198
- name: Checkout repo
189-
uses: actions/checkout@v4
199+
uses: actions/checkout@v5
190200

191-
- name: Install python3-venv
192-
run: |
193-
sudo apt-get update
194-
sudo apt-get install -y python3-venv
201+
# Set up the oldest python version that's currently still supported by Python (as of Fall 2025)
202+
- uses: actions/setup-python@v6
203+
with:
204+
python-version: '3.9'
195205

196206
- name: Install Python packages
197207
run: |
198-
python3 -m venv venv
199-
source venv/bin/activate
200208
pip install -e ./tools
201209
202210
- name: Verify that cmsis_mcu_descriptions.json5 is in sync with targets.json5
203211
run: |
204-
source venv/bin/activate
205212
cd tools/python
206213
mbed-tools cmsis-mcu-descr find-unused
207214
mbed-tools cmsis-mcu-descr check-missing
@@ -214,7 +221,7 @@ jobs:
214221
steps:
215222
-
216223
name: Checkout repo
217-
uses: actions/checkout@v4
224+
uses: actions/checkout@v5
218225
with:
219226
fetch-depth: 0
220227

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2020 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
#file which is invoked by the cmake build system to check if all necessary python packages are installed.
4+
# file which is invoked by the cmake build system to check if all necessary python packages are installed.
55

66
import sys
77

@@ -10,4 +10,4 @@
1010
except ImportError:
1111
exit(1)
1212

13-
exit(0)
13+
exit(0)

0 commit comments

Comments
 (0)