diff --git a/.appveyor.yml b/.appveyor.yml index 157bfc9e..ed70c53f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -71,11 +71,11 @@ environment: # Ubuntu core tests - ID: Ubu - + # The same but with the oldest supported Python. - ID: Ubu-3.8 PY: '3.8' - + # The same but removing busybox first - triggers different code paths in the tests - ID: Ubu-nobusybox BEFORE_CMD: docker rmi busybox:latest diff --git a/.codespellrc b/.codespellrc deleted file mode 100644 index 4cf7f14b..00000000 --- a/.codespellrc +++ /dev/null @@ -1,4 +0,0 @@ -[codespell] -skip = .venv,venvs,.git,build,*.egg-info,*.lock,.asv,.mypy_cache,.tox,fixtures,_version.py,*.pem -# ignore-words-list = -# exclude-file = diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..563a0b41 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +exclude: versioneer.py|\.all-contributorsrc|\.tributors +repos: +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files +- repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + hooks: + - id: codespell + additional_dependencies: + - tomli diff --git a/CHANGELOG.md b/CHANGELOG.md index 82fd7e5b..ead81868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -214,7 +214,7 @@ - Drop use of `Runner` (to be removed in datalad 0.14.0) in favor of `WitlessRunner` -# 1.1.0 (October 30, 2020) -- +# 1.1.0 (October 30, 2020) -- - Datalad version 0.13.0 or later is now required. @@ -229,7 +229,7 @@ to execute a container from underneath an uninstalled subdataset. -# 1.0.1 (June 23, 2020) -- +# 1.0.1 (June 23, 2020) -- - Prefer `datalad.core.local.run` to `datalad.interface.run`. The latter has been marked as obsolete since DataLad v0.12 (our minimum diff --git a/_datalad_buildsupport/setup.py b/_datalad_buildsupport/setup.py index 61a6e705..4b0f17b5 100644 --- a/_datalad_buildsupport/setup.py +++ b/_datalad_buildsupport/setup.py @@ -12,6 +12,7 @@ dirname, join as opj, ) + from setuptools import Command from setuptools.config import read_configuration from setuptools.errors import OptionError diff --git a/datalad_container/adapters/docker.py b/datalad_container/adapters/docker.py index 9e02bec8..774f53b9 100644 --- a/datalad_container/adapters/docker.py +++ b/datalad_container/adapters/docker.py @@ -57,24 +57,24 @@ def save(image, path): elif os.listdir(path): raise OSError("Directory {} is not empty".format(path)) def is_within_directory(directory, target): - + abs_directory = os.path.abspath(directory) abs_target = os.path.abspath(target) - + prefix = os.path.commonprefix([abs_directory, abs_target]) - + return prefix == abs_directory - + def safe_extract(tar, path=".", members=None, *, numeric_owner=False): - + for member in tar.getmembers(): member_path = os.path.join(path, member.name) if not is_within_directory(path, member_path): raise Exception("Attempted Path Traversal in Tar File") - - tar.extractall(path, members, numeric_owner=numeric_owner) - - + + tar.extractall(path, members, numeric_owner=numeric_owner) + + safe_extract(tar, path=path) lgr.info("Saved %s to %s", image, path) diff --git a/datalad_container/containers_add.py b/datalad_container/containers_add.py index bf40ad9a..ab182224 100644 --- a/datalad_container/containers_add.py +++ b/datalad_container/containers_add.py @@ -138,7 +138,7 @@ class ContainersAdd(Interface): the rest of the URL will be interpreted as the argument to 'docker pull', the image will be saved to a location specified by `name`, and the call format will be auto-configured - to run docker, unless overwritten. The auto-configured call to docker + to run docker, unless overwritten. The auto-configured call to docker run mounts the CWD to '/tmp' and sets the working directory to '/tmp'.""", metavar="URL", constraints=EnsureStr() | EnsureNone(), diff --git a/datalad_container/containers_run.py b/datalad_container/containers_run.py index 749e764f..c3db7929 100644 --- a/datalad_container/containers_run.py +++ b/datalad_container/containers_run.py @@ -39,7 +39,7 @@ container_name=Parameter( args=('-n', '--container-name',), metavar="NAME", - doc="""Specify the name of or a path to a known container to use + doc="""Specify the name of or a path to a known container to use for execution, in case multiple containers are configured."""), ) diff --git a/datalad_container/extractors/__init__.py b/datalad_container/extractors/__init__.py index 8b137891..e69de29b 100644 --- a/datalad_container/extractors/__init__.py +++ b/datalad_container/extractors/__init__.py @@ -1 +0,0 @@ - diff --git a/datalad_container/extractors/tests/test_metalad_container.py b/datalad_container/extractors/tests/test_metalad_container.py index 32f3cd4f..49d431fd 100644 --- a/datalad_container/extractors/tests/test_metalad_container.py +++ b/datalad_container/extractors/tests/test_metalad_container.py @@ -2,7 +2,6 @@ import pytest from datalad.support.external_versions import external_versions - # Early detection before we try to import meta_extract from datalad.tests.utils_pytest import SkipTest diff --git a/datalad_container/tests/test_add.py b/datalad_container/tests/test_add.py index 9adb9f92..6a002174 100644 --- a/datalad_container/tests/test_add.py +++ b/datalad_container/tests/test_add.py @@ -41,4 +41,4 @@ def test_ensure_datalad_remote_maybe_enable(path=None, *, autoenable): if not autoenable: assert_not_in("datalad", repo.get_remotes()) _ensure_datalad_remote(repo) - assert_in("datalad", repo.get_remotes()) \ No newline at end of file + assert_in("datalad", repo.get_remotes()) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index da2c8623..94046b5c 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -4,7 +4,7 @@ Change log ********** :: - ____ _ _ _ + ____ _ _ _ | _ \ __ _ | |_ __ _ | | __ _ __| | | | | | / _` || __| / _` || | / _` | / _` | | |_| || (_| || |_ | (_| || |___ | (_| || (_| | diff --git a/docs/source/metadata-extraction.rst b/docs/source/metadata-extraction.rst index 81f32072..e8e6afc3 100644 --- a/docs/source/metadata-extraction.rst +++ b/docs/source/metadata-extraction.rst @@ -19,7 +19,7 @@ For example: `datalad meta-extract -d . container_inspect images/bids/bids-pymvpa--1.0.2.sing | jq` -.. code-block:: +.. code-block:: { "type": "file", diff --git a/pyproject.toml b/pyproject.toml index fba51532..433c8f1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ multi_line_output = 3 combine_as_imports = true [tool.codespell] -skip = '.git,*.pdf,*.svg,venvs,versioneer.py,venvs' +skip = '.git,*.pdf,*.svg,venvs,versioneer.py,venvs,.venv,build,*.egg-info,*.lock,.asv,.mypy_cache,.tox,fixtures,_version.py,*.pem' # DNE - do not exist ignore-words-list = 'dne' diff --git a/setup.py b/setup.py index 93a7e8f3..5082ddcd 100755 --- a/setup.py +++ b/setup.py @@ -1,11 +1,9 @@ #!/usr/bin/env python from setuptools import setup -import versioneer -from _datalad_buildsupport.setup import ( - BuildManPage, -) +import versioneer +from _datalad_buildsupport.setup import BuildManPage cmdclass = versioneer.get_cmdclass() cmdclass.update(build_manpage=BuildManPage) diff --git a/tools/ci/prep-travis-forssh.sh b/tools/ci/prep-travis-forssh.sh index 554b6ffc..3030c7ad 100755 --- a/tools/ci/prep-travis-forssh.sh +++ b/tools/ci/prep-travis-forssh.sh @@ -15,6 +15,3 @@ ssh -v datalad-test exit # tmp: don't run the actual tests: # exit 1 - - -