summaryrefslogtreecommitdiff
path: root/src/setuptools_scm
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2019-11-25 22:04:43 +0100
committerJason R. Coombs <jaraco@jaraco.com>2019-11-25 16:04:43 -0500
commite9cbdb231a59f06a508d86f2b5b14719ee4bbc34 (patch)
tree0b1cdf06b85982a8b0276e33ab86e8148ef600b3 /src/setuptools_scm
parent5a201f5da3c97856b53a16a954e4db9f89ad31f9 (diff)
downloadsetuptools-scm-e9cbdb231a59f06a508d86f2b5b14719ee4bbc34.tar.gz
update pre-commit setup to modern practices and ensure flake8 is in line as well (#369)
Diffstat (limited to 'src/setuptools_scm')
-rw-r--r--src/setuptools_scm/file_finder.py7
-rw-r--r--src/setuptools_scm/git.py2
-rw-r--r--src/setuptools_scm/hg.py13
-rw-r--r--src/setuptools_scm/version.py13
4 files changed, 19 insertions, 16 deletions
diff --git a/src/setuptools_scm/file_finder.py b/src/setuptools_scm/file_finder.py
index 18712bf..ce7cbad 100644
--- a/src/setuptools_scm/file_finder.py
+++ b/src/setuptools_scm/file_finder.py
@@ -31,10 +31,9 @@ def scm_find_files(path, scm_files, scm_dirs):
# directory not in scm, don't walk it's content
dirnames[:] = []
continue
- if (
- os.path.islink(dirpath)
- and not os.path.relpath(realdirpath, realpath).startswith(os.pardir)
- ):
+ if os.path.islink(dirpath) and not os.path.relpath(
+ realdirpath, realpath
+ ).startswith(os.pardir):
# a symlink to a directory not outside path:
# we keep it in the result and don't walk its content
res.append(os.path.join(path, os.path.relpath(dirpath, path)))
diff --git a/src/setuptools_scm/git.py b/src/setuptools_scm/git.py
index c8a810c..cf027ed 100644
--- a/src/setuptools_scm/git.py
+++ b/src/setuptools_scm/git.py
@@ -65,7 +65,7 @@ class GitWorkdir(object):
def warn_on_shallow(wd):
"""experimental, may change at any time"""
if wd.is_shallow():
- warnings.warn('"%s" is shallow and may cause errors' % (wd.path,))
+ warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
def fetch_on_shallow(wd):
diff --git a/src/setuptools_scm/hg.py b/src/setuptools_scm/hg.py
index 8fedd68..d699d45 100644
--- a/src/setuptools_scm/hg.py
+++ b/src/setuptools_scm/hg.py
@@ -15,9 +15,7 @@ def _hg_tagdist_normalize_tagcommit(config, tag, dist, node, branch):
# ignore commits that only modify .hgtags and nothing else:
" and (merge() or file('re:^(?!\\.hgtags).*$'))"
" and not tag({tag!r}))" # ignore the tagged commit itself
- ).format(
- tag=tag
- )
+ ).format(tag=tag)
if tag != "0.0":
commits = do(
["hg", "log", "-r", revset, "--template", "{node|short}"],
@@ -71,7 +69,12 @@ def parse(root, config=None):
def get_latest_normalizable_tag(root):
# Gets all tags containing a '.' (see #229) from oldest to newest
cmd = [
- "hg", "log", "-r", "ancestors(.) and tag('re:\\.')", "--template", "{tags}\n"
+ "hg",
+ "log",
+ "-r",
+ "ancestors(.) and tag('re:\\.')",
+ "--template",
+ "{tags}\n",
]
outlines = do(cmd, root).split()
if not outlines:
@@ -81,7 +84,7 @@ def get_latest_normalizable_tag(root):
def get_graph_distance(root, rev1, rev2="."):
- cmd = ["hg", "log", "-q", "-r", "%s::%s" % (rev1, rev2)]
+ cmd = ["hg", "log", "-q", "-r", "{}::{}".format(rev1, rev2)]
out = do(cmd, root)
return len(out.strip().splitlines()) - 1
diff --git a/src/setuptools_scm/version.py b/src/setuptools_scm/version.py
index 4f46331..783cffa 100644
--- a/src/setuptools_scm/version.py
+++ b/src/setuptools_scm/version.py
@@ -34,11 +34,11 @@ def _parse_version_tag(tag, config):
result = {
"version": match.group(key),
- "prefix": match.group(0)[:match.start(key)],
- "suffix": match.group(0)[match.end(key):],
+ "prefix": match.group(0)[: match.start(key)],
+ "suffix": match.group(0)[match.end(key) :],
}
- trace("tag '%s' parsed to %s" % (tag, result))
+ trace("tag '{}' parsed to {}".format(tag, result))
return result
@@ -89,7 +89,7 @@ def tag_to_version(tag, config=None):
tagdict = _parse_version_tag(tag, config)
if not isinstance(tagdict, dict) or not tagdict.get("version", None):
- warnings.warn("tag %r no version found" % (tag,))
+ warnings.warn("tag {!r} no version found".format(tag))
return None
version = tagdict["version"]
@@ -97,7 +97,9 @@ def tag_to_version(tag, config=None):
if tagdict.get("suffix", ""):
warnings.warn(
- "tag %r will be stripped of its suffix '%s'" % (tag, tagdict["suffix"])
+ "tag {!r} will be stripped of its suffix '{}'".format(
+ tag, tagdict["suffix"]
+ )
)
if VERSION_CLASS is not None:
@@ -122,7 +124,6 @@ def tags_to_versions(tags, config=None):
class ScmVersion(object):
-
def __init__(
self,
tag_version,