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

Diff for: WORKSPACE

+13-2
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")

Diff for: experiment/BUILD.bazel

+1-1
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",

Diff for: experiment/find_developers.py

+1-1
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']

Diff for: experiment/graphql_issue_example.py

-3
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

Diff for: experiment/parse_build_log.py

+2-3
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

Diff for: hack/BUILD.bazel

+2-3
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"),

Diff for: hack/pylint_bin.py

+1-1
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
#

Diff for: hack/verify-pylint.sh

+2-3
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

Diff for: kettle/BUILD.bazel

+1-1
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",

Diff for: kettle/make_json.py

+4-2
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')]:

Diff for: kettle/make_json_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def expect(args, needles, negneedles, expected_ret=None):
135135
for needle in negneedles:
136136
# Only match negative needles in the middle of a word, to avoid
137137
# failures on timestamps that happen to contain a short number.
138-
self.assertNotRegexpMatches(result, r'\b%s\b' % needle)
138+
self.assertNotRegexpMatches(result, r'\b%s\b' % needle) # pylint: disable=deprecated-method
139139

140140
add_build('some-job/123', last_month, last_month + 10, 'SUCCESS', junits)
141141
add_build('some-job/456', now - 10, now, 'FAILURE', junits)

Diff for: kettle/stream.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ def get_started_finished(gcs_client, db, todo):
6969
pool = multiprocessing.pool.ThreadPool(16)
7070
try:
7171
for ack_id, (build_dir, started, finished) in pool.imap_unordered(
72-
lambda ack_id_job_build: (ack_id_job_build[0], gcs_client.get_started_finished(ack_id_job_build[1], ack_id_job_build[2])),
72+
lambda ack_id_job_build: (ack_id_job_build[0], gcs_client.get_started_finished(
73+
ack_id_job_build[1], ack_id_job_build[2])),
7374
todo):
7475
if finished:
7576
if not db.insert_build(build_dir, started, finished):
7677
print('already present??')
7778
start = time.localtime(started.get('timestamp', 0) if started else 0)
7879
print((build_dir, bool(started), bool(finished),
79-
time.strftime('%F %T %Z', start),
80-
finished and finished.get('result')))
80+
time.strftime('%F %T %Z', start),
81+
finished and finished.get('result')))
8182
build_dirs.append(build_dir)
8283
acks.append(ack_id)
8384
else:

Diff for: load.bzl

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ def repositories():
4848
# Python setup
4949
# pip_import() calls must live in WORKSPACE, otherwise we get a load() after non-load() error
5050
git_repository(
51-
name = "io_bazel_rules_python",
52-
commit = "9d68f24659e8ce8b736590ba1e4418af06ec2552",
51+
name = "rules_python",
52+
commit = "94677401bc56ed5d756f50b441a6a5c7f735a6d4",
5353
remote = "https://github.com/bazelbuild/rules_python.git",
54-
shallow_since = "1565801665 -0400",
54+
shallow_since = "1573842889 -0500",
5555
)
5656

5757
# TODO(fejta): get this to work

Diff for: metrics/BUILD.bazel

+1-1
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
package(default_visibility = ["//visibility:public"])
44

Diff for: metrics/bigquery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def do_jq(jq_filter, data_filename, out_filename, jq_bin='jq'):
6565
check([jq_bin, jq_filter, data_filename], stdout=out_file)
6666

6767

68-
class BigQuerier(object):
68+
class BigQuerier:
6969
def __init__(self, project, bucket_path, backfill_days, influx_client):
7070
if not project:
7171
raise ValueError('project', project)

Diff for: py.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
1616
load("@io_bazel_rules_appengine//appengine:py_appengine.bzl", "py_appengine_repositories")
1717
load(
18-
"@py_deps//:requirements.bzl",
18+
"@py3_deps//:requirements.bzl",
1919
"pip_install",
2020
)
2121

Diff for: releng/BUILD.bazel

+1-1
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 = "generate_tests",

Diff for: releng/generate_tests.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def apply_job_overrides(envs_or_args, job_envs_or_args):
107107
envs_or_args.append(job_env_or_arg)
108108

109109

110-
class E2ENodeTest(object):
110+
class E2ENodeTest:
111111

112112
def __init__(self, job_name, job, config):
113113
self.job_name = job_name
@@ -214,10 +214,10 @@ def generate(self):
214214
return job_config, prow_config, None
215215

216216

217-
class E2ETest(object):
217+
class E2ETest:
218218

219219
def __init__(self, output_dir, job_name, job, config):
220-
self.env_filename = os.path.join(output_dir, '%s.env' % job_name),
220+
self.env_filename = os.path.join(output_dir, '%s.env' % job_name)
221221
self.job_name = job_name
222222
self.job = job
223223
self.common = config['common']

Diff for: requirements.txt

-28
This file was deleted.

Diff for: requirements2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PyYAML==5.1.1

Diff for: requirements3.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
astroid==2.3.3
2+
backports.functools_lru_cache==1.6.1
3+
configparser==4.0.2
4+
influxdb==5.2.3
5+
isort==4.3.21
6+
pylint==2.4.4
7+
PyYAML==5.3
8+
ruamel.yaml==0.16.5
9+
setuptools==44.0.0
10+
sh==1.12.14
11+
singledispatch==3.4.0.3

Diff for: testgrid/conformance/upload_e2e.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#
3333
# Usage: see README.md
3434

35-
# Required for pylint: 1.9.4 to tokenize the python3 print function.
36-
from __future__ import print_function
3735

3836
import re
3937
import sys
@@ -112,7 +110,7 @@ def parse_e2e_logfile(file_handle, year):
112110
if passed is False:
113111
# if we already have found a failure, ignore subsequent pass/fails
114112
continue
115-
elif E2E_LOG_SUCCESS_RE.match(line):
113+
if E2E_LOG_SUCCESS_RE.match(line):
116114
passed = True
117115
elif E2E_LOG_FAIL_RE.match(line):
118116
passed = False

Diff for: velodrome/BUILD.bazel

+1-1
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
package(default_visibility = ["//visibility:public"])
44

0 commit comments

Comments
 (0)