🎨 pyupgrade --py37-plus
This commit is contained in:
1 parent
a71f6fcd40
commit
fd2ece0f13
84 files changed
+511
-716
No files matched your search
@@ -91,14 +91,12 @@ def _execute(command, **kwargs):
|
||||
if not p.commands[0].process:
|
||||
# the process might have been set to None in case of any exception
|
||||
print(
|
||||
"Error while trying to run command {}".format(joined_command),
|
||||
f"Error while trying to run command {joined_command}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return None, [], []
|
||||
except Exception:
|
||||
print(
|
||||
"Error while trying to run command {}".format(joined_command), file=sys.stderr
|
||||
)
|
||||
print(f"Error while trying to run command {joined_command}", file=sys.stderr)
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
return None, [], []
|
||||
|
||||
@@ -214,7 +212,7 @@ def _rescue_changes(git_executable, folder):
|
||||
)
|
||||
if returncode is None or returncode != 0:
|
||||
raise RuntimeError(
|
||||
'Could not update, "git diff" failed with returncode {}'.format(returncode)
|
||||
f'Could not update, "git diff" failed with returncode {returncode}'
|
||||
)
|
||||
if stdout and "".join(stdout).strip():
|
||||
# we got changes in the working tree, maybe from the user, so we'll now rescue those into a patch
|
||||
@@ -222,9 +220,9 @@ def _rescue_changes(git_executable, folder):
|
||||
import time
|
||||
|
||||
timestamp = time.strftime("%Y%m%d%H%M")
|
||||
patch = os.path.join(folder, "{}-preupdate.patch".format(timestamp))
|
||||
patch = os.path.join(folder, f"{timestamp}-preupdate.patch")
|
||||
|
||||
print(">>> Running: git diff and saving output to {}".format(patch))
|
||||
print(f">>> Running: git diff and saving output to {patch}")
|
||||
returncode, stdout, stderr = _git(["diff"], folder, git_executable=git_executable)
|
||||
if returncode is None or returncode != 0:
|
||||
raise RuntimeError(
|
||||
@@ -233,9 +231,7 @@ def _rescue_changes(git_executable, folder):
|
||||
)
|
||||
)
|
||||
|
||||
import io
|
||||
|
||||
with io.open(patch, "wt", encoding="utf-8", errors="replace") as f:
|
||||
with open(patch, "wt", encoding="utf-8", errors="replace") as f:
|
||||
for line in stdout:
|
||||
f.write(line)
|
||||
|
||||
@@ -274,11 +270,11 @@ def update_source(git_executable, folder, target, force=False, branch=None):
|
||||
returncode, stdout, stderr = _git(["fetch"], folder, git_executable=git_executable)
|
||||
if returncode is None or returncode != 0:
|
||||
raise RuntimeError(
|
||||
'Could not update, "git fetch" failed with returncode {}'.format(returncode)
|
||||
f'Could not update, "git fetch" failed with returncode {returncode}'
|
||||
)
|
||||
|
||||
if branch is not None and branch.strip() != "":
|
||||
print(">>> Running: git checkout {}".format(branch))
|
||||
print(f">>> Running: git checkout {branch}")
|
||||
returncode, stdout, stderr = _git(
|
||||
["checkout", branch], folder, git_executable=git_executable
|
||||
)
|
||||
@@ -293,7 +289,7 @@ def update_source(git_executable, folder, target, force=False, branch=None):
|
||||
returncode, stdout, stderr = _git(["pull"], folder, git_executable=git_executable)
|
||||
if returncode is None or returncode != 0:
|
||||
raise RuntimeError(
|
||||
'Could not update, "git pull" failed with returncode {}'.format(returncode)
|
||||
f'Could not update, "git pull" failed with returncode {returncode}'
|
||||
)
|
||||
|
||||
if force:
|
||||
@@ -316,7 +312,7 @@ def install_source(python_executable, folder, user=False, sudo=False):
|
||||
print(">>> Running: python setup.py clean")
|
||||
returncode, stdout, stderr = _python(["setup.py", "clean"], folder, python_executable)
|
||||
if returncode is None or returncode != 0:
|
||||
print('"python setup.py clean" failed with returncode {}'.format(returncode))
|
||||
print(f'"python setup.py clean" failed with returncode {returncode}')
|
||||
print("Continuing anyways")
|
||||
|
||||
print(">>> Running: python setup.py install")
|
||||
@@ -407,7 +403,7 @@ def main():
|
||||
if python_executable.endswith('"'):
|
||||
python_executable = python_executable[:-1]
|
||||
|
||||
print("Python executable: {!r}".format(python_executable))
|
||||
print(f"Python executable: {python_executable!r}")
|
||||
|
||||
folder = args.folder
|
||||
|
||||
|
||||
Reference in new issue
Block a user