diff options
author | Ronny Pfannschmidt <opensource@ronnypfannschmidt.de> | 2019-11-25 22:04:43 +0100 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2019-11-25 16:04:43 -0500 |
commit | e9cbdb231a59f06a508d86f2b5b14719ee4bbc34 (patch) | |
tree | 0b1cdf06b85982a8b0276e33ab86e8148ef600b3 | |
parent | 5a201f5da3c97856b53a16a954e4db9f89ad31f9 (diff) | |
download | setuptools-scm-e9cbdb231a59f06a508d86f2b5b14719ee4bbc34.tar.gz |
update pre-commit setup to modern practices and ensure flake8 is in line as well (#369)
-rw-r--r-- | .pre-commit-config.yaml | 7 | ||||
-rw-r--r-- | appveyor.yml | 1 | ||||
-rw-r--r-- | src/setuptools_scm/file_finder.py | 7 | ||||
-rw-r--r-- | src/setuptools_scm/git.py | 2 | ||||
-rw-r--r-- | src/setuptools_scm/hg.py | 13 | ||||
-rw-r--r-- | src/setuptools_scm/version.py | 13 | ||||
-rw-r--r-- | testing/runtests_travis.py | 1 | ||||
-rw-r--r-- | testing/test_basic_api.py | 1 | ||||
-rw-r--r-- | testing/test_file_finder.py | 57 | ||||
-rw-r--r-- | testing/test_functions.py | 1 | ||||
-rw-r--r-- | testing/test_git.py | 4 | ||||
-rw-r--r-- | testing/test_mercurial.py | 4 | ||||
-rw-r--r-- | tox.ini | 1 |
13 files changed, 52 insertions, 60 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a80f778..eae2e3c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,12 @@ 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 @@ -15,6 +14,6 @@ repos: - id: debug-statements - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v1.2.0 + rev: v1.25.1 hooks: - id: pyupgrade diff --git a/appveyor.yml b/appveyor.yml index a73a34a..d676e54 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,4 +41,3 @@ after_test: artifacts:
# Archive the generated wheel package in the ci.appveyor.com build report.
- path: dist\*
-
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, diff --git a/testing/runtests_travis.py b/testing/runtests_travis.py index d2d5f9e..752d660 100644 --- a/testing/runtests_travis.py +++ b/testing/runtests_travis.py @@ -1,4 +1,3 @@ - from subprocess import call import os diff --git a/testing/test_basic_api.py b/testing/test_basic_api.py index f342e23..9227b2e 100644 --- a/testing/test_basic_api.py +++ b/testing/test_basic_api.py @@ -98,7 +98,6 @@ def test_dump_version(tmpdir): def test_parse_plain_fails(recwarn): - def parse(root): return "tricked you" diff --git a/testing/test_file_finder.py b/testing/test_file_finder.py index 0bc9a7f..825f1c3 100644 --- a/testing/test_file_finder.py +++ b/testing/test_file_finder.py @@ -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"} ) @@ -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( @@ -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"} ) @@ -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", + } ) @@ -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", + } ) diff --git a/testing/test_functions.py b/testing/test_functions.py index c3d78b6..9249a80 100644 --- a/testing/test_functions.py +++ b/testing/test_functions.py @@ -16,7 +16,6 @@ PY3 = sys.version_info > (2,) class MockTime(object): - def __format__(self, *k): return "time" diff --git a/testing/test_git.py b/testing/test_git.py index 9307850..0e025f1 100644 --- a/testing/test_git.py +++ b/testing/test_git.py @@ -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") diff --git a/testing/test_mercurial.py b/testing/test_mercurial.py index e25bfe1..40f9409 100644 --- a/testing/test_mercurial.py +++ b/testing/test_mercurial.py @@ -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"}, @@ -9,6 +9,7 @@ markers= [flake8] max-complexity = 10 max-line-length = 88 +ignore=E203,W503 exclude= .git, .tox, |