Skip to content

Commit 6c0266b

Browse files
committed
fix pylint issues
1 parent 24c67c9 commit 6c0266b

File tree

3 files changed

+25
-19
lines changed

3 files changed

+25
-19
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2222
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2323
# OF THE POSSIBILITY OF SUCH DAMAGE.
24+
from __future__ import print_function
25+
2426
import os
2527
import platform
2628
import re
@@ -34,11 +36,10 @@
3436
import mx_gate
3537
import mx_sdk
3638
import mx_subst
37-
import mx_urlrewrites
3839
from mx_gate import Task
3940
from mx_graalpython_bench_param import PATH_MESO, BENCHMARKS
4041
from mx_graalpython_benchmark import PythonBenchmarkSuite, python_vm_registry, CPythonVm, PyPyVm, GraalPythonVm, \
41-
CONFIGURATION_DEFAULT, CONFIGURATION_EXPERIMENTAL_SPLITTING, CONFIGURATION_SANDBOXED
42+
CONFIGURATION_DEFAULT, CONFIG_EXPERIMENTAL_SPLITTING, CONFIGURATION_SANDBOXED
4243
from mx_unittest import unittest
4344

4445
SUITE = mx.suite('graalpython')
@@ -161,7 +162,7 @@ def punittest(args):
161162
# IMPORTANT! This must not be --suite graalpython, because a
162163
# --dynamicimports sulong will otherwise not put sulong.jar on the
163164
# classpath, which means we cannot run our C extension tests!
164-
unittest(args + ['--regex', '(graal\.python)|(com\.oracle\.truffle\.tck\.tests)', "-Dgraal.TraceTruffleCompilation=true"])
165+
unittest(args + ['--regex', r'(graal\.python)|(com\.oracle\.truffle\.tck\.tests)', "-Dgraal.TraceTruffleCompilation=true"])
165166

166167

167168
def nativebuild(args):
@@ -247,7 +248,8 @@ def python_svm(args):
247248
return svm_image
248249

249250

250-
def gate_unittests(args=[], subdir=""):
251+
def gate_unittests(args=None, subdir=""):
252+
args = args or []
251253
_graalpytest_driver = "graalpython/com.oracle.graal.python.test/src/graalpytest.py"
252254
_test_project = "graalpython/com.oracle.graal.python.test/"
253255
for idx, arg in enumerate(args):
@@ -273,7 +275,9 @@ def gate_unittests(args=[], subdir=""):
273275
mx.command_function("python")(["--python.CatchAllExceptions=true", "--python.OpaqueFilesystem"] + pre_args + test_args + post_args)
274276

275277

276-
def run_python_unittests(python_binary, args=[], aot_compatible=True, exclude=[]):
278+
def run_python_unittests(python_binary, args=None, aot_compatible=True, exclude=None):
279+
args = args or []
280+
exclude = exclude or []
277281
# tests root directory
278282
tests_folder = os.path.join(SUITE.dir, "graalpython", "com.oracle.graal.python.test", "src", "tests")
279283

@@ -602,7 +606,7 @@ def update_import(name, rev="origin/master", callback=None):
602606
suitefile = os.path.join(primary.dir, "mx." + primary.name, "suite.py")
603607
with open(suitefile, 'r') as f:
604608
contents = f.read()
605-
dep_re = re.compile("['\"]name['\"]:\s+['\"]%s['\"],\s+['\"]version['\"]:\s+['\"]([a-z0-9]+)['\"]" % name, re.MULTILINE)
609+
dep_re = re.compile(r"['\"]name['\"]:\s+['\"]%s['\"],\s+['\"]version['\"]:\s+['\"]([a-z0-9]+)['\"]" % name, re.MULTILINE)
606610
dep_match = dep_re.search(contents)
607611
if dep_match:
608612
start = dep_match.start(1)
@@ -620,7 +624,7 @@ def update_import_cmd(args):
620624
callback = None
621625
if name == "sulong":
622626
join = os.path.join
623-
callback=lambda: shutil.copy(
627+
callback = lambda: shutil.copy(
624628
join(SUITE_SULONG.dir, "include", "truffle.h"),
625629
join(SUITE.dir, "graalpython", "com.oracle.graal.python.cext", "include", "truffle.h")
626630
) and shutil.copy(
@@ -676,7 +680,7 @@ def import_python_sources(args):
676680
pypy_sources = args.pypy
677681
import_version = args.msg
678682

679-
print """
683+
print("""
680684
So you think you want to update the inlined sources? Here is how it will go:
681685
682686
1. We'll first check the copyrights check overrides file to identify the
@@ -717,7 +721,7 @@ def import_python_sources(args):
717721
python-import.
718722
719723
7. Run the tests and fix any remaining issues.
720-
""".format(mapping)
724+
""".format(mapping))
721725
raw_input("Got it?")
722726

723727
cpy_files = []
@@ -743,7 +747,7 @@ def import_python_sources(args):
743747
if name.startswith("test_") or name.endswith("_tests.py"):
744748
original_file = inlined_file
745749
else:
746-
for root, dirs, files in os.walk(pypy_sources):
750+
for root, _, files in os.walk(pypy_sources):
747751
if os.path.basename(name) in files:
748752
original_file = os.path.join(root, name)
749753
try:
@@ -761,7 +765,7 @@ def import_python_sources(args):
761765
name = os.path.basename(inlined_file)
762766
name = mapping.get(name, name)
763767
if inlined_file.endswith(".h") or inlined_file.endswith(".c"):
764-
for root, dirs, files in os.walk(python_sources):
768+
for root, _, files in os.walk(python_sources):
765769
if os.path.basename(name) in files:
766770
original_file = os.path.join(root, name)
767771
try:
@@ -846,7 +850,7 @@ def _register_vms(namespace):
846850
python_vm_registry.add_vm(CPythonVm(CONFIGURATION_DEFAULT), SUITE)
847851
python_vm_registry.add_vm(PyPyVm(CONFIGURATION_DEFAULT), SUITE)
848852
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIGURATION_DEFAULT), SUITE, 10)
849-
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIGURATION_EXPERIMENTAL_SPLITTING, extra_vm_args=[
853+
python_vm_registry.add_vm(GraalPythonVm(config_name=CONFIG_EXPERIMENTAL_SPLITTING, extra_vm_args=[
850854
'-Dgraal.TruffleExperimentalSplitting=true',
851855
'-Dgraal.TruffleExperimentalSplittingAllowForcedSplits=false'
852856
]), SUITE, 10)

mx.graalpython/mx_graalpython_benchmark.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
SUBGROUP_GRAAL_PYTHON = "graalpython"
5656
PYTHON_VM_REGISTRY_NAME = "Python"
5757
CONFIGURATION_DEFAULT = "default"
58-
CONFIGURATION_EXPERIMENTAL_SPLITTING = "experimental_splitting"
58+
CONFIG_EXPERIMENTAL_SPLITTING = "experimental_splitting"
5959
CONFIGURATION_SANDBOXED = "sandboxed"
6060

6161
DEFAULT_ITERATIONS = 10
@@ -132,7 +132,7 @@ def __init__(self, config_name, options=None, iterations=None):
132132
super(AbstractPythonIterationsControlVm, self).__init__(config_name, options)
133133
try:
134134
self._iterations = int(iterations)
135-
except Exception:
135+
except:
136136
self._iterations = None
137137

138138
def _override_iterations_args(self, args):

mx.graalpython/suite.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# pylint: disable=anomalous-backslash-in-string
12
suite = {
23
# --------------------------------------------------------------------------------------------------------------
34
#
@@ -163,7 +164,8 @@
163164
"sdk:GRAAL_SDK",
164165
"sdk:LAUNCHER_COMMON",
165166
],
166-
"javaCompliance": "1.8",
167+
"javaCompliance": "8+",
168+
"checkstyle": "com.oracle.graal.python",
167169
},
168170

169171
# GRAALPYTHON
@@ -177,8 +179,8 @@
177179
"regex:TREGEX",
178180
],
179181
"buildDependencies": ["com.oracle.graal.python.parser.antlr"],
180-
"checkstyle": "com.oracle.graal.python",
181-
"javaCompliance": "1.8",
182+
"javaCompliance" : "8+",
183+
"checkstyleVersion" : "8.8",
182184
"annotationProcessors": ["truffle:TRUFFLE_DSL_PROCESSOR"],
183185
"workingSets": "Truffle,Python",
184186
},
@@ -194,7 +196,7 @@
194196
"mx:JUNIT"
195197
],
196198
"checkstyle": "com.oracle.graal.python",
197-
"javaCompliance": "1.8",
199+
"javaCompliance": "8+",
198200
"annotationProcessors": ["truffle:TRUFFLE_DSL_PROCESSOR"],
199201
"workingSets": "Truffle,Python",
200202
"testProject": True,
@@ -208,7 +210,7 @@
208210
"mx:JUNIT"
209211
],
210212
"checkstyle": "com.oracle.graal.python",
211-
"javaCompliance": "1.8",
213+
"javaCompliance": "8+",
212214
"workingSets": "Truffle,Python",
213215
"testProject": True,
214216
},

0 commit comments

Comments
 (0)