From 9552896cd0e73a4d6aa9612bd037cc847a1e664e Mon Sep 17 00:00:00 2001
From: Remi Gau <remi_gau@hotmail.com>
Date: Wed, 24 Apr 2024 12:43:13 +0200
Subject: [PATCH] update precommit config (#4391)

---
 .pre-commit-config.yaml                       | 35 +++++++++++--------
 .../plot_localizer_surface_analysis.py        |  4 +--
 .../07_advanced/plot_surface_bids_analysis.py |  2 +-
 nilearn/plotting/surf_plotting.py             |  8 ++---
 4 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 629788546c..adc42e3a46 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -8,20 +8,6 @@ exclude: |
         | nilearn/externals/.*
         | nilearn/plotting/data/js/.*js
         | nilearn/_version.py
-        | examples/01_plotting/plot_3d_map_to_surface_projection.py
-        | examples/01_plotting/plot_surf_atlas.py
-        | examples/01_plotting/plot_surf_stat_map.py
-        | examples/01_plotting/plot_surface_projection_strategies.py
-        | examples/04_glm_first_level/plot_localizer_surface_analysis.py
-        | examples/07_advanced/plot_surface_bids_analysis.py
-        | nilearn/_utils/helpers.py
-        | nilearn/plotting/html_surface.py
-        | nilearn/plotting/js_plotting_utils.py
-        | nilearn/plotting/surf_plotting.py
-        | nilearn/plotting/tests/test_html_surface.py
-        | nilearn/plotting/tests/test_surf_plotting.py
-        | nilearn/surface/surface.py
-        | nilearn/surface/tests/test_surface.py
     )$
 
 repos:
@@ -66,6 +52,27 @@ repos:
     hooks:
     -   id: black
         args: [--config, pyproject.toml]
+        exclude: |
+            (?x)^(
+                nilearn/datasets/tests/data/localizer_behavioural.tsv
+                | nilearn/externals/.*
+                | nilearn/plotting/data/js/.*js
+                | nilearn/_version.py
+                | examples/01_plotting/plot_3d_map_to_surface_projection.py
+                | examples/01_plotting/plot_surf_atlas.py
+                | examples/01_plotting/plot_surf_stat_map.py
+                | examples/01_plotting/plot_surface_projection_strategies.py
+                | examples/04_glm_first_level/plot_localizer_surface_analysis.py
+                | examples/07_advanced/plot_surface_bids_analysis.py
+                | nilearn/_utils/helpers.py
+                | nilearn/plotting/html_surface.py
+                | nilearn/plotting/js_plotting_utils.py
+                | nilearn/plotting/surf_plotting.py
+                | nilearn/plotting/tests/test_html_surface.py
+                | nilearn/plotting/tests/test_surf_plotting.py
+                | nilearn/surface/surface.py
+                | nilearn/surface/tests/test_surface.py
+            )$
 
 -   repo: https://github.com/adamchainz/blacken-docs
     rev: 1.16.0
diff --git a/examples/04_glm_first_level/plot_localizer_surface_analysis.py b/examples/04_glm_first_level/plot_localizer_surface_analysis.py
index 05b6c2440e..b16fb26465 100644
--- a/examples/04_glm_first_level/plot_localizer_surface_analysis.py
+++ b/examples/04_glm_first_level/plot_localizer_surface_analysis.py
@@ -121,8 +121,8 @@
 
 # %%
 # At first, we create basic contrasts.
-basic_contrasts = dict([(column, contrast_matrix[i])
-                        for i, column in enumerate(design_matrix.columns)])
+basic_contrasts = {column: contrast_matrix[i]
+                   for i, column in enumerate(design_matrix.columns)}
 
 # %%
 # Next, we add some intermediate contrasts and
diff --git a/examples/07_advanced/plot_surface_bids_analysis.py b/examples/07_advanced/plot_surface_bids_analysis.py
index 883aa69c4d..68d76d26fb 100644
--- a/examples/07_advanced/plot_surface_bids_analysis.py
+++ b/examples/07_advanced/plot_surface_bids_analysis.py
@@ -70,7 +70,7 @@
              'sub-01' /
              'func' /
              'sub-01_task-languagelocalizer_desc-preproc_bold.json')
-with open(json_file, 'r') as f:
+with open(json_file) as f:
     t_r = json.load(f)['RepetitionTime']
 
 # %%
diff --git a/nilearn/plotting/surf_plotting.py b/nilearn/plotting/surf_plotting.py
index f5bb81cac3..e69f03360d 100644
--- a/nilearn/plotting/surf_plotting.py
+++ b/nilearn/plotting/surf_plotting.py
@@ -829,10 +829,10 @@ def plot_surf(surf_mesh, surf_map=None, bg_map=None,
         for parameter, value in parameters_not_implemented_in_plotly.items():
             if value is not None:
                 warn(
-                    (f"'{parameter}' is not implemented "
-                     "for the plotly engine.\n"
-                     f"Got '{parameter} = {value}'.\n"
-                     f"Use '{parameter} = None' to silence this warning."))
+                    f"'{parameter}' is not implemented "
+                    "for the plotly engine.\n"
+                    f"Got '{parameter} = {value}'.\n"
+                    f"Use '{parameter} = None' to silence this warning.")
 
     coords, faces = load_surf_mesh(surf_mesh)