Skip to content

Commit

Permalink
Merge pull request #13 from Remi-Gau/lint
Browse files Browse the repository at this point in the history
[STY] set up linting, formatting and apply
  • Loading branch information
Remi-Gau authored Feb 16, 2024
2 parents 1afe252 + 5dd9a98 commit 1a2b14b
Show file tree
Hide file tree
Showing 25 changed files with 1,567 additions and 1,250 deletions.
37 changes: 37 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[flake8]
; exclude =
; .git,
; __pycache__,
; build,
; dist,
; env,
; venv,
; doc/_build
--select = A,B,C,D,E,F,W,C90,FS
; docstring-convention = numpy
max-line-length = 100
# For PEP8 error codes see
# http://pep8.readthedocs.org/en/latest/intro.html#error-codes
; per-file-ignores =
; **/__init__.py: D104
ignore =
D100,
D101,
D102,
D103,
D105,
D107,
E501,
E711,
E712,
E713,
E721,
E741,
F821,
F841,
FS002,
FS001,
W503
# for compatibility with black
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
extend-ignore = E203
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Documentation
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
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 .
20 changes: 20 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Codespell

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

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run codespell
uses: codespell-project/actions-codespell@master
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 .
53 changes: 53 additions & 0 deletions .github/workflows/update_precommit_hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
name: Update precommit hooks


on:

# Uses the cron schedule for github actions
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
#
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
schedule:
- cron: 0 0 1 1,4,7,10 * # every 3 months

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
update_precommit_hooks:

# only run on upstream repo
if: github.repository_owner == 'neuropower'

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 pre-commit
run: pip install pre-commit
- name: Update pre-commit hooks
run: pre-commit autoupdate
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: pre-commit hooks auto-update
base: main
token: ${{ secrets.GITHUB_TOKEN }}
delete-branch: true
title: '[BOT] update pre-commit hooks'
body: done via this [GitHub Action](https://github.com/${{ github.repository_owner }}/neuropower/blob/master/.github/workflows/update_precommit_hooks.yml)
68 changes: 68 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
# See https://pre-commit.com for more information
# 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/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/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/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
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/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
hooks:
- id: pretty-format-toml
args: [--autofix, --indent, '4']

- repo: https://github.com/pyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [--config, .flake8, --verbose, neurodesign, examples]
additional_dependencies: [flake8-docstrings, flake8-use-fstring]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016
Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ The documentation of neurodesign is available at [ReadTheDocs](http://neurodesig
|---- source Folder with the source code of the python package
| |
| |---- media Folder contains the logo of neurodesign, which is used
in the reports.

in the reports.
Loading

0 comments on commit 1a2b14b

Please sign in to comment.