diff options
author | Philip Withnall <pwithnall@endlessos.org> | 2020-11-17 15:07:09 +0000 |
---|---|---|
committer | Philip Withnall <pwithnall@endlessos.org> | 2020-11-17 15:50:07 +0000 |
commit | 905b22a17eee2b0b4648f59e615360ca52d3b603 (patch) | |
tree | 7f1bdd4645fb15632ea4707d6b90449f1ad0877c /.gitlab-ci/check-todos.py | |
parent | 053d2ae2b4cd31c98f1523f0bc7748296e633b6d (diff) | |
download | glib-905b22a17eee2b0b4648f59e615360ca52d3b603.tar.gz |
py: Reformat all Python files consistently
This commit is the unmodified results of running
```
black $(git ls-files '*.py')
```
with black version 19.10b0. See #2046.
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Diffstat (limited to '.gitlab-ci/check-todos.py')
-rwxr-xr-x | .gitlab-ci/check-todos.py | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/.gitlab-ci/check-todos.py b/.gitlab-ci/check-todos.py index 83b3eee7a..aa88f0832 100755 --- a/.gitlab-ci/check-todos.py +++ b/.gitlab-ci/check-todos.py @@ -23,18 +23,18 @@ import sys # that’s conventionally used as a way of marking a workaround which needs to # be merged for now, but is to be grepped for and reverted or reworked later. BANNED_KEYWORDS = [ - 'TO' + 'DO', - 'X' + 'XX', - 'W' + 'IP', + "TO" + "DO", + "X" + "XX", + "W" + "IP", ] def main(): parser = argparse.ArgumentParser( - description='Check a range of commits to ensure they don’t contain ' - 'banned keywords.') - parser.add_argument('commits', - help='SHA to diff from, or range of commits to diff') + description="Check a range of commits to ensure they don’t contain " + "banned keywords." + ) + parser.add_argument("commits", help="SHA to diff from, or range of commits to diff") args = parser.parse_args() banned_words_seen = set() @@ -43,47 +43,55 @@ def main(): # Check the log messages for banned words. log_process = subprocess.run( - ['git', 'log', '--no-color', args.commits + '..HEAD'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', - check=True) - log_lines = log_process.stdout.strip().split('\n') + ["git", "log", "--no-color", args.commits + "..HEAD"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + check=True, + ) + log_lines = log_process.stdout.strip().split("\n") for line in log_lines: for keyword in BANNED_KEYWORDS: - if re.search('(^|\W+){}(\W+|$)'.format(keyword), line): + if re.search("(^|\W+){}(\W+|$)".format(keyword), line): banned_words_seen.add(keyword) seen_in_log = True # Check the diff for banned words. diff_process = subprocess.run( - ['git', 'diff', '-U0', '--no-color', args.commits], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='utf-8', - check=True) - diff_lines = diff_process.stdout.strip().split('\n') + ["git", "diff", "-U0", "--no-color", args.commits], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + encoding="utf-8", + check=True, + ) + diff_lines = diff_process.stdout.strip().split("\n") for line in diff_lines: - if not line.startswith('+ '): + if not line.startswith("+ "): continue for keyword in BANNED_KEYWORDS: - if re.search('(^|\W+){}(\W+|$)'.format(keyword), line): + if re.search("(^|\W+){}(\W+|$)".format(keyword), line): banned_words_seen.add(keyword) seen_in_diff = True if banned_words_seen: if seen_in_log and seen_in_diff: - where = 'commit message and diff' + where = "commit message and diff" elif seen_in_log: - where = 'commit message' + where = "commit message" elif seen_in_diff: - where = 'commit diff' - - print('Saw banned keywords in a {}: {}. ' - 'This indicates the branch is a work in progress and should not ' - 'be merged in its current ' - 'form.'.format(where, ', '.join(banned_words_seen))) + where = "commit diff" + + print( + "Saw banned keywords in a {}: {}. " + "This indicates the branch is a work in progress and should not " + "be merged in its current " + "form.".format(where, ", ".join(banned_words_seen)) + ) sys.exit(1) -if __name__ == '__main__': +if __name__ == "__main__": main() |