Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit config and "apply" it - no trailing spaces, sorted imports #271

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions .codespellrc

This file was deleted.

21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand Down
18 changes: 9 additions & 9 deletions datalad_container/adapters/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion datalad_container/containers_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion datalad_container/containers_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""),
)

Expand Down
1 change: 0 additions & 1 deletion datalad_container/extractors/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion datalad_container/tests/test_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
assert_in("datalad", repo.get_remotes())
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Change log
**********
::

____ _ _ _
____ _ _ _
| _ \ __ _ | |_ __ _ | | __ _ __| |
| | | | / _` || __| / _` || | / _` | / _` |
| |_| || (_| || |_ | (_| || |___ | (_| || (_| |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/metadata-extraction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 0 additions & 3 deletions tools/ci/prep-travis-forssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ ssh -v datalad-test exit

# tmp: don't run the actual tests:
# exit 1