mypy: Fix run types in pg_backup_and_purge.

This commit is contained in:
Tim Abbott
2018-08-09 12:55:34 -07:00
parent db1f706d09
commit 054c07b585

View File

@@ -15,8 +15,7 @@ if False:
logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s") logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s")
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def run(args, dry_run=False): def run(args: List[str], dry_run: bool=False) -> str:
# type: (List[str], bool) -> str
if dry_run: if dry_run:
print("Would have run: " + " ".join(map(shlex.quote, args))) print("Would have run: " + " ".join(map(shlex.quote, args)))
return "" return ""
@@ -28,9 +27,9 @@ def run(args, dry_run=False):
logger.error("Could not invoke %s\nstdout: %s\nstderror: %s" logger.error("Could not invoke %s\nstdout: %s\nstderror: %s"
% (args[0], stdout, stderr)) % (args[0], stdout, stderr))
sys.exit(1) sys.exit(1)
return stdout return stdout.decode()
recovery_val = run(['psql', '-t', '-c', 'select pg_is_in_recovery()']).strip().decode() recovery_val = run(['psql', '-t', '-c', 'select pg_is_in_recovery()']).strip()
# Assertion to check that we're extracting the value correctly. # Assertion to check that we're extracting the value correctly.
assert recovery_val in ['t', 'f'] assert recovery_val in ['t', 'f']
if recovery_val == 't': if recovery_val == 't':