Skip to content

Commit 596fe77

Browse files
committed
Again - move hack job to python3 and enable PY3 linting
This reverts commit ed64df7.
1 parent 9146e32 commit 596fe77

23 files changed

+56
-66
lines changed

WORKSPACE

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,22 @@ load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")
6868

6969
ts_setup_workspace()
7070

71-
load("@io_bazel_rules_python//python:pip.bzl", "pip_import")
71+
load("@rules_python//python:pip.bzl", "pip_import")
7272

7373
pip_import(
7474
name = "py_deps",
75-
requirements = "//:requirements.txt",
75+
python_interpreter = "python2",
76+
requirements = "//:requirements2.txt",
77+
)
78+
79+
load("@py_deps//:requirements.bzl", "pip_install")
80+
81+
pip_install()
82+
83+
pip_import(
84+
name = "py3_deps",
85+
python_interpreter = "python3",
86+
requirements = "//:requirements3.txt",
7687
)
7788

7889
load("//:py.bzl", "python_repos")

experiment/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py_deps//:requirements.bzl", "requirement")
1+
load("@py3_deps//:requirements.bzl", "requirement")
22

33
py_binary(
44
name = "flakedetector",

experiment/find_developers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def load_content(data):
4343

4444

4545
@functools.total_ordering
46-
class User(object): # pylint: disable=too-few-public-methods
46+
class User: # pylint: disable=too-few-public-methods
4747
"""Store .user and number of .total and .recent commits."""
4848
def __init__(self, blob):
4949
self.user = blob['author']['login']

experiment/graphql_issue_example.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616

1717
# USAGE: find_issues.py <github_token>
1818

19-
# Required for pylint: 1.9.4 to tokenize the python3 print function.
20-
from __future__ import print_function
21-
2219
import sys
2320
import json
2421
import argparse

experiment/parse_build_log.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
_CURRENT_YEAR = datetime.datetime.utcnow().year
3030

3131

32-
class TestOutput(object):
32+
class TestOutput:
3333
def __init__(self):
3434
self._lines = []
3535
self._start = None
@@ -81,8 +81,7 @@ def _get_tests(log):
8181
current_test = TestOutput()
8282
if len(ended_test) <= 1:
8383
continue
84-
else:
85-
yield ended_test
84+
yield ended_test
8685
else:
8786
current_test.append(match.group(1))
8887
yield current_test

hack/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py_deps//:requirements.bzl", "requirement")
1+
load("@py3_deps//:requirements.bzl", "requirement")
22
load("@build_bazel_rules_nodejs//:defs.bzl", "nodejs_binary", "nodejs_test")
33

44
package(default_visibility = ["//visibility:public"])
@@ -226,14 +226,13 @@ test_suite(
226226
py_binary(
227227
name = "pylint_bin",
228228
srcs = ["pylint_bin.py"],
229-
python_version = "PY2",
229+
python_version = "PY3",
230230
tags = ["lint"],
231231
# NOTE: this should only contain direct third party imports and pylint
232232
deps = [
233233
requirement("astroid"),
234234
requirement("backports.functools_lru_cache"),
235235
requirement("configparser"),
236-
requirement("enum34"),
237236
requirement("influxdb"),
238237
requirement("isort"),
239238
requirement("lazy-object-proxy"),

hack/pylint_bin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python2
1+
#!/usr/bin/env python3
22

33
# Copyright 2017 The Kubernetes Authors.
44
#

hack/verify-pylint.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,5 @@ export PYLINTHOME=$TEST_TMPDIR
3636

3737
shopt -s extglob globstar
3838

39-
# TODO(clarketm) there is no version of `pylint` that supports "both" PY2 and PY3
40-
# I am disabling pylint checks for python3 files until migration complete
41-
"$DIR/pylint_bin" !(kettle|metrics|triage|velodrome|hack|gubernator|external|vendor|testgrid|bazel-*)/**/*.py
39+
# TODO(clarketm): remove `boskos` exclusion after upgrading to PY3.
40+
"$DIR/pylint_bin" !(gubernator|external|vendor|jenkins|scenarios|triage|boskos|bazel-*)/**/*.py

kettle/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@py_deps//:requirements.bzl", "requirement")
1+
load("@py3_deps//:requirements.bzl", "requirement")
22

33
py_test(
44
name = "make_db_test",

kettle/make_json.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ def make_result(name, time, failure_text):
8181

8282

8383
def buckets_yaml():
84-
import ruamel.yaml as yaml # does not support pypy
84+
import ruamel.yaml as yaml # pylint: disable=import-outside-toplevel
8585
with open(os.path.dirname(os.path.abspath(__file__))+'/buckets.yaml') as fp:
8686
return yaml.safe_load(fp)
8787

8888
# pypy compatibility hack
8989
def python_buckets_yaml(python='python3'):
9090
return json.loads(subprocess.check_output(
91-
[python, '-c', 'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'],
91+
[python, '-c',
92+
'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'
93+
],
9294
cwd=os.path.dirname(os.path.abspath(__file__))).decode("utf-8"))
9395

9496
for attempt in [python_buckets_yaml, buckets_yaml, lambda: python_buckets_yaml(python='python')]:

0 commit comments

Comments
 (0)