Modernize python and update pylint (#5096)
Update code to conform to the newer version of pylint available in
ubuntu-22.04, with few exceptions:
- disabled `import-outside-toplevel` for `main()` in
`jerry_client.py`
- disabled `consider-using-with` for the logfile of `TestSuite` in
`test262-harness.py` as using `with` is not practical in that case
Update test262-harness.py to use argparse instead of the now deprecated
optparse
Rename variables in jerry_client_main.py that redefined python builtins
or shadowed variables from an outer scope
Update python files to use f-stirngs
Add minimum python versions (3.6 and 3.8) to the CI jobs: without it the
default python version did not support the `with` statement for
`subprocess.Popen` used in `build.py` on macos, or in some cases f-stirngs
Remove `from __future__` imports that are no-ops in python 3
Remove shebang from non executable files
Re-enable most pylint checkers, except `missing-docstring`
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
from cmd import Cmd
|
||||
from pprint import pprint
|
||||
import math
|
||||
@@ -42,7 +41,7 @@ class DebuggerPrompt(Cmd):
|
||||
def precmd(self, line):
|
||||
self.stop = False
|
||||
if self.debugger.non_interactive:
|
||||
print("%s" % line)
|
||||
print(f"{line}")
|
||||
return line
|
||||
|
||||
def postcmd(self, stop, line):
|
||||
@@ -104,14 +103,14 @@ class DebuggerPrompt(Cmd):
|
||||
if res_type == result.END:
|
||||
self.quit = True
|
||||
return
|
||||
elif res_type == result.TEXT:
|
||||
if res_type == result.TEXT:
|
||||
write(result.get_text())
|
||||
elif res_type == result.PROMPT:
|
||||
break
|
||||
|
||||
args -= 1
|
||||
except ValueError as val_errno:
|
||||
print("Error: expected a positive integer: %s" % val_errno)
|
||||
print(f"Error: expected a positive integer: {val_errno}")
|
||||
do_n = do_next
|
||||
|
||||
def do_step(self, _):
|
||||
@@ -185,10 +184,10 @@ class DebuggerPrompt(Cmd):
|
||||
code = args[1]
|
||||
|
||||
if index < 0 or index > 65535:
|
||||
raise ValueError("Invalid scope chain index: %d (must be between 0 and 65535)" % index)
|
||||
raise ValueError(f"Invalid scope chain index: {index} (must be between 0 and 65535)")
|
||||
|
||||
except ValueError as val_errno:
|
||||
print("Error: %s" % (val_errno))
|
||||
print(f"Error: {val_errno}")
|
||||
return
|
||||
|
||||
self.debugger.eval_at(code, index)
|
||||
@@ -259,10 +258,10 @@ def src_check_args(args):
|
||||
|
||||
return line_num
|
||||
except ValueError as val_errno:
|
||||
print("Error: Non-negative integer number expected: %s" % (val_errno))
|
||||
print(f"Error: Non-negative integer number expected: {val_errno}")
|
||||
return -1
|
||||
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements
|
||||
# pylint: disable=too-many-branches,too-many-locals,too-many-statements,import-outside-toplevel
|
||||
def main():
|
||||
args = jerry_client_main.arguments_parse()
|
||||
|
||||
@@ -325,7 +324,7 @@ def main():
|
||||
|
||||
if res_type == result.END:
|
||||
break
|
||||
elif res_type == result.PROMPT:
|
||||
if res_type == result.PROMPT:
|
||||
prompt.cmdloop()
|
||||
elif res_type == result.TEXT:
|
||||
write(result.get_text())
|
||||
@@ -339,7 +338,7 @@ if __name__ == "__main__":
|
||||
MSG = str(error_msg)
|
||||
if ERRNO == 111:
|
||||
sys.exit("Failed to connect to the JerryScript debugger.")
|
||||
elif ERRNO == 32 or ERRNO == 104:
|
||||
elif ERRNO in (32, 104):
|
||||
sys.exit("Connection closed.")
|
||||
else:
|
||||
sys.exit("Failed to connect to the JerryScript debugger.\nError: %s" % (MSG))
|
||||
sys.exit(f"Failed to connect to the JerryScript debugger.\nError: {MSG}")
|
||||
|
||||
Reference in New Issue
Block a user