From d8c63ebf32c50f4f4519a93aa04f99ebd14cd42b Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 08:53:47 +0100 Subject: [PATCH 01/51] Add pre-commit --- .pre-commit-config.yaml | 16 ++++++++++++++++ 1 file changed, 16 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 00000000000..0d46d304fe0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +default_language_version: + python: python3.11 + +repos: +- repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.254 + hooks: + - id: ruff +- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell From 7c6f66cbedee27dd58e32e62e2700cd4ecb0dfb9 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 09:01:31 +0100 Subject: [PATCH 02/51] Add GitHub workflow --- .github/workflows/precommit.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/workflows/precommit.yml diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 00000000000..4638064b646 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,14 @@ +name: Pre-commit + +on: [push, pull_request] + +jobs: + style: + name: Pre-commit + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.11' + - uses: pre-commit/action@v3.0.0 From 91b04fde4f1619e757c4474fa127f543f430312f Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 09:11:50 +0100 Subject: [PATCH 03/51] Exclude __init__.py (Ruff) --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..bf1d326b04c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.ruff] +exclude = ["__init__.py"] From 74f05ef4eeb9378ff2aa05b94ee86414d01b685c Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 09:14:01 +0100 Subject: [PATCH 04/51] Add per-file ignore --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index bf1d326b04c..a7bef3b73a4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,5 @@ [tool.ruff] exclude = ["__init__.py"] + +[tool.ruff.per-file-ignores] +"tutorials/time-freq/10_spectrum_class.py" = ["E501"] From 33e348ad6147c895ab0314126fd8501690faea6b Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 09:27:39 +0100 Subject: [PATCH 05/51] Quiet Black --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0d46d304fe0..cfd94509ed7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,7 @@ repos: rev: 23.1.0 hooks: - id: black + args: [--quiet] - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.254 hooks: From 8d73a6e75a33863c23a99b10ce1d66b9f45b2e9c Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 10:23:22 +0100 Subject: [PATCH 06/51] Add Codespell config --- .pre-commit-config.yaml | 1 + pyproject.toml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cfd94509ed7..f53567dd432 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,3 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell + args: [mne/ doc/ tutorials/ examples/] diff --git a/pyproject.toml b/pyproject.toml index a7bef3b73a4..b7ea6e9428a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,8 @@ +[tool.codespell] +ignore-words = ignore_words.txt +uri-ignore-words-list = bu +skip = 'doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr' + [tool.ruff] exclude = ["__init__.py"] From 390f87203bce1ce891207f30744da21f31759065 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 10:28:33 +0100 Subject: [PATCH 07/51] Fix TOML --- pyproject.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b7ea6e9428a..50bac407dd1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.codespell] -ignore-words = ignore_words.txt -uri-ignore-words-list = bu -skip = 'doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr' +ignore-words = "ignore_words.txt" +uri-ignore-words-list = "bu" +skip = "doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr" [tool.ruff] exclude = ["__init__.py"] From 1220e04cadf5063d07c7634b2ceb7c744400e2c5 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 10:36:02 +0100 Subject: [PATCH 08/51] Include instead of exclude files --- .pre-commit-config.yaml | 2 +- pyproject.toml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f53567dd432..aaa37fe0748 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: [mne/ doc/ tutorials/ examples/] + args: [mne/ doc/ tutorials/ examples/ *.py *.rst *.bib *.inc] diff --git a/pyproject.toml b/pyproject.toml index 50bac407dd1..5efd7ad0bfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [tool.codespell] ignore-words = "ignore_words.txt" uri-ignore-words-list = "bu" -skip = "doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr" [tool.ruff] exclude = ["__init__.py"] From e638c9de1f36e098df0f5273ea2f8d94c8d3a34d Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 10:43:27 +0100 Subject: [PATCH 09/51] Try args --- .pre-commit-config.yaml | 2 +- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index aaa37fe0748..fa5827c14a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: [mne/ doc/ tutorials/ examples/ *.py *.rst *.bib *.inc] + args: [mne/,doc/,tutorials/,examples/,*.py,*.rst,*.bib,*.inc] diff --git a/pyproject.toml b/pyproject.toml index 5efd7ad0bfb..77bce780767 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,7 @@ [tool.codespell] ignore-words = "ignore_words.txt" uri-ignore-words-list = "bu" +builtin = "clear,rare,informal,names,usage" [tool.ruff] exclude = ["__init__.py"] From 35a1139cb8497ccec1cf3e977fe95e6dbda69b39 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 11:08:49 +0100 Subject: [PATCH 10/51] Quote args --- .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 fa5827c14a4..1efb262f908 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: [mne/,doc/,tutorials/,examples/,*.py,*.rst,*.bib,*.inc] + args: ["mne/", "doc/", "tutorials/", "examples/", "*.py", "*.rst", "*.bib"] From df77fa68e85514c71d7b25e2fd10603aca3fce1b Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 11:13:27 +0100 Subject: [PATCH 11/51] Just one string --- .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 1efb262f908..b0ffdfbe8be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ["mne/", "doc/", "tutorials/", "examples/", "*.py", "*.rst", "*.bib"] + args: ["mne/ doc/ tutorials/ examples/ *.py *.rst *.bib"] From 7111930e5cc26c8efc8d09722d7a7459dedcfe81 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 11:18:20 +0100 Subject: [PATCH 12/51] Single quotes --- .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 b0ffdfbe8be..3f7fb700c68 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,4 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ["mne/ doc/ tutorials/ examples/ *.py *.rst *.bib"] + args: ['mne/', 'doc/', 'tutorials/', 'examples/', '*.py', '*.rst', '*.bib'] From 1f056aad6348f95633ba46f9a3d3d763d2a5ee55 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 11:28:55 +0100 Subject: [PATCH 13/51] More Ruff excludes --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 77bce780767..04fc19dbbb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ uri-ignore-words-list = "bu" builtin = "clear,rare,informal,names,usage" [tool.ruff] -exclude = ["__init__.py"] +exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] From 3e3a373051903fea8cd3ee7a670cdbe60ab4038c Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 11:31:12 +0100 Subject: [PATCH 14/51] Disable Black and Ruff for now --- .pre-commit-config.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3f7fb700c68..6c272aec89c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,15 +2,15 @@ default_language_version: python: python3.11 repos: -- repo: https://github.com/psf/black - rev: 23.1.0 - hooks: - - id: black - args: [--quiet] -- repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.254 - hooks: - - id: ruff +# - repo: https://github.com/psf/black +# rev: 23.1.0 +# hooks: +# - id: black +# args: [--quiet] +# - repo: https://github.com/charliermarsh/ruff-pre-commit +# rev: v0.0.254 +# hooks: +# - id: ruff - repo: https://github.com/codespell-project/codespell rev: v2.2.2 hooks: From e57737049455d26a772fedbf0b2c2b8e062bc46b Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 17:24:05 +0100 Subject: [PATCH 15/51] Filter files and types --- .pre-commit-config.yaml | 3 ++- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c272aec89c..d8e11f7abd2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,4 +15,5 @@ repos: rev: v2.2.2 hooks: - id: codespell - args: ['mne/', 'doc/', 'tutorials/', 'examples/', '*.py', '*.rst', '*.bib'] + files: ^mne/|^doc/|^examples/|^tutorials/ + types_or: [python, bib, rst] diff --git a/pyproject.toml b/pyproject.toml index 04fc19dbbb6..415ebdf26bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ ignore-words = "ignore_words.txt" uri-ignore-words-list = "bu" builtin = "clear,rare,informal,names,usage" +skip = "doc/references.bib" [tool.ruff] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] From 45d50ca83af3f4e189b444fbf20ee3837b904527 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 17:30:09 +0100 Subject: [PATCH 16/51] Add tomli dependency for codespell --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d8e11f7abd2..3d3abfa32be 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,5 +15,7 @@ repos: rev: v2.2.2 hooks: - id: codespell + additional_dependencies: + - tomli files: ^mne/|^doc/|^examples/|^tutorials/ types_or: [python, bib, rst] From 14b692a30403e96c9bd1cf56c0fb6ced64bd6aac Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 17:33:47 +0100 Subject: [PATCH 17/51] Enable Ruff --- .pre-commit-config.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3d3abfa32be..371c99ec894 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,10 +7,10 @@ repos: # hooks: # - id: black # args: [--quiet] -# - repo: https://github.com/charliermarsh/ruff-pre-commit -# rev: v0.0.254 -# hooks: -# - id: ruff +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.254 + hooks: + - id: ruff - repo: https://github.com/codespell-project/codespell rev: v2.2.2 hooks: From 5f5a28eb2c39811421f03d337fa6fd72007c6ab1 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 17:41:02 +0100 Subject: [PATCH 18/51] Fix Ruff errors --- doc/conf.py | 3 +-- mne/beamformer/tests/test_resolution_matrix.py | 4 ++-- mne/chpi.py | 4 ++-- mne/io/base.py | 5 ++++- mne/viz/evoked.py | 2 +- mne/viz/topo.py | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index c826d19228d..a537b0e85e6 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -204,7 +204,6 @@ # MNE 'Label': 'mne.Label', 'Forward': 'mne.Forward', 'Evoked': 'mne.Evoked', 'Info': 'mne.Info', 'SourceSpaces': 'mne.SourceSpaces', - 'SourceMorph': 'mne.SourceMorph', 'Epochs': 'mne.Epochs', 'Layout': 'mne.channels.Layout', 'EvokedArray': 'mne.EvokedArray', 'BiHemiLabel': 'mne.BiHemiLabel', 'AverageTFR': 'mne.time_frequency.AverageTFR', @@ -224,7 +223,7 @@ 'CrossSpectralDensity': 'mne.time_frequency.CrossSpectralDensity', 'SourceMorph': 'mne.SourceMorph', 'Xdawn': 'mne.preprocessing.Xdawn', - 'Report': 'mne.Report', 'Forward': 'mne.Forward', + 'Report': 'mne.Report', 'TimeDelayingRidge': 'mne.decoding.TimeDelayingRidge', 'Vectorizer': 'mne.decoding.Vectorizer', 'UnsupervisedSpatialFilter': 'mne.decoding.UnsupervisedSpatialFilter', diff --git a/mne/beamformer/tests/test_resolution_matrix.py b/mne/beamformer/tests/test_resolution_matrix.py index 09ef7fe1118..e70ede5f1fa 100755 --- a/mne/beamformer/tests/test_resolution_matrix.py +++ b/mne/beamformer/tests/test_resolution_matrix.py @@ -86,9 +86,9 @@ def test_resolution_matrix_lcmv(): # Some rows are off by about 0.1 - not yet clear why corr = [] - for (f, l) in zip(resmat_fwd, resmat_lcmv): + for (f, lf) in zip(resmat_fwd, resmat_lcmv): - corr.append(np.corrcoef(f, l)[0, 1]) + corr.append(np.corrcoef(f, lf)[0, 1]) # all row correlations should at least be above ~0.8 assert_allclose(corr, 1., atol=0.2) diff --git a/mne/chpi.py b/mne/chpi.py index 096c4e6f2bc..12d40f4cfa3 100644 --- a/mne/chpi.py +++ b/mne/chpi.py @@ -1213,8 +1213,8 @@ def compute_chpi_locs(info, chpi_amplitudes, t_step_max=1., too_close='raise', # check if data has sufficiently changed if last['sin_fit'] is not None: # first iteration corrs = np.array( - [np.corrcoef(s, l)[0, 1] - for s, l in zip(sin_fit, last['sin_fit'])]) + [np.corrcoef(s, lst)[0, 1] + for s, lst in zip(sin_fit, last['sin_fit'])]) corrs *= corrs # check to see if we need to continue if fit_time - last['coil_fit_time'] <= t_step_max - 1e-7 and \ diff --git a/mne/io/base.py b/mne/io/base.py index 55ebc33b588..91e4193e137 100644 --- a/mne/io/base.py +++ b/mne/io/base.py @@ -576,7 +576,10 @@ def time_as_index(self, times, use_rounding=False, origin=None): @property def _raw_lengths(self): - return [l - f + 1 for f, l in zip(self._first_samps, self._last_samps)] + return [ + last - first + 1 + for first, last in zip(self._first_samps, self._last_samps) + ] @property def annotations(self): # noqa: D401 diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py index aff29fdd046..8c9cc4564b4 100644 --- a/mne/viz/evoked.py +++ b/mne/viz/evoked.py @@ -911,7 +911,7 @@ def plot_evoked_topo(evoked, layout=None, layout_scale=0.945, fig : instance of matplotlib.figure.Figure Images of evoked responses at sensor locations. """ - if not type(evoked) in (tuple, list): + if type(evoked) not in (tuple, list): evoked = [evoked] background_color = _to_rgb(background_color, name='background_color') diff --git a/mne/viz/topo.py b/mne/viz/topo.py index 962fa283bcb..612cbaf86f8 100644 --- a/mne/viz/topo.py +++ b/mne/viz/topo.py @@ -658,7 +658,7 @@ def _plot_evoked_topo(evoked, layout=None, layout_scale=0.945, import matplotlib.pyplot as plt from ..cov import whiten_evoked - if not type(evoked) in (tuple, list): + if type(evoked) not in (tuple, list): evoked = [evoked] noise_cov = _check_cov(noise_cov, evoked[0].info) From b5789ded19b36cfb2c0e8a2a3071066df9b10be8 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 17:57:06 +0100 Subject: [PATCH 19/51] Exclude *.yaml --- MANIFEST.in | 1 + 1 file changed, 1 insertion(+) diff --git a/MANIFEST.in b/MANIFEST.in index 6c1aa9ff47f..e00b86e3e79 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -57,6 +57,7 @@ exclude tools exclude Makefile exclude .coveragerc exclude *.yml +exclude *.yaml exclude ignore_words.txt exclude .mailmap exclude codemeta.json From 4cf0920d30efb5b3746c56c852a8cfde3c485910 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 18:00:57 +0100 Subject: [PATCH 20/51] Try without tomli package again --- .pre-commit-config.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 371c99ec894..4a1f44208d7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,5 @@ repos: rev: v2.2.2 hooks: - id: codespell - additional_dependencies: - - tomli files: ^mne/|^doc/|^examples/|^tutorials/ types_or: [python, bib, rst] From 19f7e4f3aa4886d377ec3c1d29cd1fff7d537cc8 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 18:07:59 +0100 Subject: [PATCH 21/51] Even 3.11 requires tomli --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4a1f44208d7..371c99ec894 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,5 +15,7 @@ repos: rev: v2.2.2 hooks: - id: codespell + additional_dependencies: + - tomli files: ^mne/|^doc/|^examples/|^tutorials/ types_or: [python, bib, rst] From 48209ee6e6da7f96c0b22446cfe2dc1d354cf07d Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 22:06:35 +0100 Subject: [PATCH 22/51] Try new Codespell without tomli --- .pre-commit-config.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 371c99ec894..9fa57e489b2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,10 +12,8 @@ repos: hooks: - id: ruff - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.3 hooks: - id: codespell - additional_dependencies: - - tomli files: ^mne/|^doc/|^examples/|^tutorials/ types_or: [python, bib, rst] From adcdebfdae42a8b3164fc7715289f8cb935504a1 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 22:17:43 +0100 Subject: [PATCH 23/51] Add .inc files for codespell --- .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 9fa57e489b2..0f41eb4fedc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,4 +16,4 @@ repos: hooks: - id: codespell files: ^mne/|^doc/|^examples/|^tutorials/ - types_or: [python, bib, rst] + types_or: [python, bib, rst, inc] From fc44493c58f53e6555bf13f733db6c8f162d00e4 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 22:25:05 +0100 Subject: [PATCH 24/51] Remove Codespell from old workflow --- .github/workflows/codespell_and_flake.yml | 45 ----------------------- .github/workflows/flake.yml | 33 +++++++++++++++++ 2 files changed, 33 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/codespell_and_flake.yml create mode 100644 .github/workflows/flake.yml diff --git a/.github/workflows/codespell_and_flake.yml b/.github/workflows/codespell_and_flake.yml deleted file mode 100644 index e191caa25d1..00000000000 --- a/.github/workflows/codespell_and_flake.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: 'codespell_and_flake' -# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency -# https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent -# workflow name, PR number (empty on push), push ref (empty on PR) -concurrency: - group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} - cancel-in-progress: true -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - style: - name: 'codespell and flake' - runs-on: ubuntu-20.04 - env: - CODESPELL_DIRS: 'mne/ doc/ tutorials/ examples/' - CODESPELL_SKIPS: 'doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr' - - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.9' - architecture: 'x64' - - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install flake8 - name: 'Install dependencies' - - uses: rbialon/flake8-annotations@v1 - name: 'Setup flake8 annotations' - - run: make flake - name: 'Run flake8' - - uses: codespell-project/actions-codespell@v1.0 - with: - path: ${{ env.CODESPELL_DIRS }} - skip: ${{ env.CODESPELL_SKIPS }} - builtin: 'clear,rare,informal,names' - ignore_words_file: 'ignore_words.txt' - uri_ignore_words_list: 'bu' - name: 'Run codespell' diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml new file mode 100644 index 00000000000..df085952b5a --- /dev/null +++ b/.github/workflows/flake.yml @@ -0,0 +1,33 @@ +name: 'flake' +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency +# https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent +# workflow name, PR number (empty on push), push ref (empty on PR) +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} + cancel-in-progress: true +on: + push: + branches: + - '*' + pull_request: + branches: + - '*' + +jobs: + style: + name: 'flake' + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + architecture: 'x64' + - run: | + python -m pip install --upgrade pip setuptools wheel + python -m pip install flake8 + name: 'Install dependencies' + - uses: rbialon/flake8-annotations@v1 + name: 'Setup flake8 annotations' + - run: make flake + name: 'Run flake8' From 427edb8cd45d4b07f5a47ecfeb83642a2cd0810e Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 22:40:15 +0100 Subject: [PATCH 25/51] Remove flake and codespell from Azure --- azure-pipelines.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 74332387a67..23927beb16c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -54,12 +54,6 @@ stages: python -m pip install --progress-bar off --upgrade pip setuptools wheel python -m pip install --progress-bar off -r requirements_base.txt -r requirements_hdf5.txt -r requirements_testing.txt displayName: Install dependencies - - bash: | - make flake - displayName: make flake - - bash: | - make codespell-error - displayName: make codespell - bash: | make pydocstyle displayName: make pydocstyle From aeb6ecf3386904d0f0c76383ffa3a1c0074b5396 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Wed, 8 Mar 2023 22:45:14 +0100 Subject: [PATCH 26/51] Ignore .ruff_cache/ --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 40c64c7bb65..c73ee6d5257 100644 --- a/.gitignore +++ b/.gitignore @@ -92,5 +92,5 @@ cover venv/ *.json .hypothesis/ - +.ruff_cache/ .ipynb_checkpoints/ From a614a20e480ba2b9c006247ae288a824b01efdd9 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 07:24:16 +0100 Subject: [PATCH 27/51] Enable W rules in Ruff --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 415ebdf26bb..288e9c14081 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ builtin = "clear,rare,informal,names,usage" skip = "doc/references.bib" [tool.ruff] +select = ["E", "F", "W"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From 903c94d97359c7efe7553cb182adedcdc0537a3b Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 07:32:51 +0100 Subject: [PATCH 28/51] Enable pydocstyle in Ruff --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 288e9c14081..0abe9b129b9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ builtin = "clear,rare,informal,names,usage" skip = "doc/references.bib" [tool.ruff] -select = ["E", "F", "W"] +select = ["E", "F", "W", "D"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From db5bdc4264b0dff336b9592a6014fc9a09ce94e8 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 07:44:29 +0100 Subject: [PATCH 29/51] Ignore several pydocstyle rules --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 0abe9b129b9..c670cc4f38f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,6 +6,7 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] +ignore = ["D100", "D104", "D107", "D413"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From 92fd63141da3cfcd9373b45e4074fde5caa52116 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:19:57 +0100 Subject: [PATCH 30/51] Check for numpydoc style --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c670cc4f38f..6790c6ff3eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] -ignore = ["D100", "D104", "D107", "D413"] +ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From fd3b8ba6bb38a187a61f9278f12cfe6f806d3670 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:22:59 +0100 Subject: [PATCH 31/51] Ignore more D rules --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6790c6ff3eb..e83ab2a6c4d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,8 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] -ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"] +ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"] # numpydoc style +ignore-extend = ["D100", "D104", "D107", "D413"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From 8b91fa37ccf47361b9c19797dcef4153ce72f482 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:24:22 +0100 Subject: [PATCH 32/51] Fix key --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e83ab2a6c4d..10ee16190f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"] # numpydoc style -ignore-extend = ["D100", "D104", "D107", "D413"] +extend-ignore = ["D100", "D104", "D107", "D413"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.per-file-ignores] From 83895fea7e286dccbf314ab40eb5c10fc2896ff3 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:45:38 +0100 Subject: [PATCH 33/51] Pydocstyle specific excludes --- pyproject.toml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 10ee16190f2..19029bbcc15 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,9 +6,13 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] -ignore = ["D107", "D203", "D212", "D213", "D402", "D413", "D415", "D416", "D417"] # numpydoc style -extend-ignore = ["D100", "D104", "D107", "D413"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] +[tool.ruff.pydocstyle] +convention = "numpydoc" +extend-ignore = ["D100", "D104", "D107", "D413"] +ignore-decorators = ^(copy_.*_doc_to_|on_trait_change|cached_property|deprecated|property|.*setter).* +extend-exclude = ^(?!\.|doc|tutorials|examples|logo|icons).*$ + [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] From 18818f6ca8de308a1690a4e1c0eba3b1cc6c2fca Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:49:47 +0100 Subject: [PATCH 34/51] Fix ignores --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 19029bbcc15..3096d7295bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,8 +11,8 @@ exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.pydocstyle] convention = "numpydoc" extend-ignore = ["D100", "D104", "D107", "D413"] -ignore-decorators = ^(copy_.*_doc_to_|on_trait_change|cached_property|deprecated|property|.*setter).* -extend-exclude = ^(?!\.|doc|tutorials|examples|logo|icons).*$ +ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] +extend-exclude = ["doc", "tutorials", "examples", "logo", "icons"] [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] From d2502d690f16a4407fb042548672dc8448fc9ad1 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:51:04 +0100 Subject: [PATCH 35/51] Fix convention --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3096d7295bf..73ac4e8de1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ select = ["E", "F", "W", "D"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.pydocstyle] -convention = "numpydoc" +convention = "numpy" extend-ignore = ["D100", "D104", "D107", "D413"] ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] extend-exclude = ["doc", "tutorials", "examples", "logo", "icons"] From 8e11f3e069aae482426530838e25c4a4fe2721ca Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:52:37 +0100 Subject: [PATCH 36/51] Fix ignore --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 73ac4e8de1f..ca83504255d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] [tool.ruff.pydocstyle] convention = "numpy" -extend-ignore = ["D100", "D104", "D107", "D413"] +ignore = ["D100", "D104", "D107", "D413"] ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] extend-exclude = ["doc", "tutorials", "examples", "logo", "icons"] From 9af3e9e6199adba527eac0bcead6dad8d73634d4 Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:53:41 +0100 Subject: [PATCH 37/51] Move ignore --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ca83504255d..d20edb766fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,10 +7,10 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] +ignore = ["D100", "D104", "D107", "D413"] [tool.ruff.pydocstyle] convention = "numpy" -ignore = ["D100", "D104", "D107", "D413"] ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] extend-exclude = ["doc", "tutorials", "examples", "logo", "icons"] From befaf1067d9f81bf8dd8a2084254f98ca84a53fb Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Thu, 9 Mar 2023 08:59:10 +0100 Subject: [PATCH 38/51] Remove excludes for pydocstyle --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d20edb766fc..6989b098c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,6 @@ ignore = ["D100", "D104", "D107", "D413"] [tool.ruff.pydocstyle] convention = "numpy" ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] -extend-exclude = ["doc", "tutorials", "examples", "logo", "icons"] [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] From fbb4da8644d4f20eb6bec93b85a647236a6b8765 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 20 Apr 2023 18:10:11 -0400 Subject: [PATCH 39/51] FIX: Closer --- .pre-commit-config.yaml | 9 ++++++++- pyproject.toml | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f41eb4fedc..34fcd8b01fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,9 +8,16 @@ repos: # - id: black # args: [--quiet] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.254 + rev: v0.0.262 hooks: - id: ruff + files: ^mne/ +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.0.262 + hooks: + - id: ruff + args: ["--ignore=D103,D400"] + files: ^tutorials/|^examples/ - repo: https://github.com/codespell-project/codespell rev: v2.2.3 hooks: diff --git a/pyproject.toml b/pyproject.toml index 6989b098c8f..cc30610c6fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,13 @@ ignore = ["D100", "D104", "D107", "D413"] [tool.ruff.pydocstyle] convention = "numpy" -ignore-decorators = ["copy_.*_doc_to_.*", "on_trait_change.*", "cached_property.*", "deprecated.*", "property.*", ".*setter.*"] +ignore-decorators = [ + "property", + "setter", + "mne.utils.copy_function_doc_to_method_doc", + "mne.utils.copy_doc", + "mne.utils.deprecated" +] [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] From 8a65b160ebb60a2cb87e245ffa1de4b0b741022f Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 20 Apr 2023 18:14:33 -0400 Subject: [PATCH 40/51] FIX: TOMLY --- pyproject.toml | 9 +++++++++ setup.cfg | 42 ------------------------------------------ 2 files changed, 9 insertions(+), 42 deletions(-) delete mode 100644 setup.cfg diff --git a/pyproject.toml b/pyproject.toml index cc30610c6fb..0b0ddf24cfd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,3 +21,12 @@ ignore-decorators = [ [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] + +[tool.pytest.ini_options] +addopts = """--durations=20 --doctest-modules -ra --cov-report= --tb=short \ + --doctest-ignore-import-errors --junit-xml=junit-results.xml \ + --ignore=doc --ignore=logo --ignore=examples --ignore=tutorials \ + --ignore=mne/gui/_*.py --ignore=mne/icons --ignore=tools \ + --ignore=mne/report/js_and_css \ + --color=yes --capture=sys""" +junit_family = "xunit2" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 396a8906cc0..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,42 +0,0 @@ -[aliases] -release = egg_info -RDb '' -# Make sure the sphinx docs are built each time we do a dist. -# bdist = build_sphinx bdist -# sdist = build_sphinx sdist -# Make sure a zip file is created each time we build the sphinx docs -# build_sphinx = generate_help build_sphinx zip_help -# Make sure the docs are uploaded when we do an upload -# upload = upload upload_help - -[egg_info] -# tag_build = .dev - -[bdist_rpm] -doc_files = doc - -[flake8] -exclude = __init__.py,constants.py,fixes.py,resources.py,*doc/auto_*,*doc/_build*,build/* -ignore = W503,W504,I100,I101,I201,N806,E201,E202,E221,E222,E241 -# We add A for the array-spacing plugin, and ignore the E ones it covers above -select = A,E,F,W,C -# 10_spectrum_class.py has a wide rST table -per-file-ignores = - tutorials/time-freq/10_spectrum_class.py:E501 - -[tool:pytest] -addopts = - --durations=20 --doctest-modules -ra --cov-report= --tb=short - --doctest-ignore-import-errors --junit-xml=junit-results.xml - --ignore=doc --ignore=logo --ignore=examples --ignore=tutorials - --ignore=mne/gui/_*.py --ignore=mne/icons --ignore=tools - --ignore=mne/report/js_and_css - --color=yes --capture=sys -junit_family = xunit2 - -[pydocstyle] -convention = pep257 -match_dir = ^(?!\.|doc|tutorials|examples|logo|icons).*$ -match = (?!tests/__init__\.py|fixes).*\.py -add-ignore = D100,D104,D107,D413 -add-select = D214,D215,D404,D405,D406,D407,D408,D409,D410,D411 -ignore-decorators = ^(copy_.*_doc_to_|on_trait_change|cached_property|deprecated|property|.*setter).* From 4655f04cf7e1a8216cb8d073ce1d4b4785b3e9d7 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 20 Apr 2023 18:25:55 -0400 Subject: [PATCH 41/51] FIX: Reqs --- .github/workflows/flake.yml | 33 ------------ Makefile | 98 +++--------------------------------- azure-pipelines.yml | 8 +-- doc/install/contributing.rst | 5 +- requirements_testing.txt | 4 +- 5 files changed, 11 insertions(+), 137 deletions(-) delete mode 100644 .github/workflows/flake.yml diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml deleted file mode 100644 index df085952b5a..00000000000 --- a/.github/workflows/flake.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: 'flake' -# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency -# https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent -# workflow name, PR number (empty on push), push ref (empty on PR) -concurrency: - group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }} - cancel-in-progress: true -on: - push: - branches: - - '*' - pull_request: - branches: - - '*' - -jobs: - style: - name: 'flake' - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: '3.9' - architecture: 'x64' - - run: | - python -m pip install --upgrade pip setuptools wheel - python -m pip install flake8 - name: 'Install dependencies' - - uses: rbialon/flake8-annotations@v1 - name: 'Setup flake8 annotations' - - run: make flake - name: 'Run flake8' diff --git a/Makefile b/Makefile index 944b059aa2e..d303908ec8f 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,6 @@ PYTHON ?= python PYTESTS ?= py.test -CTAGS ?= ctags CODESPELL_SKIPS ?= "doc/_build,doc/auto_*,*.fif,*.eve,*.gz,*.tgz,*.zip,*.mat,*.stc,*.label,*.w,*.bz2,*.annot,*.sulc,*.log,*.local-copy,*.orig_avg,*.inflated_avg,*.gii,*.pyc,*.doctree,*.pickle,*.inv,*.png,*.edf,*.touch,*.thickness,*.nofix,*.volume,*.defect_borders,*.mgh,lh.*,rh.*,COR-*,FreeSurferColorLUT.txt,*.examples,.xdebug_mris_calc,bad.segments,BadChannels,*.hist,empty_file,*.orig,*.js,*.map,*.ipynb,searchindex.dat,install_mne_c.rst,plot_*.rst,*.rst.txt,c_EULA.rst*,*.html,gdf_encodes.txt,*.svg,references.bib,*.css,*.edf,*.bdf,*.vhdr" CODESPELL_DIRS ?= mne/ doc/ tutorials/ examples/ all: clean inplace test test-doc @@ -25,16 +24,6 @@ clean-cache: clean: clean-build clean-pyc clean-so clean-ctags clean-cache -in: inplace # just a shortcut -inplace: - $(PYTHON) setup.py build_ext -i - -wheel: - $(PYTHON) setup.py sdist bdist_wheel - -wheel_quiet: - $(PYTHON) setup.py -q sdist bdist_wheel - sample_data: @python -c "import mne; mne.datasets.sample.data_path(verbose=True);" @@ -43,22 +32,6 @@ testing_data: pytest: test -test: in - rm -f .coverage - $(PYTESTS) -m 'not ultraslowtest' mne - -test-verbose: in - rm -f .coverage - $(PYTESTS) -m 'not ultraslowtest' mne --verbose - -test-fast: in - rm -f .coverage - $(PYTESTS) -m 'not slowtest' mne - -test-full: in - rm -f .coverage - $(PYTESTS) mne - test-no-network: in sudo unshare -n -- sh -c 'MNE_SKIP_NETWORK_TESTS=1 py.test mne' @@ -66,56 +39,20 @@ test-no-testing-data: in @MNE_SKIP_TESTING_DATASET_TESTS=true \ $(PYTESTS) mne -test-no-sample-with-coverage: in testing_data - rm -rf coverage .coverage - $(PYTESTS) --cov=mne --cov-report html:coverage - test-doc: sample_data testing_data $(PYTESTS) --doctest-modules --doctest-ignore-import-errors --doctest-glob='*.rst' ./doc/ --ignore=./doc/auto_examples --ignore=./doc/auto_tutorials --ignore=./doc/_build --ignore=./doc/conf.py --ignore=doc/sphinxext --fulltrace -test-coverage: testing_data - rm -rf coverage .coverage - $(PYTESTS) --cov=mne --cov-report html:coverage -# whats the difference with test-no-sample-with-coverage? - -test-mem: in testing_data - ulimit -v 1097152 && $(PYTESTS) mne - -trailing-spaces: - find . -name "*.py" | xargs perl -pi -e 's/[ \t]*$$//' +pre-commit: + @pre-commit run -a -ctags: - # make tags for symbol based navigation in emacs and vim - # Install with: sudo apt-get install exuberant-ctags - $(CTAGS) -R * - -upload-pipy: - python setup.py sdist bdist_egg register upload - -flake: - @if command -v flake8 > /dev/null; then \ - echo "Running flake8"; \ - flake8 --count; \ - else \ - echo "flake8 not found, please install it!"; \ - exit 1; \ - fi; - @echo "flake8 passed" +# Aliases for stuff we used to support or users might think of +ruff: pre-commit +flake: pre-commit +pep: pre-commit codespell: # running manually @codespell --builtin clear,rare,informal,names,usage -w -i 3 -q 3 -S $(CODESPELL_SKIPS) --ignore-words=ignore_words.txt --uri-ignore-words-list=bu $(CODESPELL_DIRS) -codespell-error: # running on travis - @codespell --builtin clear,rare,informal,names,usage -i 0 -q 7 -S $(CODESPELL_SKIPS) --ignore-words=ignore_words.txt --uri-ignore-words-list=bu $(CODESPELL_DIRS) - -pydocstyle: - @echo "Running pydocstyle" - @pydocstyle mne - -docstring: - @echo "Running docstring tests" - @$(PYTESTS) --doctest-modules mne/tests/test_docstring_parameters.py - check-manifest: check-manifest -q --ignore .circleci/config.yml,doc,logo,mne/io/*/tests/data*,mne/io/tests/data,mne/preprocessing/tests/data,.DS_Store,mne/_version.py @@ -125,26 +62,3 @@ check-readme: clean wheel_quiet nesting: @echo "Running import nesting tests" @$(PYTESTS) mne/tests/test_import_nesting.py - -pep: - @$(MAKE) -k flake pydocstyle docstring codespell-error check-manifest nesting check-readme - -manpages: - @echo "I: generating manpages" - set -e; mkdir -p _build/manpages && \ - cd bin && for f in mne*; do \ - descr=$$(grep -h -e "^ *'''" -e 'DESCRIP =' $$f -h | sed -e "s,.*' *\([^'][^']*\)'.*,\1,g" | head -n 1); \ - PYTHONPATH=../ \ - help2man -n "$$descr" --no-discard-stderr --no-info --version-string "$(uver)" ./$$f \ - >| ../_build/manpages/$$f.1; \ - done - -build-doc-dev: - cd doc; make clean - cd doc; DISPLAY=:1.0 xvfb-run -n 1 -s "-screen 0 1280x1024x24 -noreset -ac +extension GLX +render" make html_dev - -build-doc-stable: - cd doc; make clean - cd doc; DISPLAY=:1.0 xvfb-run -n 1 -s "-screen 0 1280x1024x24 -noreset -ac +extension GLX +render" make html_stable - -docstyle: pydocstyle diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23927beb16c..6a515889731 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -55,12 +55,8 @@ stages: python -m pip install --progress-bar off -r requirements_base.txt -r requirements_hdf5.txt -r requirements_testing.txt displayName: Install dependencies - bash: | - make pydocstyle - displayName: make pydocstyle - condition: always() - - bash: | - make docstring - displayName: make docstring + make pre-commit + displayName: make ruff condition: always() - bash: | make nesting diff --git a/doc/install/contributing.rst b/doc/install/contributing.rst index e6efb6814f3..4de59a0d10c 100644 --- a/doc/install/contributing.rst +++ b/doc/install/contributing.rst @@ -694,7 +694,7 @@ Adhere to standard Python style guidelines All contributions to MNE-Python are checked against style guidelines described in `PEP 8`_. We also check for common coding errors (such as variables that are defined but never used). We allow very few exceptions to these guidelines, and -use tools such as pep8_, pyflakes_, and flake8_ to check code style +use tools such as ruff_ to check code style automatically. From the :file:`mne-python` root directory, you can check for style violations by running:: @@ -1097,8 +1097,7 @@ it can serve as a useful example of what to expect from the PR review process. .. linting .. _PEP 8: https://www.python.org/dev/peps/pep-0008/ -.. _pyflakes: https://pypi.org/project/pyflakes -.. _Flake8: http://flake8.pycqa.org/ +.. _ruff: https://beta.ruff.rs/docs .. misc diff --git a/requirements_testing.txt b/requirements_testing.txt index 3344f4b409e..928eba49183 100644 --- a/requirements_testing.txt +++ b/requirements_testing.txt @@ -3,11 +3,9 @@ pytest pytest-cov pytest-timeout pytest-harvest -flake8 -flake8-array-spacing +ruff numpydoc codespell -pydocstyle check-manifest twine wheel From 593a6250a2a28ae6a7df8d8082c761b9cc78d35d Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 20 Apr 2023 18:27:49 -0400 Subject: [PATCH 42/51] FIX: Cleaner --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 34fcd8b01fe..5ac5533802e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,17 +7,23 @@ repos: # hooks: # - id: black # args: [--quiet] + +# Ruff mne - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.262 hooks: - id: ruff files: ^mne/ + +# Ruff tutorials and examples - repo: https://github.com/charliermarsh/ruff-pre-commit rev: v0.0.262 hooks: - id: ruff args: ["--ignore=D103,D400"] files: ^tutorials/|^examples/ + +# Codespell - repo: https://github.com/codespell-project/codespell rev: v2.2.3 hooks: From b4509079d3fb62a2a263c72c6d3294d608aecbea Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 11:43:38 -0400 Subject: [PATCH 43/51] FIX: Fix em --- .pre-commit-config.yaml | 2 ++ examples/simulation/simulate_evoked_data.py | 2 +- .../simulation/simulated_raw_data_using_subject_anatomy.py | 3 +-- examples/visualization/topo_customized.py | 3 ++- mne/utils/check.py | 1 + pyproject.toml | 3 +++ 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ac5533802e..b854d5d745f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,6 +13,7 @@ repos: rev: v0.0.262 hooks: - id: ruff + name: ruff mne files: ^mne/ # Ruff tutorials and examples @@ -20,6 +21,7 @@ repos: rev: v0.0.262 hooks: - id: ruff + name: ruff tutorials and examples args: ["--ignore=D103,D400"] files: ^tutorials/|^examples/ diff --git a/examples/simulation/simulate_evoked_data.py b/examples/simulation/simulate_evoked_data.py index 0d4cff6a6c3..b906d2df265 100644 --- a/examples/simulation/simulate_evoked_data.py +++ b/examples/simulation/simulate_evoked_data.py @@ -55,7 +55,7 @@ def data_fun(times): - """Function to generate random source time courses""" + """Generate random source time courses.""" return (50e-9 * np.sin(30. * times) * np.exp(- (times - 0.15 + 0.05 * rng.randn(1)) ** 2 / 0.01)) diff --git a/examples/simulation/simulated_raw_data_using_subject_anatomy.py b/examples/simulation/simulated_raw_data_using_subject_anatomy.py index b78db66c965..0edb33e7d0f 100644 --- a/examples/simulation/simulated_raw_data_using_subject_anatomy.py +++ b/examples/simulation/simulated_raw_data_using_subject_anatomy.py @@ -124,8 +124,7 @@ def data_fun(times, latency, duration): - """Function to generate source time courses for evoked responses, - parametrized by latency and duration.""" + """Generate source time courses for evoked responses.""" f = 15 # oscillating frequency, beta band [Hz] sigma = 0.375 * duration sinusoid = np.sin(2 * np.pi * f * (times - latency)) diff --git a/examples/visualization/topo_customized.py b/examples/visualization/topo_customized.py index cc284431246..e9106a1e8d2 100644 --- a/examples/visualization/topo_customized.py +++ b/examples/visualization/topo_customized.py @@ -47,7 +47,8 @@ def my_callback(ax, ch_idx): - """ + """Handle axes callback. + This block of code is executed once you click on one of the channel axes in the plot. To work with the viz internals, this function should only take two parameters, the axis and the channel or data index. diff --git a/mne/utils/check.py b/mne/utils/check.py index 6a66fb20edc..e351184680f 100644 --- a/mne/utils/check.py +++ b/mne/utils/check.py @@ -1122,6 +1122,7 @@ def _to_rgb(*args, name='color', alpha=False): @deprecated('has_nibabel is deprecated and will be removed in 1.5') def has_nibabel(): + """Check if nibabel is installed.""" return check_version('nibabel') # pragma: no cover diff --git a/pyproject.toml b/pyproject.toml index 0b0ddf24cfd..69e29ff04e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,9 @@ ignore-decorators = [ [tool.ruff.per-file-ignores] "tutorials/time-freq/10_spectrum_class.py" = ["E501"] +"mne/datasets/*/*.py" = ["D103"] +"mne/utils/tests/test_docs.py" = ["D101", "D411", "D410", "D414"] +"examples/*/*.py" = ["D205"] [tool.pytest.ini_options] addopts = """--durations=20 --doctest-modules -ra --cov-report= --tb=short \ From 6416b6f7223cbe2d7301d661bf4542345447851b Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 12:46:12 -0400 Subject: [PATCH 44/51] FIX: More --- Makefile | 3 +++ requirements_testing.txt | 1 + 2 files changed, 4 insertions(+) diff --git a/Makefile b/Makefile index d303908ec8f..c0e47ada7fb 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,9 @@ clean-cache: clean: clean-build clean-pyc clean-so clean-ctags clean-cache +wheel_quiet: + $(PYTHON) setup.py -q sdist bdist_wheel + sample_data: @python -c "import mne; mne.datasets.sample.data_path(verbose=True);" diff --git a/requirements_testing.txt b/requirements_testing.txt index 928eba49183..c8ff7b5c5fb 100644 --- a/requirements_testing.txt +++ b/requirements_testing.txt @@ -9,3 +9,4 @@ codespell check-manifest twine wheel +pre-commit From f1b7076db15addc74fcc297cb8b1700f84eb4aa3 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 12:46:39 -0400 Subject: [PATCH 45/51] FIX: Install hooks --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 96c486f2947..d56a77ca841 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -50,9 +50,10 @@ stages: addToPath: true displayName: 'Get Python' - bash: | - set -e + set -eo pipefail python -m pip install --progress-bar off --upgrade pip setuptools wheel python -m pip install --progress-bar off -r requirements_base.txt -r requirements_hdf5.txt -r requirements_testing.txt + pre-commit install --install-hooks displayName: Install dependencies - bash: | make pre-commit From 1414b221c40aacc8f9ae104708758dc6566d55b4 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 13:07:06 -0400 Subject: [PATCH 46/51] FIX: Ver --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d56a77ca841..e27e056aa3f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,7 +39,7 @@ stages: pool: vmImage: 'ubuntu-latest' variables: - PYTHON_VERSION: '3.9' + PYTHON_VERSION: '3.11' PYTHON_ARCH: 'x64' steps: - bash: echo $(COMMIT_MSG) From 1f297d68b30f34c96b45f3b69ec5b0bf56693cf1 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 13:30:09 -0400 Subject: [PATCH 47/51] FIX: Instructions --- doc/install/contributing.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/install/contributing.rst b/doc/install/contributing.rst index 78a778d49b7..7ec42192741 100644 --- a/doc/install/contributing.rst +++ b/doc/install/contributing.rst @@ -696,9 +696,14 @@ in `PEP 8`_. We also check for common coding errors (such as variables that are defined but never used). We allow very few exceptions to these guidelines, and use tools such as ruff_ to check code style automatically. From the :file:`mne-python` root directory, you can check for -style violations by running:: +style violations by first installing pre-commit hook - $ make flake + $ pip install pre-commit + $ pre-commit install --install-hooks + +Then running:: + + $ make ruff in the shell. Several text editors or IDEs also have Python style checking, which can highlight style errors while you code (and train you to make those @@ -748,7 +753,7 @@ but complete docstrings are appropriate when private functions/methods are relatively complex. To run some basic tests on documentation, you can use:: $ pytest mne/tests/test_docstring_parameters.py - $ make docstyle + $ make ruff Cross-reference everywhere From a9427fcd29450aeb05fb572732cb9036959f5d20 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 13:31:51 -0400 Subject: [PATCH 48/51] FIX: Explain --- doc/install/contributing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/install/contributing.rst b/doc/install/contributing.rst index 7ec42192741..5dfa97aa004 100644 --- a/doc/install/contributing.rst +++ b/doc/install/contributing.rst @@ -703,7 +703,7 @@ style violations by first installing pre-commit hook Then running:: - $ make ruff + $ make ruff # alias for `pre-commit run -a` in the shell. Several text editors or IDEs also have Python style checking, which can highlight style errors while you code (and train you to make those From 61f456244b1d4ef1688b004dbe64db30ff56dbe5 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 18:05:11 -0400 Subject: [PATCH 49/51] Apply suggestions from code review Co-authored-by: Daniel McCloy --- .pre-commit-config.yaml | 2 ++ doc/install/contributing.rst | 2 +- pyproject.toml | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b854d5d745f..4814c23d8eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,8 @@ repos: hooks: - id: ruff name: ruff tutorials and examples + # D103: missing docstring in public function + # D400: docstring first line must end with period args: ["--ignore=D103,D400"] files: ^tutorials/|^examples/ diff --git a/doc/install/contributing.rst b/doc/install/contributing.rst index 5dfa97aa004..f7b278fe7d7 100644 --- a/doc/install/contributing.rst +++ b/doc/install/contributing.rst @@ -696,7 +696,7 @@ in `PEP 8`_. We also check for common coding errors (such as variables that are defined but never used). We allow very few exceptions to these guidelines, and use tools such as ruff_ to check code style automatically. From the :file:`mne-python` root directory, you can check for -style violations by first installing pre-commit hook +style violations by first installing our pre-commit hook:: $ pip install pre-commit $ pre-commit install --install-hooks diff --git a/pyproject.toml b/pyproject.toml index 69e29ff04e2..a04cb2bf2d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,12 @@ skip = "doc/references.bib" [tool.ruff] select = ["E", "F", "W", "D"] exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] -ignore = ["D100", "D104", "D107", "D413"] +ignore = [ + "D100", # Missing docstring in public module + "D104", # Missing docstring in public package + "D107", # Missing docstring in __init__ + "D413", # Missing blank line after last section +] [tool.ruff.pydocstyle] convention = "numpy" From 2545bb6c0752c318e750ce57cb180e1aae408c2a Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 18:05:55 -0400 Subject: [PATCH 50/51] Apply suggestions from code review Co-authored-by: Daniel McCloy --- pyproject.toml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index a04cb2bf2d6..24c2c22b5f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,10 +25,21 @@ ignore-decorators = [ ] [tool.ruff.per-file-ignores] -"tutorials/time-freq/10_spectrum_class.py" = ["E501"] -"mne/datasets/*/*.py" = ["D103"] -"mne/utils/tests/test_docs.py" = ["D101", "D411", "D410", "D414"] -"examples/*/*.py" = ["D205"] +"tutorials/time-freq/10_spectrum_class.py" = [ + "E501" # line too long +] +"mne/datasets/*/*.py" = [ + "D103", # Missing docstring in public function +] +"mne/utils/tests/test_docs.py" = [ + "D101", # Missing docstring in public class + "D410", # Missing blank line after section + "D411", # Missing blank line before section + "D414", # Section has no content +] +"examples/*/*.py" = [ + "D205", # 1 blank line required between summary line and description +] [tool.pytest.ini_options] addopts = """--durations=20 --doctest-modules -ra --cov-report= --tb=short \ From d0c00a372cb266431db4e3fbf89b97d25f2c7991 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 21 Apr 2023 18:06:09 -0400 Subject: [PATCH 51/51] FIX: D107 --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 24c2c22b5f8..b8b664ab193 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,6 @@ exclude = ["__init__.py", "constants.py", "fixes.py", "resources.py"] ignore = [ "D100", # Missing docstring in public module "D104", # Missing docstring in public package - "D107", # Missing docstring in __init__ "D413", # Missing blank line after last section ]