Skip to content
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
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v2.19.1
hooks:
- id: pyupgrade

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
Expand Down
3 changes: 1 addition & 2 deletions scripts/convert_to_generic_platform_wheel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import argparse
import logging
import os
Expand Down Expand Up @@ -94,7 +93,7 @@ def _convert_to_generic_platform_wheel(wheel_ctx, py2_py3, additional_platforms)
logger.debug('Previous pyver tags: %s', ', '.join(original_pyver_tags))
pyver_tags = _to_generic_pyver(original_pyver_tags)
if py2_py3:
if len(set(["py2", "py3"]) & set(pyver_tags)) == 0:
if len({"py2", "py3"} & set(pyver_tags)) == 0:
raise ValueError("pyver_tags does not contain py2 nor py3")
pyver_tags = list(sorted(set(pyver_tags + ["py2", "py3"])))
if pyver_tags != original_pyver_tags:
Expand Down
10 changes: 5 additions & 5 deletions scripts/update_cmake_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,19 @@ def get_cmake_archive_urls_and_sha256s(version, verbose=False):
for identifier in set(expected_files.values()) - set(urls.keys()):
missing_files.append(expected_files_by_identifier[identifier])
raise RuntimeError(
"Couldn't find %s at %s" % (missing_files, files_base_url)
"Couldn't find {} at {}".format(missing_files, files_base_url)
)

# combine the URLs and SHA256s into a single dictionary
zipped = {}
for value in expected_files.values():
print("[%s]\n%s\n%s\n" % (value, urls[value], shas[value]))
print("[{}]\n{}\n{}\n".format(value, urls[value], shas[value]))
zipped[value] = (urls[value], shas[value])
assert len(zipped) == len(expected_files)

if verbose:
for identifier, (url, sha256) in zipped.items():
print("[%s]\n%s\n%s\n" % (identifier, url, sha256))
print("[{}]\n{}\n{}\n".format(identifier, url, sha256))

return zipped

Expand Down Expand Up @@ -147,7 +147,7 @@ def update_cmake_urls_script(version):
cmake_urls_filename = "CMakeUrls.cmake"
cmake_urls_filepath = os.path.join(ROOT_DIR, cmake_urls_filename)

msg = "Updating '%s' with CMake version %s" % (cmake_urls_filename, version)
msg = "Updating '{}' with CMake version {}".format(cmake_urls_filename, version)
with _log(msg), open(cmake_urls_filepath, "w") as cmake_file:
cmake_file.write(content)

Expand All @@ -169,7 +169,7 @@ def update_docs(version):
pattern = re.compile(
r"CMake \d.(\d)+.\d <https://cmake.org/cmake/help/v\d.(\d)+/index.html>"
)
replacement = "CMake %s <https://cmake.org/cmake/help/v%s/index.html>" % (
replacement = "CMake {} <https://cmake.org/cmake/help/v{}/index.html>".format(
version,
_major_minor(version),
)
Expand Down
9 changes: 4 additions & 5 deletions src/cmake/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
Expand Down Expand Up @@ -91,7 +90,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print("unable to find command, tried {}".format(commands))
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
Expand Down Expand Up @@ -177,11 +176,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
if verbose:
print("keywords are unexpanded, not using")
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = {r.strip() for r in refnames.strip("()").split(",")}
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = {r[len(TAG):] for r in refs if r.startswith(TAG)}
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
Expand All @@ -190,7 +189,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# between branches and tags. By ignoring refnames without digits, we
# filter out many common branch names like "release" and
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
tags = {r for r in refs if re.search(r'\d', r)}
if verbose:
print("discarding '%s', no digits" % ",".join(refs - tags))
if verbose:
Expand Down
1 change: 0 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import sys

from contextlib import contextmanager
Expand Down
1 change: 0 additions & 1 deletion tests/test_cmake.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import pytest
import textwrap

Expand Down
3 changes: 1 addition & 2 deletions tests/test_distribution.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import os
import pytest
import textwrap
Expand All @@ -14,7 +13,7 @@ def _check_cmake_install(virtualenv, tmpdir):
for executable_name in ["cmake", "cpack", "ctest"]:
output = virtualenv.run(
"%s --version" % executable_name, capture=True).splitlines()[0]
assert output == "%s version %s" % (executable_name, expected_version)
assert output == "{} version {}".format(executable_name, expected_version)

test_script = tmpdir.join("test_cmake.cmake")
test_script.write(textwrap.dedent(r"""
Expand Down
15 changes: 7 additions & 8 deletions versioneer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# Version: 0.17

"""The Versioneer - like a rocketeer, but for versions.
Expand Down Expand Up @@ -404,7 +403,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print("unable to find command, tried {}".format(commands))
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
Expand All @@ -415,7 +414,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
print("stdout was %s" % stdout)
return None, p.returncode
return stdout, p.returncode
LONG_VERSION_PY['git'] = '''
LONG_VERSION_PY['git'] = r'''
# This file helps to compute a version number in source trees obtained from
# git-archive tarball (such as those provided by githubs download-from-tag
# feature). Distribution tarballs (built by setup.py sdist) and build
Expand Down Expand Up @@ -986,11 +985,11 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
if verbose:
print("keywords are unexpanded, not using")
raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = {r.strip() for r in refnames.strip("()").split(",")}
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = {r[len(TAG):] for r in refs if r.startswith(TAG)}
if not tags:
# Either we're using git < 1.8.3, or there really are no tags. We use
# a heuristic: assume all version tags have a digit. The old git %d
Expand All @@ -999,7 +998,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# between branches and tags. By ignoring refnames without digits, we
# filter out many common branch names like "release" and
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
tags = {r for r in refs if re.search(r'\d', r)}
if verbose:
print("discarding '%s', no digits" % ",".join(refs - tags))
if verbose:
Expand Down Expand Up @@ -1219,7 +1218,7 @@ def write_to_version_file(filename, versions):
with open(filename, "w") as f:
f.write(SHORT_VERSION_PY % contents)

print("set %s to '%s'" % (filename, versions["version"]))
print("set {} to '{}'".format(filename, versions["version"]))


def plus_or_dot(pieces):
Expand Down Expand Up @@ -1453,7 +1452,7 @@ def get_versions(verbose=False):
try:
ver = versions_from_file(versionfile_abs)
if verbose:
print("got version from file %s %s" % (versionfile_abs, ver))
print("got version from file {} {}".format(versionfile_abs, ver))
return ver
except NotThisMethod:
pass
Expand Down