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
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
exclude: setuptools_scm/win_py31_compat.py
repos:
- repo: https://github.com/ambv/black
rev: 18.4a4
rev: 19.10b0
hooks:
- id: black
args: [--safe, --quiet]
python_version: python3.6
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: flake8
- repo: https://github.com/asottile/pyupgrade
rev: v1.2.0
rev: v1.25.1
hooks:
- id: pyupgrade
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ after_test:
artifacts:
# Archive the generated wheel package in the ci.appveyor.com build report.
- path: dist\*

7 changes: 3 additions & 4 deletions src/setuptools_scm/file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ def _link_not_in_scm(n):
# 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)))
Expand Down
2 changes: 1 addition & 1 deletion src/setuptools_scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def count_all_nodes(self):
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):
Expand Down
13 changes: 8 additions & 5 deletions src/setuptools_scm/hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"],
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions src/setuptools_scm/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -89,15 +89,17 @@ 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"]
trace("version pre parse", version)

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:
Expand All @@ -122,7 +124,6 @@ def tags_to_versions(tags, config=None):


class ScmVersion(object):

def __init__(
self,
tag_version,
Expand Down
1 change: 0 additions & 1 deletion testing/runtests_travis.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from subprocess import call

import os
Expand Down
1 change: 0 additions & 1 deletion testing/test_basic_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ def test_dump_version(tmpdir):


def test_parse_plain_fails(recwarn):

def parse(root):
return "tricked you"

Expand Down
57 changes: 25 additions & 32 deletions testing/test_file_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ def test_case(inwd):
(inwd.cwd / "CamelFile").ensure(file=True)
(inwd.cwd / "file2").ensure(file=True)
inwd.add_and_commit()
assert (
set(find_files())
== _sep({"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"})
assert set(find_files()) == _sep(
{"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}
)


Expand All @@ -73,9 +72,9 @@ def test_symlink_dir_source_not_in_scm(inwd):
def test_symlink_file(inwd):
(inwd.cwd / "adir" / "file1link").mksymlinkto("../file1")
inwd.add_and_commit()
assert (
set(find_files("adir")) == _sep({"adir/filea", "adir/file1link"}) # -> ../file1
)
assert set(find_files("adir")) == _sep(
{"adir/filea", "adir/file1link"}
) # -> ../file1


@pytest.mark.skipif(
Expand Down Expand Up @@ -130,8 +129,8 @@ def test_empty_subdir(inwd):
subdir.ensure(dir=True)
(subdir / "xfile").ensure(file=True)
inwd.add_and_commit()
assert (
set(find_files("adir")) == _sep({"adir/filea", "adir/emptysubdir/subdir/xfile"})
assert set(find_files("adir")) == _sep(
{"adir/filea", "adir/emptysubdir/subdir/xfile"}
)


Expand All @@ -142,18 +141,15 @@ def test_double_include_through_symlink(inwd):
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
inwd.add_and_commit()
assert (
set(find_files())
== _sep(
{
"file1",
"adir/datalink", # -> ../data
"adir/filealink", # -> filea
"adir/filea",
"bdir/fileb",
"data/datafile",
}
)
assert set(find_files()) == _sep(
{
"file1",
"adir/datalink", # -> ../data
"adir/filealink", # -> filea
"adir/filea",
"bdir/fileb",
"data/datafile",
}
)


Expand All @@ -164,16 +160,13 @@ def test_symlink_not_in_scm_while_target_is(inwd):
inwd.add_and_commit()
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
assert (
set(find_files())
== _sep(
{
"file1",
"adir/filea",
# adir/datalink and adir/afilelink not included
# because the symlink themselves are not in scm
"bdir/fileb",
"data/datafile",
}
)
assert set(find_files()) == _sep(
{
"file1",
"adir/filea",
# adir/datalink and adir/afilelink not included
# because the symlink themselves are not in scm
"bdir/fileb",
"data/datafile",
}
)
1 change: 0 additions & 1 deletion testing/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


class MockTime(object):

def __format__(self, *k):
return "time"

Expand Down
4 changes: 1 addition & 3 deletions testing/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,4 @@ def test_not_matching_tags(wd):
assert wd.get_version(
tag_regex=r"^apache-arrow-([\.0-9]+)$",
git_describe_command="git describe --dirty --tags --long --exclude *js* ",
).startswith(
"0.11.2"
)
).startswith("0.11.2")
4 changes: 3 additions & 1 deletion testing/test_mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def wd(wd):
archival_mapping = {
"1.0": {"tag": "1.0"},
"1.1.dev3+h000000000000": {
"latesttag": "1.0", "latesttagdistance": "3", "node": "0" * 20
"latesttag": "1.0",
"latesttagdistance": "3",
"node": "0" * 20,
},
"0.0": {"node": "0" * 20},
"1.2.2": {"tag": "release-1.2.2"},
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ markers=
[flake8]
max-complexity = 10
max-line-length = 88
ignore=E203,W503
exclude=
.git,
.tox,
Expand Down