Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flake8 violations for all files in the asv/plugins/ directory #1088

Merged
merged 4 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion asv/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

6 changes: 4 additions & 2 deletions asv/plugins/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,13 @@ def _setup(self):
env=env)
except Exception:
if env_file_name != env_file.name:
log.info("conda env create/update failed: in {} with file {}".format(self._path, env_file_name))
log.info("conda env create/update failed: "
"in {} with file {}".format(self._path, env_file_name))
elif os.path.isfile(env_file_name):
with open(env_file_name, 'r') as f:
text = f.read()
log.info("conda env create/update failed: in {} with:\n{}".format(self._path, text))
log.info("conda env create/update failed: "
"in {} with:\n{}".format(self._path, text))
raise
finally:
os.unlink(env_file.name)
Expand Down
9 changes: 4 additions & 5 deletions asv/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ def __init__(self, url, mirror_path):

# Clone is missing
log.info("Cloning project")
self._run_git(['clone', '--mirror', url, self._path],
cwd=None)
self._run_git(['clone', '--mirror', url, self._path], cwd=None)

@classmethod
def is_local_repo(cls, path):
Expand Down Expand Up @@ -65,8 +64,8 @@ def _run_git(self, args, cwd=True, **kwargs):
if cwd is not None:
prev = env.get('GIT_CEILING_DIRECTORIES')
env['GIT_CEILING_DIRECTORIES'] = os.pathsep.join(
[os.path.join(os.path.abspath(cwd), os.pardir)]
+ ([prev] if prev is not None else []))
[os.path.join(os.path.abspath(cwd), os.pardir)] +
([prev] if prev is not None else []))
return util.check_output([self._git] + args, env=env, **kwargs)

def get_new_range_spec(self, latest_result, branch=None):
Expand Down Expand Up @@ -149,7 +148,7 @@ def get_name_from_hash(self, commit):
display_error=False).strip()
if not name:
return None
except util.ProcessError as err:
except util.ProcessError:
# Failed to obtain.
return None

Expand Down
4 changes: 2 additions & 2 deletions asv/plugins/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
try:
import hglib
except ImportError as exc:
except ImportError:
hglib = None

from ..console import log
Expand Down Expand Up @@ -91,7 +91,7 @@ def url_match(cls, url):
return False

def get_range_spec(self, commit_a, commit_b):
return '{0}::{1} and not {0}'.format(commit_a, commit_b, commit_a)
return '{0}::{1} and not {0}'.format(commit_a, commit_b)

def get_new_range_spec(self, latest_result, branch=None):
return '{0}::{1}'.format(latest_result, self.get_branch_name(branch))
Expand Down
27 changes: 16 additions & 11 deletions asv/plugins/regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def publish(cls, conf, repo, benchmarks, graphs, revisions):
cls._save_feed(conf, benchmarks, regressions, revisions, revision_to_hash)

@classmethod
def _process_regression(cls, regressions, revision_to_hash, repo, all_params,
graph_data, graph):
def _process_regression(cls, regressions, revision_to_hash, repo,
all_params, graph_data, graph):
j, entry_name, steps, threshold = graph_data

last_v, best_v, jumps = detect_regressions(steps, threshold)
Expand Down Expand Up @@ -138,10 +138,11 @@ def _save_feed(cls, conf, benchmarks, data, revisions, revision_to_hash):
graph_params['p-' + k] = v

for rev1, rev2, value1, value2 in jumps:
timestamps = (run_timestamps[benchmark_name, t] for t in (rev1, rev2) if t is not None)
timestamps = (run_timestamps[benchmark_name, t]
for t in (rev1, rev2) if t is not None)
last_timestamp = max(timestamps)

updated = datetime.datetime.fromtimestamp(last_timestamp/1000)
updated = datetime.datetime.fromtimestamp(last_timestamp / 1000)

params = dict(graph_params)

Expand All @@ -154,7 +155,8 @@ def _save_feed(cls, conf, benchmarks, data, revisions, revision_to_hash):
link = 'index.html#{0}?{1}'.format(benchmark_name, urllib.parse.urlencode(params))

try:
best_percentage = "{0:.2f}%".format(100 * (last_value - best_value) / best_value)
best_percentage = "{0:.2f}%".format(100 *
(last_value - best_value) / best_value)
except ZeroDivisionError:
best_percentage = "{0:.2g} units".format(last_value - best_value)

Expand All @@ -163,14 +165,15 @@ def _save_feed(cls, conf, benchmarks, data, revisions, revision_to_hash):
except ZeroDivisionError:
percentage = "{0:.2g} units".format(value2 - value1)

jump_date = datetime.datetime.fromtimestamp(revision_timestamps[rev2]/1000)
jump_date = datetime.datetime.fromtimestamp(revision_timestamps[rev2] / 1000)
jump_date_str = jump_date.strftime('%Y-%m-%d %H:%M:%S')

if rev1 is not None:
commit_a = revision_to_hash[rev1]
commit_b = revision_to_hash[rev2]
if 'github.com' in conf.show_commit_url:
commit_url = conf.show_commit_url + '../compare/' + commit_a + "..." + commit_b
commit_url = (conf.show_commit_url + '../compare/' +
commit_a + "..." + commit_b)
else:
commit_url = conf.show_commit_url + commit_a
commit_ref = 'in commits <a href="{0}">{1}...{2}</a>'.format(commit_url,
Expand All @@ -191,7 +194,8 @@ def _save_feed(cls, conf, benchmarks, data, revisions, revision_to_hash):
summary = """
<a href="{link}">{percentage} regression</a> on {jump_date_str} {commit_ref}.<br>
New value: {value2_str}, old value: {value1_str}.<br>
Latest value: {last_value_str} ({best_percentage} worse than best value {best_value_str}).
Latest value: {last_value_str} ({best_percentage} worse
than best value {best_value_str}).
""".format(**locals()).strip()

# Information that uniquely identifies a regression
Expand Down Expand Up @@ -243,7 +247,7 @@ def get_graph_data(self, graph, benchmark):
"""
if benchmark.get('params'):
param_iter = enumerate(zip(itertools.product(*benchmark['params']),
graph.get_steps()))
graph.get_steps()))
else:
param_iter = [(None, (None, graph.get_steps()))]

Expand Down Expand Up @@ -302,7 +306,7 @@ def _get_start_revision(self, graph, benchmark, entry_name):
else:
# Commit not found in the branch --- warn and ignore.
log.warning(("Commit {0} specified in `regressions_first_commits` "
"not found in branch").format(start_commit))
"not found in branch").format(start_commit))
self._start_revisions[key] = -1

start_revision = max(start_revision, self._start_revisions[key] + 1)
Expand All @@ -325,7 +329,8 @@ def _get_threshold(self, graph, benchmark, entry_name):
try:
threshold = float(threshold)
except ValueError:
raise util.UserError("Non-float threshold in asv.conf.json: {!r}".format(threshold))
raise util.UserError("Non-float threshold in asv.conf.json: {!r}"
.format(threshold))

if max_threshold is None:
max_threshold = threshold
Expand Down
2 changes: 1 addition & 1 deletion asv/plugins/summarylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def publish(cls, conf, repo, benchmarks, graphs, revisions):
change_rev = [None, last_piece[0]]
else:
# Revision range (left-exclusive)
change_rev = [prev_piece[1]-1, last_piece[0]]
change_rev = [prev_piece[1] - 1, last_piece[0]]

row = dict(name=benchmark_name,
idx=idx,
Expand Down
2 changes: 1 addition & 1 deletion asv/plugins/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, conf, python, requirements, tagged_env_vars):
tagged_env_vars)

try:
import virtualenv
import virtualenv # noqa F401 unused, but required in case the previous step does not work
except ImportError:
raise environment.EnvironmentUnavailable(
"virtualenv package not installed")
Expand Down