mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
pylint: Enable and fix consider-using-sys-exit warnings
This commit is contained in:
parent
b65e093394
commit
449f56c15b
@ -277,7 +277,7 @@ def main(argv):
|
|||||||
|
|
||||||
if [check, fix, examine_coverage, next_id].count(True) != 1:
|
if [check, fix, examine_coverage, next_id].count(True) != 1:
|
||||||
print("usage: python error_codes.py --check | --fix [--no-confirm] | --examine-coverage | --next")
|
print("usage: python error_codes.py --check | --fix [--no-confirm] | --examine-coverage | --next")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
|
|
||||||
@ -303,9 +303,9 @@ def main(argv):
|
|||||||
if examine_coverage:
|
if examine_coverage:
|
||||||
if not ok:
|
if not ok:
|
||||||
print("Incorrect IDs have to be fixed before applying --examine-coverage")
|
print("Incorrect IDs have to be fixed before applying --examine-coverage")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
res = 0 if examine_id_coverage(cwd, source_id_to_file_names) else 1
|
res = 0 if examine_id_coverage(cwd, source_id_to_file_names) else 1
|
||||||
exit(res)
|
sys.exit(res)
|
||||||
|
|
||||||
ok &= examine_id_coverage(cwd, source_id_to_file_names, new_ids_only=True)
|
ok &= examine_id_coverage(cwd, source_id_to_file_names, new_ids_only=True)
|
||||||
|
|
||||||
@ -314,18 +314,18 @@ def main(argv):
|
|||||||
if next_id:
|
if next_id:
|
||||||
if not ok:
|
if not ok:
|
||||||
print("Incorrect IDs have to be fixed before applying --next")
|
print("Incorrect IDs have to be fixed before applying --next")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
available_ids = {str(id) for id in range(1000, 10000)} - source_id_to_file_names.keys()
|
available_ids = {str(id) for id in range(1000, 10000)} - source_id_to_file_names.keys()
|
||||||
next_id = get_next_id(available_ids)
|
next_id = get_next_id(available_ids)
|
||||||
print(f"Next ID: {next_id}")
|
print(f"Next ID: {next_id}")
|
||||||
exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if ok:
|
if ok:
|
||||||
print("No incorrect IDs found")
|
print("No incorrect IDs found")
|
||||||
exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
assert fix, "Unexpected state, should not come here without --fix"
|
assert fix, "Unexpected state, should not come here without --fix"
|
||||||
|
|
||||||
@ -338,14 +338,14 @@ def main(argv):
|
|||||||
while len(answer) == 0 or answer not in "YNyn":
|
while len(answer) == 0 or answer not in "YNyn":
|
||||||
answer = input("[Y/N]? ")
|
answer = input("[Y/N]? ")
|
||||||
if answer not in "yY":
|
if answer not in "yY":
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# number of appearances for every id
|
# number of appearances for every id
|
||||||
source_id_to_count = { id: len(file_names) for id, file_names in source_id_to_file_names.items() }
|
source_id_to_count = { id: len(file_names) for id, file_names in source_id_to_file_names.items() }
|
||||||
|
|
||||||
fix_ids_in_source_files(source_file_names, source_id_to_count)
|
fix_ids_in_source_files(source_file_names, source_id_to_count)
|
||||||
print("Fixing completed")
|
print("Fixing completed")
|
||||||
exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
@ -6,9 +6,9 @@ Runs pylint on all Python files in project directories known to contain Python s
|
|||||||
|
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from os import path, walk
|
from os import path, walk
|
||||||
from sys import exit
|
|
||||||
from textwrap import dedent
|
from textwrap import dedent
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
|
PROJECT_ROOT = path.dirname(path.dirname(path.realpath(__file__)))
|
||||||
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"
|
PYLINT_RCFILE = f"{PROJECT_ROOT}/scripts/pylintrc"
|
||||||
@ -89,7 +89,7 @@ def main():
|
|||||||
success = pylint_all_filenames(options.dev_mode, rootdirs)
|
success = pylint_all_filenames(options.dev_mode, rootdirs)
|
||||||
|
|
||||||
if not success:
|
if not success:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
print("No problems found.")
|
print("No problems found.")
|
||||||
|
|
||||||
@ -98,4 +98,4 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
main()
|
main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
exit("Interrupted by user. Exiting.")
|
sys.exit("Interrupted by user. Exiting.")
|
||||||
|
@ -20,7 +20,6 @@ disable=
|
|||||||
bad-continuation,
|
bad-continuation,
|
||||||
bad-indentation,
|
bad-indentation,
|
||||||
bad-whitespace,
|
bad-whitespace,
|
||||||
consider-using-sys-exit,
|
|
||||||
duplicate-code,
|
duplicate-code,
|
||||||
invalid-name,
|
invalid-name,
|
||||||
missing-docstring,
|
missing-docstring,
|
||||||
|
@ -5,6 +5,7 @@ import fnmatch
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from typing import Any, List, Optional, Tuple, Union
|
from typing import Any, List, Optional, Tuple, Union
|
||||||
@ -871,4 +872,4 @@ class SolidityLSPTestSuite: # {{{
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
suite = SolidityLSPTestSuite()
|
suite = SolidityLSPTestSuite()
|
||||||
exit_code = suite.main()
|
exit_code = suite.main()
|
||||||
exit(exit_code)
|
sys.exit(exit_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user