fix: improve correctness of exits (#539)
* fix: improve correctness of exits * refactor: use sys.exit
This commit is contained in:
+10
-6
@@ -1,8 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.parse
|
||||
from pathlib import Path
|
||||
|
||||
@@ -23,6 +25,8 @@ config = [
|
||||
]
|
||||
|
||||
|
||||
# This file requires Python 3.7
|
||||
# Setting -> None will cause MyPy to notice this.
|
||||
@click.command()
|
||||
def bump_version():
|
||||
current_version = cibuildwheel.__version__
|
||||
@@ -49,7 +53,7 @@ def bump_version():
|
||||
|
||||
if repo_has_uncommitted_changes:
|
||||
print('error: Uncommitted changes detected.')
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
print( 'Current version:', current_version) # noqa
|
||||
new_version = input(' New version: ').strip()
|
||||
@@ -59,7 +63,7 @@ def bump_version():
|
||||
except InvalidVersion:
|
||||
print("error: This version doesn't conform to PEP440")
|
||||
print(' https://www.python.org/dev/peps/pep-0440/')
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
actions = []
|
||||
|
||||
@@ -68,7 +72,7 @@ def bump_version():
|
||||
|
||||
if not paths:
|
||||
print(f'error: Pattern {path_pattern} didn’t match any files')
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
find_pattern = version_pattern.format(current_version)
|
||||
replace_pattern = version_pattern.format(new_version)
|
||||
@@ -83,8 +87,8 @@ def bump_version():
|
||||
)
|
||||
|
||||
if not found_at_least_one_file_needing_update:
|
||||
print(f'error: Didn’t find any occurences of “{find_pattern}” in “{path_pattern}”')
|
||||
exit(1)
|
||||
print(f'error: Didn’t find any occurrences of “{find_pattern}” in “{path_pattern}”')
|
||||
sys.exit(1)
|
||||
|
||||
print()
|
||||
print("Here's the plan:")
|
||||
@@ -102,7 +106,7 @@ def bump_version():
|
||||
|
||||
if answer != 'y':
|
||||
print('Aborted')
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
for path, find, replace in actions:
|
||||
contents = path.read_text(encoding='utf8')
|
||||
|
||||
Reference in New Issue
Block a user