Marco Ricci commited on 2025-02-09 22:17:47
Zeige 2 geänderte Dateien mit 14 Einfügungen und 2 Löschungen.
In general, we want the formatter to deal with too-long lines (E501) as much as possible by itself, and the linter to warn us on E501 lines the formatter *cannot* deal with. However, just naively running the linter and formatter causes the linter to abort on any E501 lines it encounters, because the linter cannot auto-fix them. So we want to run the linter twice, once before the formatter and once after the formatter, while ignoring E501 violations in the first run. (But because E501 noqa markers are now treated as unnecessary noqa markers during the first linting run, we actually need to ignore both E501 and RUF100 in the first run.)
... | ... |
@@ -349,7 +349,11 @@ quote-style = 'single' |
349 | 349 |
ignore = [ |
350 | 350 |
# Suggested ignore by ruff when also using ruff to format. We *do* |
351 | 351 |
# check for E501, because this usually only happens when there is |
352 |
- # a text string that should be manually broken. |
|
352 |
+ # a text string that should be manually broken. However, for |
|
353 |
+ # automated quality control, that specific check is turned off so |
|
354 |
+ # that the linting and formatting can proceed, and then *afterwards* |
|
355 |
+ # the files are re-linted. We hope that any *true* E501 errors left |
|
356 |
+ # over from this *are* text strings that should be manually broken. |
|
353 | 357 |
'W191', 'E111', 'E114', 'E117', 'D206', 'D300', 'Q000', 'Q001', |
354 | 358 |
'Q002', 'Q003', 'COM812', 'COM819', 'ISC001', 'ISC002', |
355 | 359 |
# We use `assert` regularly to appease the type checker, and because |
... | ... |
@@ -53,8 +53,16 @@ is_stgit_patch = bool( |
53 | 53 |
) |
54 | 54 |
|
55 | 55 |
try: |
56 |
- subprocess.run(['hatch', 'fmt', '-l'], check=True) |
|
56 |
+ # In a first run, ignore E501 (line-too-long) and RUF100 |
|
57 |
+ # (unused-noqa), so that E501 errors don't stop the formatter from |
|
58 |
+ # running, but also so that E501 noqas don't get fixed as RUF100 |
|
59 |
+ # violations. Afterwards, run with normal settings to handle true |
|
60 |
+ # E501s. |
|
61 |
+ subprocess.run( |
|
62 |
+ ['hatch', 'fmt', '-l', '--', '--ignore=E501,RUF100'], check=True |
|
63 |
+ ) |
|
57 | 64 |
subprocess.run(['hatch', 'fmt', '-f'], check=True) |
65 |
+ subprocess.run(['hatch', 'fmt', '-l'], check=True) |
|
58 | 66 |
if current_branch == 'master': |
59 | 67 |
subprocess.run( |
60 | 68 |
['hatch', 'env', 'run', '-e', 'types', '--', 'check'], check=True |
61 | 69 |