Skip to content

Commit

Permalink
Revert "upgrade pylint and enable linting for PY3 code"
Browse files Browse the repository at this point in the history
  • Loading branch information
clarketm authored Oct 18, 2019
1 parent a9cea4f commit 7defad2
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 170 deletions.
7 changes: 1 addition & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ load("@npm_bazel_typescript//:index.bzl", "ts_setup_workspace")

ts_setup_workspace()

# TODO(clarketm): when `io_bazel_rules_python` supports `python3` interpreter, replace "//:pip.bzl" w/ "@io_bazel_rules_python//python:pip.bzl"
# https://github.com/bazelbuild/rules_python/issues/85
# https://github.com/bazelbuild/rules_python/issues/158
# https://github.com/bazelbuild/rules_python/issues/179
# https://github.com/bazelbuild/rules_python/issues/220
load("//:pip.bzl", "pip_import")
load("@io_bazel_rules_python//python:pip.bzl", "pip_import")

pip_import(
name = "py_deps",
Expand Down
2 changes: 1 addition & 1 deletion experiment/find_developers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def load_content(data):


@functools.total_ordering
class User: # pylint: disable=too-few-public-methods
class User(object): # pylint: disable=too-few-public-methods
"""Store .user and number of .total and .recent commits."""
def __init__(self, blob):
self.user = blob['author']['login']
Expand Down
6 changes: 3 additions & 3 deletions experiment/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def apply_job_overrides(envs_or_args, job_envs_or_args):
envs_or_args.append(job_env_or_arg)


class E2ENodeTest:
class E2ENodeTest(object):

def __init__(self, job_name, job, config):
self.job_name = job_name
Expand Down Expand Up @@ -214,10 +214,10 @@ def generate(self):
return job_config, prow_config, None


class E2ETest:
class E2ETest(object):

def __init__(self, output_dir, job_name, job, config):
self.env_filename = os.path.join(output_dir, '%s.env' % job_name)
self.env_filename = os.path.join(output_dir, '%s.env' % job_name),
self.job_name = job_name
self.job = job
self.common = config['common']
Expand Down
2 changes: 2 additions & 0 deletions experiment/graphql_issue_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

# USAGE: find_issues.py <github_token>

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

import sys
import json
Expand Down
2 changes: 1 addition & 1 deletion experiment/parse_build_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
_CURRENT_YEAR = datetime.datetime.utcnow().year


class TestOutput:
class TestOutput(object):
def __init__(self):
self._lines = []
self._start = None
Expand Down
2 changes: 1 addition & 1 deletion experiment/prepare_release_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import glob
import re

import ruamel.yaml as yaml
import sh
import ruamel.yaml as yaml


TEST_CONFIG_YAML = "experiment/test_config.yaml"
Expand Down
13 changes: 9 additions & 4 deletions hack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,27 @@ test_suite(
py_binary(
name = "pylint_bin",
srcs = ["pylint_bin.py"],
python_version = "PY3",
python_version = "PY2",
tags = ["lint"],
# NOTE: this should only contain direct third party imports and pylint
deps = [
requirement("astroid"),
requirement("backports.functools_lru_cache"),
requirement("configparser"),
requirement("enum34"),
requirement("influxdb"),
requirement("isort"),
requirement("lazy-object-proxy"),
requirement("mccabe"),
requirement("pylint"),
requirement("pytz"),
requirement("PyYAML"),
requirement("requests"),
requirement("ruamel.yaml"),
requirement("typed-ast"),
requirement("setuptools"),
requirement("sh"),
requirement("singledispatch"),
requirement("six"),
requirement("wrapt"),
requirement("ruamel.yaml"),
],
)

Expand Down
2 changes: 1 addition & 1 deletion hack/pylint_bin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python2

# Copyright 2017 The Kubernetes Authors.
#
Expand Down
5 changes: 3 additions & 2 deletions hack/verify-pylint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ export PYLINTHOME=$TEST_TMPDIR

shopt -s extglob globstar

# TODO(clarketm): remove `boskos` exclusion after upgrading to PY3.
"$DIR/pylint_bin" !(gubernator|external|vendor|jenkins|scenarios|triage|boskos|bazel-*)/**/*.py
# TODO(clarketm) there is no version of `pylint` that supports "both" PY2 and PY3
# I am disabling pylint checks for python3 files until migration complete
"$DIR/pylint_bin" !(kettle|metrics|triage|velodrome|hack|gubernator|external|vendor|testgrid|bazel-*)/**/*.py
2 changes: 1 addition & 1 deletion kettle/make_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

import multiprocessing
import multiprocessing.pool
import ruamel.yaml as yaml
import requests
import ruamel.yaml as yaml

import model

Expand Down
5 changes: 1 addition & 4 deletions kettle/make_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ def buckets_yaml():
# pypy compatibility hack
def python_buckets_yaml(python='python3'):
return json.loads(subprocess.check_output(
[python,
'-c',
'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'
],
[python, '-c', 'import json, ruamel.yaml as yaml; print(json.dumps(yaml.safe_load(open("buckets.yaml"))))'],
cwd=os.path.dirname(os.path.abspath(__file__))).decode("utf-8"))

for attempt in [python_buckets_yaml, buckets_yaml, lambda: python_buckets_yaml(python='python')]:
Expand Down
2 changes: 1 addition & 1 deletion kettle/make_json_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def expect(args, needles, negneedles, expected_ret=None):
for needle in negneedles:
# Only match negative needles in the middle of a word, to avoid
# failures on timestamps that happen to contain a short number.
self.assertNotRegexpMatches(result, r'\b%s\b' % needle) # pylint: disable=deprecated-method
self.assertNotRegexpMatches(result, r'\b%s\b' % needle)

add_build('some-job/123', last_month, last_month + 10, 'SUCCESS', junits)
add_build('some-job/456', now - 10, now, 'FAILURE', junits)
Expand Down
7 changes: 3 additions & 4 deletions kettle/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ def get_started_finished(gcs_client, db, todo):
pool = multiprocessing.pool.ThreadPool(16)
try:
for ack_id, (build_dir, started, finished) in pool.imap_unordered(
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])),
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])),
todo):
if finished:
if not db.insert_build(build_dir, started, finished):
print('already present??')
start = time.localtime(started.get('timestamp', 0) if started else 0)
print((build_dir, bool(started), bool(finished),
time.strftime('%F %T %Z', start),
finished and finished.get('result')))
time.strftime('%F %T %Z', start),
finished and finished.get('result')))
build_dirs.append(build_dir)
acks.append(ack_id)
else:
Expand Down
4 changes: 2 additions & 2 deletions metrics/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import time
import traceback

import ruamel.yaml as yaml
import influxdb
import requests
import ruamel.yaml as yaml


def check(cmd, **kwargs):
Expand Down Expand Up @@ -65,7 +65,7 @@ def do_jq(jq_filter, data_filename, out_filename, jq_bin='jq'):
check([jq_bin, jq_filter, data_filename], stdout=out_file)


class BigQuerier:
class BigQuerier(object):
def __init__(self, project, bucket_path, backfill_days, influx_client):
if not project:
raise ValueError('project', project)
Expand Down
131 changes: 0 additions & 131 deletions pip.bzl

This file was deleted.

11 changes: 7 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
astroid==2.2.5
astroid==1.6.6
backports.functools_lru_cache==1.5
certifi==2019.6.16
chardet==3.0.4
configparser==3.8.1
enum34==1.1.6
google-cloud-bigquery==1.18.0
google-cloud-pubsub==0.45.0
idna==2.8
influxdb==5.2.2
isort==4.3.21
jinja2==2.10.1
lazy-object-proxy==1.4.2
lazy-object-proxy==1.4.1
MarkupSafe==1.1.1
mccabe==0.6.1
pylint==2.3.1
pylint==1.9.5
python-dateutil==2.8.0
pytz==2019.2
PyYAML==5.1.1
requests==2.22.0
ruamel.yaml==0.15.97
setuptools==41.1.0
sh==1.12.14
singledispatch==3.4.0.3
six==1.12.0
typed-ast==1.4.0
urllib3==1.25.3
webapp2==2.5.2
wrapt==1.11.2
2 changes: 2 additions & 0 deletions testgrid/conformance/upload_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#
# Usage: see README.md

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

import re
import sys
Expand Down
3 changes: 1 addition & 2 deletions triage/summarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,7 @@ def render(builds, clustered):

SIG_LABEL_RE = re.compile(r'\[sig-([^]]*)\]')


def annotate_owners(data, builds, owners): # pylint: disable=too-many-branches
def annotate_owners(data, builds, owners):
"""
Assign ownership to a cluster based on the share of hits in the last day.
"""
Expand Down
3 changes: 1 addition & 2 deletions triage/summarize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def expect(test, owner, owners=None):
'cols': {'started': [now]}
},
'clustered': [
{'tests': [{'name': test, 'jobs': [
{'name': 'somejob', 'builds': ['123', '125']}]}]}
{'tests': [{'name': test, 'jobs': [{'name': 'somejob', 'builds': ['123', '125']}]}]}
],
}
summarize.annotate_owners(
Expand Down

0 comments on commit 7defad2

Please sign in to comment.