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

Replace format() function with PY3 fstrings #1087

Merged
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
2 changes: 1 addition & 1 deletion asv/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,4 @@ def _get_id(owner, date, content):

if date is None:
date = datetime.datetime(1970, 1, 1)
return "tag:{0},{1}:/{2}".format(owner, date.strftime('%Y-%m-%d'), h.hexdigest())
return f"tag:{owner},{date.strftime('%Y-%m-%d')}:/{h.hexdigest()}"
4 changes: 2 additions & 2 deletions asv/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def _run_git(self, args, cwd=True, **kwargs):
return util.check_output([self._git] + args, env=env, **kwargs)

def get_new_range_spec(self, latest_result, branch=None):
return '{0}..{1}'.format(latest_result, self.get_branch_name(branch))
return f'{latest_result}..{self.get_branch_name(branch)}'

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

def pull(self):
# We assume the remote isn't updated during the run of asv
Expand Down
4 changes: 2 additions & 2 deletions asv/plugins/summarylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ def publish(cls, conf, repo, benchmarks, graphs, revisions):
pretty_name = benchmark['pretty_name']

if idx is not None:
pretty_name = '{0}({1})'.format(pretty_name,
", ".join(benchmark_param))
bench_param = ", ".join(benchmark_param)
pretty_name = f'{pretty_name}({bench_param})'

# Each environment parameter combination is reported
# separately on the summarylist page
Expand Down
17 changes: 9 additions & 8 deletions asv/plugins/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(self, conf, python, requirements, tagged_env_vars):
executable = Virtualenv._find_python(python)
if executable is None:
raise environment.EnvironmentUnavailable(
"No executable found for python {0}".format(python))
f"No executable found for python {python}")

self._executable = executable
self._python = python
Expand Down Expand Up @@ -67,7 +67,7 @@ def _find_python(python):
python_version = python[4:]
else:
python_version = python
executable = "python{0}".format(python_version)
executable = f"python{python_version}"

# Find Python executable on path
try:
Expand All @@ -77,8 +77,8 @@ def _find_python(python):

# Maybe the current one is correct?
current_is_pypy = hasattr(sys, 'pypy_version_info')
current_versions = ['{0[0]}'.format(sys.version_info),
'{0[0]}.{0[1]}'.format(sys.version_info)]
current_versions = [f'{sys.version_info[0]}',
f'{sys.version_info[0]}.{sys.version_info[1]}']

if is_pypy == current_is_pypy and python_version in current_versions:
return sys.executable
Expand Down Expand Up @@ -130,15 +130,15 @@ def _setup(self):
env = dict(os.environ)
env.update(self.build_env_vars)

log.info("Creating virtualenv for {0}".format(self.name))
log.info(f"Creating virtualenv for {self.name}")
util.check_call([
sys.executable,
"-mvirtualenv",
"-p",
self._executable,
self._path], env=env)

log.info("Installing requirements for {0}".format(self.name))
log.info(f"Installing requirements for {self.name}")
self._install_requirements()

def _install_requirements(self):
Expand All @@ -160,7 +160,7 @@ def _install_requirements(self):
pkg = key[4:]

if val:
args.append("{0}=={1}".format(pkg, val))
args.append(f"{pkg}=={val}")
else:
args.append(pkg)
self._run_pip(args, timeout=self._install_timeout, env=env)
Expand All @@ -171,5 +171,6 @@ def _run_pip(self, args, **kwargs):
return self.run_executable('python', ['-mpip'] + list(args), **kwargs)

def run(self, args, **kwargs):
log.debug("Running '{0}' in {1}".format(' '.join(args), self.name))
joined_args = ' '.join(args)
log.debug(f"Running '{joined_args}' in {self.name}")
return self.run_executable('python', args, **kwargs)