From e985d08e87dac2fc7564897f7365886dbf5c2bb5 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 5 Feb 2025 14:41:46 -0500 Subject: [PATCH 1/5] Add precommit configuration as in datalad ATM Just removed unnecessary exclude for codespell and added tomli as needed dependency since we define config in pyproject.toml --- .pre-commit-config.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1e1561c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,22 @@ +# 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.0.0 + hooks: + - id: codespell + additional_dependencies: + - tomli + From 4fd7f4f17906c91f5a1a15330a355b6307b95974 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 5 Feb 2025 14:51:06 -0500 Subject: [PATCH 2/5] progress codespell in pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e1561c..bd008dd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: check-yaml - id: check-added-large-files - repo: https://github.com/codespell-project/codespell - rev: v2.0.0 + rev: v2.4.1 hooks: - id: codespell additional_dependencies: From 4d6eabfe98c69893bd4aa78a5d9a3a79315128a0 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 5 Feb 2025 14:52:56 -0500 Subject: [PATCH 3/5] rm duplicate .codespellrc and move some of its skips into pyproject.toml --- .codespellrc | 4 ---- pyproject.toml | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc deleted file mode 100644 index 4cf7f14..0000000 --- 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/pyproject.toml b/pyproject.toml index e6e46ab..0196f3f 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' From a2b6768ff80e3a9a4412ef747d87c3a5cc43a017 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Wed, 5 Feb 2025 14:54:05 -0500 Subject: [PATCH 4/5] [DATALAD RUNCMD] Run pre-commit to harmonize code throughout === Do not change lines below === { "chain": [], "cmd": "pre-commit run --all || pre-commit run --all", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- .appveyor.yml | 4 ++-- .pre-commit-config.yaml | 1 - CHANGELOG.md | 4 ++-- datalad_container/adapters/docker.py | 18 +++++++++--------- datalad_container/containers_add.py | 2 +- datalad_container/containers_run.py | 2 +- datalad_container/extractors/__init__.py | 1 - .../extractors/tests/test_metalad_container.py | 1 - datalad_container/tests/test_add.py | 2 +- docs/source/changelog.rst | 2 +- docs/source/metadata-extraction.rst | 2 +- setup.py | 6 ++---- tools/ci/prep-travis-forssh.sh | 3 --- 13 files changed, 20 insertions(+), 28 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 157bfc9..ed70c53 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/.pre-commit-config.yaml b/.pre-commit-config.yaml index bd008dd..563a0b4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,4 +19,3 @@ repos: - id: codespell additional_dependencies: - tomli - diff --git a/CHANGELOG.md b/CHANGELOG.md index f6a1ebb..f2ded3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -207,7 +207,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. @@ -222,7 +222,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_container/adapters/docker.py b/datalad_container/adapters/docker.py index 9e02bec..774f53b 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 bf40ad9..ab18222 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 749e764..c3db792 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 8b13789..e69de29 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 32f3cd4..49d431f 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 9adb9f9..6a00217 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 da2c862..94046b5 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 81f3207..e8e6afc 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/setup.py b/setup.py index 93a7e8f..5082ddc 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 554b6ff..3030c7a 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 - - - From 971f127e4c9c9b185856cdc80ddfb4d4314b4c72 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 23 Sep 2025 16:26:33 -0400 Subject: [PATCH 5/5] [DATALAD RUNCMD] Run pre-commit to harmonize code throughout === Do not change lines below === { "chain": [ "a2b6768ff80e3a9a4412ef747d87c3a5cc43a017" ], "cmd": "pre-commit run --all || pre-commit run --all", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ --- _datalad_buildsupport/setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_datalad_buildsupport/setup.py b/_datalad_buildsupport/setup.py index 61a6e70..4b0f17b 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