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

MAINT: Black, ruff, pre-commit #688

Closed
wants to merge 3 commits into from
Closed
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
141 changes: 50 additions & 91 deletions .circleci/config.yml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# black
7d03ec2f7bb5d12a747366cecd7e56b306a35d7f
7 changes: 4 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install flake8 and codespell
run: pip install flake8 flake8-pyproject codespell tomli
- run: make flake
- name: Install ruff and codespell
run: pip install ruff codespell tomli
- run: make ruff
- run: make codespell-error
- uses: psf/black@stable
check-doc:
name: Doc consistency
runs-on: ubuntu-latest
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
# Eventually we should use yamllint, too
files: ^(.*\.(py|yaml))$
exclude: ^(\.[^/]*cache/.*)$
repos:
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args:
- --safe
- --quiet
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.178
hooks:
- id: ruff
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
hooks:
- id: codespell
additional_dependencies:
- tomli
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ check:
trailing-spaces:
find . -name "*.py" | xargs perl -pi -e 's/[ \t]*$$//'

flake:
flake8
@echo "flake8 passed"
ruff:
ruff .
@echo "ruff passed"

codespell: # running manually; auto-fix spelling mistakes
@codespell --write-changes $(CODESPELL_DIRS)
Expand Down
8 changes: 4 additions & 4 deletions docs/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from mkdocs.config.defaults import MkDocsConfig

logger = logging.getLogger('mkdocs')
logger = logging.getLogger("mkdocs")

config_updated = False

Expand All @@ -19,6 +19,6 @@ def on_template_context(
global config_updated
if not config_updated:
config_updated = True
now = context['build_date_utc'].strftime('%Y/%m/%d')
config.copyright = f'{config.copyright}, last updated {now}'
logger.info(f'Updated copyright to {config.copyright}')
now = context["build_date_utc"].strftime("%Y/%m/%d")
config.copyright = f"{config.copyright}, last updated {now}"
logger.info(f"Updated copyright to {config.copyright}")
13 changes: 7 additions & 6 deletions docs/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
This file contains hooks to simplify changelog generation.
"""


def define_env(env):
'Hook function'
"Hook function"

@env.macro
def gh(pr_id):
url = f'https://github.com/mne-tools/mne-bids-pipeline/pull/{pr_id}'
markdown = f'[#{pr_id}]({url})'
return markdown
@env.macro
def gh(pr_id):
url = f"https://github.com/mne-tools/mne-bids-pipeline/pull/{pr_id}"
markdown = f"[#{pr_id}]({url})"
return markdown
4 changes: 2 additions & 2 deletions docs/source/doc-config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
bids_root = '/tmp'
ch_types = ['meg']
bids_root = "/tmp"
ch_types = ["meg"]
Loading