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

[STY] apply black, isort, flake8 #66

Merged
merged 12 commits into from
Feb 20, 2024
Merged
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
20 changes: 20 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[flake8]
--select = A,B,C,D,E,F,W,C90,FS
max-line-length = 93
# For PEP8 error codes see
# http://pep8.readthedocs.org/en/latest/intro.html#error-codes
ignore =
D101,
D102,
D103,
D104,
D105,
D107,
F403,
F405,
F841,
FS,
W503
# for compatibility with black
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
extend-ignore = E203
30 changes: 30 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: black

on:
push:
branches:
- master
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
black:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
allow-prereleases: false
- name: Install black
run: python -m pip install --upgrade pip black
- name: Run Black
run: black --check --diff --color .
26 changes: 13 additions & 13 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Codespell
uses: codespell-project/actions-codespell@v2
31 changes: 31 additions & 0 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: flake8

on:
push:
branches:
- master
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
flake8:
name: run flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'
allow-prereleases: false
- name: Install tox
run: python -m pip install --upgrade tox
- name: Run Flake8
run: tox run -e flake8
31 changes: 31 additions & 0 deletions .github/workflows/isort.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: isort

on:
push:
branches:
- master
pull_request:
branches:
- '*'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
isort:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
allow-prereleases: false
- name: Install isort
shell: bash {0}
run: python -m pip install --upgrade pip isort
- name: Run isort
run: isort --diff --check --settings-path pyproject.toml .
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test

on:
push:
branches: ['master']
branches: [master]
pull_request:
branches: ['*']

Expand All @@ -16,7 +16,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
fail-fast: false
steps:
Expand All @@ -30,4 +30,3 @@ jobs:
run: pip install tox
- name: Run tests
run: tox run -e tests

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ debug.log

test/data

.tox
.tox
96 changes: 48 additions & 48 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@
# See https://pre-commit.com/hooks.html for more hooks

repos:
# - repo: https://github.com/pre-commit/pre-commit-hooks
# rev: v4.5.0
# hooks:
# - id: check-ast
# - id: check-case-conflict
# - id: check-json
# - id: check-merge-conflict
# - id: check-toml
# - id: check-yaml
# - id: end-of-file-fixer
# - id: mixed-line-ending
# - id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace

# - repo: https://github.com/pycqa/isort
# rev: 5.13.2
# hooks:
# - id: isort
# args: [--profile, black, --settings-path, pyproject.toml]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: [--profile, black, --settings-path, pyproject.toml]

# - repo: https://github.com/asottile/pyupgrade
# rev: v3.15.0
# hooks:
# - id: pyupgrade
# args: [--py38-plus]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]

# - repo: https://github.com/psf/black-pre-commit-mirror
# rev: 24.1.1
# hooks:
# - id: black
# args: [--config, pyproject.toml]
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.1.1
hooks:
- id: black
args: [--config, pyproject.toml]

# - repo: https://github.com/adamchainz/blacken-docs
# rev: 1.16.0
# hooks:
# - id: blacken-docs
# additional_dependencies:
# - black==23.9.1
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies:
- black==23.9.1

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
Expand All @@ -48,26 +48,26 @@ repos:
args: [--toml, pyproject.toml]
additional_dependencies: [tomli]

# - repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
# rev: 0.2.3
# hooks:
# - id: yamlfmt
# args: [--mapping, '4', --sequence, '4', --offset, '0']
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
- id: yamlfmt
args: [--mapping, '4', --sequence, '4', --offset, '0']

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix, --indent, '4']

# - repo: https://github.com/pre-commit/pygrep-hooks
# rev: v1.10.0
# hooks:
# - id: rst-backticks
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: rst-backticks

# - repo: https://github.com/pyCQA/flake8
# rev: 7.0.0
# hooks:
# - id: flake8
# args: [--config, .flake8, --verbose, nilearn, examples, maint_tools]
# additional_dependencies: [flake8-docstrings, flake8-use-fstring, flake8-functions]
- repo: https://github.com/pyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--config, .flake8, --verbose, nidmresults, examples]
additional_dependencies: [flake8-docstrings, flake8-use-fstring]
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,3 @@ Examples are available in the [examples](examples) folder.

## Contributing
Thanks for your interest in contributing to nidmresults. All contributions are very welcome! If you experience difficulties using the library, please [open an issue](https://github.com/incf-nidash/nidmresults/issues/new) describing the problem. See the list of [current issues](https://github.com/incf-nidash/nidmresults/issues).


18 changes: 10 additions & 8 deletions examples/ex_read_nidm.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# Example: reading a NIDM pack available on NeuroVault
import os
"""Example: reading a NIDM pack available on NeuroVault."""

import json
import nidmresults as nidm
import os
import urllib.request

import nidmresults as nidm

# Download the NIDM pack locally
nidm_url = 'https://neurovault.org/collections/2210/fsl_default_130.nidm.zip'
nidm_url = "https://neurovault.org/collections/2210/fsl_default_130.nidm.zip"
nidmpack = "2210_fsl_default_130.nidm.zip"

if not os.path.isfile(nidmpack):
print(f'Downloading {nidmpack}')
print(f"Downloading {nidmpack}")
urllib.request.urlretrieve(nidm_url, nidmpack)

# Known issues with NIDM packs in collection 2210
to_replace = {
' \\ntask': '\\\\n task',
';\n nidm_coordinateVectorInVoxels: "null"^^xsd:string .':
'.'}
" \\ntask": "\\\\n task",
';\n nidm_coordinateVectorInVoxels: "null"^^xsd:string .': ".",
}

# Read the NIDM pack
nres = nidm.load(nidmpack, to_replace=to_replace)
Expand Down
12 changes: 7 additions & 5 deletions nidmresults/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os

from nidmresults._version import __version__ # noqa
from nidmresults.load import load

from nidmresults._version import __version__

latest_owlfile = os.path.join(
os.path.dirname(os.path.dirname(__file__)), 'nidmresults', 'owl',
"nidm-results_130.owl")
os.path.dirname(os.path.dirname(__file__)),
"nidmresults",
"owl",
"nidm-results_130.owl",
)

__all__ = ["load"]
__all__ = ["load"]
8 changes: 5 additions & 3 deletions nidmresults/cli/nidm_mkda_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
@copyright: University of Warwick 2013-2014
"""

from __future__ import absolute_import, division, print_function

import argparse
import os
Expand All @@ -29,7 +28,7 @@ def main(argv=sys.argv):
nargs="+",
)
parser.add_argument(
"--version", action="version", version="{version}".format(version=__version__)
"--version", action="version", version=f"{__version__}"
)

args = parser.parse_args(argv[1:])
Expand All @@ -56,7 +55,10 @@ def main(argv=sys.argv):

nidmgraph = Graph(nidm_zip=nidmpack)
con_ids = nidmgraph.serialize(
outfile, "mkda", overwrite=overwrite, last_used_con_id=max(con_ids.values())
outfile,
"mkda",
overwrite=overwrite,
last_used_con_id=max(con_ids.values()),
)


Expand Down
Loading
Loading