Skip to content

Commit e9cbdb2

Browse files
RonnyPfannschmidtjaraco
authored andcommitted
update pre-commit setup to modern practices and ensure flake8 is in line as well (#369)
1 parent 5a201f5 commit e9cbdb2

13 files changed

+52
-60
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
exclude: setuptools_scm/win_py31_compat.py
22
repos:
33
- repo: https://github.com/ambv/black
4-
rev: 18.4a4
4+
rev: 19.10b0
55
hooks:
66
- id: black
77
args: [--safe, --quiet]
8-
python_version: python3.6
98
- repo: https://github.com/pre-commit/pre-commit-hooks
10-
rev: v1.2.3
9+
rev: v2.4.0
1110
hooks:
1211
- id: trailing-whitespace
1312
- id: end-of-file-fixer
1413
- id: check-yaml
1514
- id: debug-statements
1615
- id: flake8
1716
- repo: https://github.com/asottile/pyupgrade
18-
rev: v1.2.0
17+
rev: v1.25.1
1918
hooks:
2019
- id: pyupgrade

appveyor.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ after_test:
4141
artifacts:
4242
# Archive the generated wheel package in the ci.appveyor.com build report.
4343
- path: dist\*
44-

src/setuptools_scm/file_finder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ def _link_not_in_scm(n):
3131
# directory not in scm, don't walk it's content
3232
dirnames[:] = []
3333
continue
34-
if (
35-
os.path.islink(dirpath)
36-
and not os.path.relpath(realdirpath, realpath).startswith(os.pardir)
37-
):
34+
if os.path.islink(dirpath) and not os.path.relpath(
35+
realdirpath, realpath
36+
).startswith(os.pardir):
3837
# a symlink to a directory not outside path:
3938
# we keep it in the result and don't walk its content
4039
res.append(os.path.join(path, os.path.relpath(dirpath, path)))

src/setuptools_scm/git.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def count_all_nodes(self):
6565
def warn_on_shallow(wd):
6666
"""experimental, may change at any time"""
6767
if wd.is_shallow():
68-
warnings.warn('"%s" is shallow and may cause errors' % (wd.path,))
68+
warnings.warn('"{}" is shallow and may cause errors'.format(wd.path))
6969

7070

7171
def fetch_on_shallow(wd):

src/setuptools_scm/hg.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ def _hg_tagdist_normalize_tagcommit(config, tag, dist, node, branch):
1515
# ignore commits that only modify .hgtags and nothing else:
1616
" and (merge() or file('re:^(?!\\.hgtags).*$'))"
1717
" and not tag({tag!r}))" # ignore the tagged commit itself
18-
).format(
19-
tag=tag
20-
)
18+
).format(tag=tag)
2119
if tag != "0.0":
2220
commits = do(
2321
["hg", "log", "-r", revset, "--template", "{node|short}"],
@@ -71,7 +69,12 @@ def parse(root, config=None):
7169
def get_latest_normalizable_tag(root):
7270
# Gets all tags containing a '.' (see #229) from oldest to newest
7371
cmd = [
74-
"hg", "log", "-r", "ancestors(.) and tag('re:\\.')", "--template", "{tags}\n"
72+
"hg",
73+
"log",
74+
"-r",
75+
"ancestors(.) and tag('re:\\.')",
76+
"--template",
77+
"{tags}\n",
7578
]
7679
outlines = do(cmd, root).split()
7780
if not outlines:
@@ -81,7 +84,7 @@ def get_latest_normalizable_tag(root):
8184

8285

8386
def get_graph_distance(root, rev1, rev2="."):
84-
cmd = ["hg", "log", "-q", "-r", "%s::%s" % (rev1, rev2)]
87+
cmd = ["hg", "log", "-q", "-r", "{}::{}".format(rev1, rev2)]
8588
out = do(cmd, root)
8689
return len(out.strip().splitlines()) - 1
8790

src/setuptools_scm/version.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def _parse_version_tag(tag, config):
3434

3535
result = {
3636
"version": match.group(key),
37-
"prefix": match.group(0)[:match.start(key)],
38-
"suffix": match.group(0)[match.end(key):],
37+
"prefix": match.group(0)[: match.start(key)],
38+
"suffix": match.group(0)[match.end(key) :],
3939
}
4040

41-
trace("tag '%s' parsed to %s" % (tag, result))
41+
trace("tag '{}' parsed to {}".format(tag, result))
4242
return result
4343

4444

@@ -89,15 +89,17 @@ def tag_to_version(tag, config=None):
8989

9090
tagdict = _parse_version_tag(tag, config)
9191
if not isinstance(tagdict, dict) or not tagdict.get("version", None):
92-
warnings.warn("tag %r no version found" % (tag,))
92+
warnings.warn("tag {!r} no version found".format(tag))
9393
return None
9494

9595
version = tagdict["version"]
9696
trace("version pre parse", version)
9797

9898
if tagdict.get("suffix", ""):
9999
warnings.warn(
100-
"tag %r will be stripped of its suffix '%s'" % (tag, tagdict["suffix"])
100+
"tag {!r} will be stripped of its suffix '{}'".format(
101+
tag, tagdict["suffix"]
102+
)
101103
)
102104

103105
if VERSION_CLASS is not None:
@@ -122,7 +124,6 @@ def tags_to_versions(tags, config=None):
122124

123125

124126
class ScmVersion(object):
125-
126127
def __init__(
127128
self,
128129
tag_version,

testing/runtests_travis.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from subprocess import call
32

43
import os

testing/test_basic_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def test_dump_version(tmpdir):
9898

9999

100100
def test_parse_plain_fails(recwarn):
101-
102101
def parse(root):
103102
return "tricked you"
104103

testing/test_file_finder.py

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ def test_case(inwd):
4848
(inwd.cwd / "CamelFile").ensure(file=True)
4949
(inwd.cwd / "file2").ensure(file=True)
5050
inwd.add_and_commit()
51-
assert (
52-
set(find_files())
53-
== _sep({"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"})
51+
assert set(find_files()) == _sep(
52+
{"CamelFile", "file2", "file1", "adir/filea", "bdir/fileb"}
5453
)
5554

5655

@@ -73,9 +72,9 @@ def test_symlink_dir_source_not_in_scm(inwd):
7372
def test_symlink_file(inwd):
7473
(inwd.cwd / "adir" / "file1link").mksymlinkto("../file1")
7574
inwd.add_and_commit()
76-
assert (
77-
set(find_files("adir")) == _sep({"adir/filea", "adir/file1link"}) # -> ../file1
78-
)
75+
assert set(find_files("adir")) == _sep(
76+
{"adir/filea", "adir/file1link"}
77+
) # -> ../file1
7978

8079

8180
@pytest.mark.skipif(
@@ -130,8 +129,8 @@ def test_empty_subdir(inwd):
130129
subdir.ensure(dir=True)
131130
(subdir / "xfile").ensure(file=True)
132131
inwd.add_and_commit()
133-
assert (
134-
set(find_files("adir")) == _sep({"adir/filea", "adir/emptysubdir/subdir/xfile"})
132+
assert set(find_files("adir")) == _sep(
133+
{"adir/filea", "adir/emptysubdir/subdir/xfile"}
135134
)
136135

137136

@@ -142,18 +141,15 @@ def test_double_include_through_symlink(inwd):
142141
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
143142
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
144143
inwd.add_and_commit()
145-
assert (
146-
set(find_files())
147-
== _sep(
148-
{
149-
"file1",
150-
"adir/datalink", # -> ../data
151-
"adir/filealink", # -> filea
152-
"adir/filea",
153-
"bdir/fileb",
154-
"data/datafile",
155-
}
156-
)
144+
assert set(find_files()) == _sep(
145+
{
146+
"file1",
147+
"adir/datalink", # -> ../data
148+
"adir/filealink", # -> filea
149+
"adir/filea",
150+
"bdir/fileb",
151+
"data/datafile",
152+
}
157153
)
158154

159155

@@ -164,16 +160,13 @@ def test_symlink_not_in_scm_while_target_is(inwd):
164160
inwd.add_and_commit()
165161
(inwd.cwd / "adir" / "datalink").mksymlinkto("../data")
166162
(inwd.cwd / "adir" / "filealink").mksymlinkto("filea")
167-
assert (
168-
set(find_files())
169-
== _sep(
170-
{
171-
"file1",
172-
"adir/filea",
173-
# adir/datalink and adir/afilelink not included
174-
# because the symlink themselves are not in scm
175-
"bdir/fileb",
176-
"data/datafile",
177-
}
178-
)
163+
assert set(find_files()) == _sep(
164+
{
165+
"file1",
166+
"adir/filea",
167+
# adir/datalink and adir/afilelink not included
168+
# because the symlink themselves are not in scm
169+
"bdir/fileb",
170+
"data/datafile",
171+
}
179172
)

testing/test_functions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class MockTime(object):
19-
2019
def __format__(self, *k):
2120
return "time"
2221

0 commit comments

Comments
 (0)