Skip to content

Commit 6309a6e

Browse files
committed
linting our mx files
1 parent d7590a8 commit 6309a6e

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ def do_run_python(args, extra_vm_args=None, env=None, jdk=None, extra_dists=None
156156
for tool in ["CHROMEINSPECTOR", "TRUFFLE_COVERAGE"]:
157157
if os.path.exists(mx.suite("tools").dependency(tool).path):
158158
dists.append(tool)
159-
else:
160-
mx.logv("%s was not built, not including it automatically" % tool)
161159

162160
graalpython_args.insert(0, '--experimental-options=true')
163161

@@ -742,9 +740,8 @@ def delete_self_if_testdownstream(args):
742740

743741

744742
def update_import(name, suite_py, rev="origin/master"):
745-
mx_name = "mx." + name
746743
parent = os.path.join(SUITE.dir, "..")
747-
for dirpath,dirnames,filenames in os.walk(parent):
744+
for dirpath, dirnames, _ in os.walk(parent):
748745
if os.path.sep in os.path.relpath(dirpath, parent):
749746
dirnames.clear() # we're looking for siblings or sibling-subdirs
750747
elif name in dirnames:
@@ -793,7 +790,7 @@ def update_import_cmd(args):
793790
if os.path.exists(jsonnetfile):
794791
local_names.append(sibling)
795792
repos.append(dd)
796-
for dirpath,dirnames,filenames in os.walk(dd):
793+
for dirpath, dirnames, filenames in os.walk(dd):
797794
mx_dirs = list(filter(lambda x: x.startswith("mx."), dirnames))
798795
if mx_dirs:
799796
dirnames[:] = mx_dirs # don't go deeper once we found some mx dirs
@@ -834,9 +831,9 @@ def update_import_cmd(args):
834831
# find all imports we might update
835832
imports_to_update = set()
836833
for suite_py in suite_py_files:
837-
dict = {}
834+
d = {}
838835
with open(suite_py) as f:
839-
exec(f.read(), dict, dict)
836+
exec(f.read(), d, d) # pylint: disable=exec-used;
840837
for suite in dict["suite"].get("imports", {}).get("suites", []):
841838
import_name = suite["name"]
842839
if suite.get("version") and import_name not in local_names:
@@ -934,7 +931,7 @@ def _python_checkpatchfiles():
934931
pypi_base_url = mx_urlrewrites.rewriteurl("https://pypi.org/packages/").replace("packages/", "")
935932
with open(listfilename, "r") as listfile:
936933
content = listfile.read()
937-
patchfile_pattern = re.compile("lib-graalpython/patches/(.*)\.patch")
934+
patchfile_pattern = re.compile(r"lib-graalpython/patches/(.*)\.patch")
938935
allowed_licenses = ["MIT", "BSD", "MIT license"]
939936
for line in content.split("\n"):
940937
match = patchfile_pattern.search(line)
@@ -949,7 +946,7 @@ def _python_checkpatchfiles():
949946
if data_license not in allowed_licenses:
950947
mx.abort(("The license for the original project %r is %r. We cannot include " +
951948
"a patch for it. Allowed licenses are: %r.") % (package_name, data_license, allowed_licenses))
952-
except Exception as e:
949+
except Exception as e: # pylint: disable=broad-except;
953950
mx.abort("Error getting %r.\n%r" % (package_url, e))
954951
finally:
955952
if response:
@@ -1523,7 +1520,7 @@ def checkout_find_version_for_graalvm(args):
15231520
contents = SUITE.vc.git_command(path, ["show", "%s:%s" % (current_revision, suite)])
15241521
d = {}
15251522
try:
1526-
exec(contents, d, d)
1523+
exec(contents, d, d) # pylint: disable=exec-used;
15271524
except:
15281525
mx.log("suite.py no longer parseable, falling back to %s" % current_commit)
15291526
return

mx.graalpython/mx_graalpython_bench_param.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,4 @@ def _pickling_benchmarks(module='pickle'):
199199

200200
JBENCHMARKS = {
201201
"pyjava": [INTEROP_JAVA_BENCHMARKS],
202-
}
202+
}

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from os.path import join
3030

3131
import mx
32-
import mx_subst
3332
import mx_benchmark
3433
from mx_benchmark import StdOutRule, java_vm_registry, Vm, GuestVm, VmBenchmarkSuite, AveragingBenchmarkMixin
3534
from mx_graalpython_bench_param import HARNESS_PATH
@@ -77,7 +76,7 @@ def _check_vm_args(name, args):
7776

7877

7978
def is_sandboxed_configuration(conf):
80-
return conf == CONFIGURATION_SANDBOXED or conf == CONFIGURATION_SANDBOXED_MULTI
79+
return conf in (CONFIGURATION_SANDBOXED, CONFIGURATION_SANDBOXED_MULTI)
8180

8281

8382
# from six
@@ -365,7 +364,7 @@ def name(self):
365364

366365
def benchSuiteName(self, bmSuiteArgs):
367366
return self.name()
368-
367+
369368
def subgroup(self):
370369
return SUBGROUP_GRAAL_PYTHON
371370

@@ -490,7 +489,7 @@ def __init__(self, name, bench_path, benchmarks, python_path=None):
490489
mx.abort("python harness path not specified!")
491490

492491
self._bench_path = join(SUITE.dir, bench_path)
493-
492+
494493
def get_bench_name(self, benchmarks):
495494
return os.path.basename(os.path.splitext(benchmarks[0])[0])
496495

@@ -542,9 +541,6 @@ def get_benchmark_suites(cls, benchmarks):
542541

543542
class PythonInteropBenchmarkSuite(PythonBaseBenchmarkSuite): # pylint: disable=too-many-ancestors
544543

545-
def __init__(self, name, benchmarks):
546-
super(PythonInteropBenchmarkSuite, self).__init__(name, benchmarks)
547-
548544
def get_vm_registry(self):
549545
return java_vm_registry
550546

@@ -567,7 +563,7 @@ def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
567563
vmArgs += mx.get_runtime_jvm_args(dists + ['com.oracle.graal.python.benchmarks'], jdk=mx.get_jdk())
568564
jmh_entry = ["com.oracle.graal.python.benchmarks.interop.BenchRunner"]
569565
runArgs = self.runArgs(bmSuiteArgs)
570-
566+
571567
bench_name = benchmarks[0]
572568
bench_args = self._benchmarks[bench_name]
573569
return vmArgs + jmh_entry + runArgs + [bench_name] + bench_args
@@ -576,4 +572,3 @@ def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
576572
def get_benchmark_suites(cls, benchmarks):
577573
assert isinstance(benchmarks, dict), "benchmarks must be a dict: {suite: {bench: args, ... }, ...}"
578574
return [cls(suite_name, suite_info[0]) for suite_name, suite_info in benchmarks.items()]
579-

0 commit comments

Comments
 (0)