diff --git a/format.sh b/format.sh new file mode 100755 index 00000000000..77f3719323f --- /dev/null +++ b/format.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 -m black . diff --git a/oracle.py b/oracle.py index bd035139b63..e3af0041776 100644 --- a/oracle.py +++ b/oracle.py @@ -235,14 +235,11 @@ def check_status(learning_status, testing_status): for attr in learning_status[rtype]: if learning_status[rtype][attr] != testing_status[rtype][attr]: alarm += 1 - bug_report += ( - "[ERROR] %s %s inconsistency: %s seen after learning run, but %s seen after testing run\n" - % ( - rtype, - attr.upper(), - str(learning_status[rtype][attr]), - str(testing_status[rtype][attr]), - ) + bug_report += "[ERROR] %s %s inconsistency: %s seen after learning run, but %s seen after testing run\n" % ( + rtype, + attr.upper(), + str(learning_status[rtype][attr]), + str(testing_status[rtype][attr]), ) final_bug_report = ( "Liveness assertion failed:\n" + bug_report if bug_report != "" else "" @@ -328,16 +325,13 @@ def check_side_effect( continue if learning_entry[attr] != testing_entry[attr]: alarm += 1 - bug_report += ( - "[ERROR] %s/%s/%s %s inconsistency: %s events seen during learning run, but %s seen during testing run\n" - % ( - rtype, - namespace, - name, - attr.upper(), - str(learning_entry[attr]), - str(testing_entry[attr]), - ) + bug_report += "[ERROR] %s/%s/%s %s inconsistency: %s events seen during learning run, but %s seen during testing run\n" % ( + rtype, + namespace, + name, + attr.upper(), + str(learning_entry[attr]), + str(testing_entry[attr]), ) final_bug_report = ( "Safety assertion failed:\n" + bug_report if bug_report != "" else "" @@ -346,34 +340,28 @@ def check_side_effect( def generate_time_travel_debugging_hint(testing_config): - desc = ( - "Sieve makes the controller time travel back to the history to see the status just %s %s: %s" - % ( - testing_config["timing"], - testing_config["ce-rtype"] - + "/" - + testing_config["ce-namespace"] - + "/" - + testing_config["ce-name"], - testing_config["ce-diff-current"], - ) + desc = "Sieve makes the controller time travel back to the history to see the status just %s %s: %s" % ( + testing_config["timing"], + testing_config["ce-rtype"] + + "/" + + testing_config["ce-namespace"] + + "/" + + testing_config["ce-name"], + testing_config["ce-diff-current"], ) - suggestion = ( - "Please check how controller reacts when seeing %s: %s, the controller might issue %s to %s without proper checking" - % ( - testing_config["ce-rtype"] - + "/" - + testing_config["ce-namespace"] - + "/" - + testing_config["ce-name"], - testing_config["ce-diff-current"], - "deletion" if testing_config["se-etype"] == "ADDED" else "creation", - testing_config["se-rtype"] - + "/" - + testing_config["se-namespace"] - + "/" - + testing_config["se-name"], - ) + suggestion = "Please check how controller reacts when seeing %s: %s, the controller might issue %s to %s without proper checking" % ( + testing_config["ce-rtype"] + + "/" + + testing_config["ce-namespace"] + + "/" + + testing_config["ce-name"], + testing_config["ce-diff-current"], + "deletion" if testing_config["se-etype"] == "ADDED" else "creation", + testing_config["se-rtype"] + + "/" + + testing_config["se-namespace"] + + "/" + + testing_config["se-name"], ) return desc + "\n" + suggestion + "\n" @@ -387,16 +375,13 @@ def generate_obs_gap_debugging_hint(testing_config): + testing_config["ce-name"], testing_config["ce-diff-current"], ) - suggestion = ( - "Please check how controller reacts when seeing %s: %s, the event can trigger a controller side effect, and it might be cancelled by following events" - % ( - testing_config["ce-rtype"] - + "/" - + testing_config["ce-namespace"] - + "/" - + testing_config["ce-name"], - testing_config["ce-diff-current"], - ) + suggestion = "Please check how controller reacts when seeing %s: %s, the event can trigger a controller side effect, and it might be cancelled by following events" % ( + testing_config["ce-rtype"] + + "/" + + testing_config["ce-namespace"] + + "/" + + testing_config["ce-name"], + testing_config["ce-diff-current"], ) return desc + "\n" + suggestion + "\n" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..3f735f03451 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[tool.black] +line-length = 88 +target-version = ['py36'] +include = '\.pyi?$' +exclude = ''' + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | fakegopath + | log + | app + )/ +''' diff --git a/sieve.py b/sieve.py index 1508f0d4e4c..09e5ba949fa 100644 --- a/sieve.py +++ b/sieve.py @@ -664,14 +664,18 @@ def run_batch(project, test, dir, mode, stage, docker): sieve_modes.OBS_GAP, sieve_modes.ATOM_VIO, "learn", - ], ("invalid mode option: %s" % options.mode) + ], ( + "invalid mode option: %s" % options.mode + ) assert options.phase in [ "all", "setup_only", "workload_only", "check_only", "workload_and_check", - ], ("invalid phase option: %s" % options.phase) + ], ( + "invalid phase option: %s" % options.phase + ) print("Running Sieve with %s: %s..." % (options.stage, options.mode))