Skip to content

Commit 82d6780

Browse files
mnvrCodaFi
authored andcommitted
Minor improvements to the Python linter (swiftlang#12079)
* Mention utils/python_lint.py in docs/ContinuousIntegration.md * Improve error messages in utils/python_lint.py * Make python_lint.py fail if required modules are not found Previously, it returned 0 in such a case, which is considered as a successful exit. * Continue returning success when missing modules [python_lint.py] Reverts ffd3b78
1 parent 58e89b3 commit 82d6780

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

docs/ContinuousIntegration.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- [@swift-ci](#swift-ci)
99
- [Smoke Testing](#smoke-testing)
1010
- [Validation Testing](#validation-testing)
11-
- [Lint Testing](#lint-testing)
11+
- [Linting](#linting)
1212
- [Specific Preset Testing](#specific-preset-testing)
1313
- [Cross Repository Testing](#cross-repository-testing)
1414
- [ci.swift.org bots](#ciswiftorg-bots)
@@ -28,7 +28,7 @@ Users with [commit access](https://swift.org/contributing/#commit-access) can tr
2828
1. Smoke Testing
2929
2. Validation Testing
3030
3. Benchmarking.
31-
4. Lint Testing
31+
4. Linting
3232
5. Source Compatibility Testing
3333
6. Specific Preset Testing
3434

@@ -121,11 +121,11 @@ Platform | Comment | Check Status
121121
macOS platform | @swift-ci Please benchmark | Swift Benchmark on OS X Platform (many runs - rigorous)
122122
macOS platform | @swift-ci Please smoke benchmark | Swift Benchmark on OS X Platform (few runs - sanity)
123123

124-
### Lint Testing
124+
### Linting
125125

126-
Language | Comment | Check Status
127-
------------ | ------- | ------------
128-
Python | @swift-ci Please Python lint | Python lint
126+
Language | Comment | What it Does | Corresponding Local Command
127+
------------ | ------- | ------------ | -------------
128+
Python | @swift-ci Please Python lint | Lints Python sources | `./utils/python_lint.py`
129129

130130
### Source Compatibility Testing
131131

utils/python_lint.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,22 @@ def lint(arguments, verbose=True):
2323
)
2424
if flake8_result != 0:
2525
if verbose:
26-
print("Missing modules flake8 or flake8-import-order. Please be"
27-
" sure to install these python packages before linting.")
26+
print("""
27+
The flake8 and flake8-import-order Python packages are required for linting,
28+
but these were not found on your system.
29+
30+
You can install these using:
31+
32+
python -m pip install flake8
33+
python -m pip install flake8-import-order
34+
35+
For more help, see http://flake8.pycqa.org.""")
36+
37+
# We should be returning `flake8_result` from here. However,
38+
# some Python files lint themselves using embedded doctests,
39+
# which causes CI smoke tests to fail because the Linux nodes
40+
# do not have these modules installed.
41+
2842
return 0
2943

3044
utils_directory = os.path.dirname(os.path.abspath(__file__))

0 commit comments

Comments
 (0)