Skip to content

Commit

Permalink
[MAINT] add workflow to check for f strings (#3759)
Browse files Browse the repository at this point in the history
* add workflow for flynt

* configure and run flynt

* flake8

* Update .github/workflows/f_strings.yml

Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com>

* Update nilearn/_utils/data_gen.py

Co-authored-by: bthirion <bertrand.thirion@inria.fr>

* pre-commit hooks auto-update (#3764)

Co-authored-by: Remi-Gau <Remi-Gau@users.noreply.github.com>

* [DOC] update changelog and git blame ignore (#3755)

* update git-blame-ignore

* update changelog

* fix

* update ignore

* fix regex escape

* flake8

* use list and not set

* simplify rev file

* rm spaces

* pragmatism wins

* rm import

* reset plotting files

* [FIX] Change error string to match scikit-learn `InvalidParameterError` message (#3763)

* Modify ValueError string

* Warning based on sklearn version

* relax regex for warning on sanitize reorder error (#3766)

---------

Co-authored-by: Yasmin <63292494+ymzayek@users.noreply.github.com>
Co-authored-by: bthirion <bertrand.thirion@inria.fr>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Remi-Gau <Remi-Gau@users.noreply.github.com>
  • Loading branch information
5 people committed Jun 20, 2023
1 parent bb59d69 commit 88b4232
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/f_strings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: f strings

on:
push:
branches:
- "main"
pull_request:
branches:
- "*"

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

jobs:
f_strings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: "Install flynt"
shell: bash {0}
run: python -m pip install --upgrade pip flynt

- name: "Run flynt"
run: flynt .
12 changes: 6 additions & 6 deletions examples/01_plotting/plot_surf_atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
fsaverage = datasets.fetch_surf_fsaverage()

# The fsaverage dataset contains file names pointing to the file locations
print('Fsaverage5 pial surface of left hemisphere is at: %s' %
fsaverage['pial_left'])
print('Fsaverage5 inflated surface of left hemisphere is at: %s' %
fsaverage['infl_left'])
print('Fsaverage5 sulcal depth map of left hemisphere is at: %s' %
fsaverage['sulc_left'])
print("Fsaverage5 pial surface of left hemisphere is at: "
f"{fsaverage['pial_left']}")
print("Fsaverage5 inflated surface of left hemisphere is at: "
f"{fsaverage['infl_left']}")
print("Fsaverage5 sulcal depth map of left hemisphere is at: "
f"{fsaverage['sulc_left']}")

###############################################################################
# Visualization
Expand Down
2 changes: 1 addition & 1 deletion nilearn/_utils/data_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def generate_group_sparse_gaussian_graphs(n_subjects=5,
topology = topology > 0
assert (np.all(topology == topology.T))
logger.log(
"Sparsity: {0:f}".format(1. * topology.sum() / (topology.shape[0]**2)),
f"Sparsity: {1.0 * topology.sum() / topology.shape[0] ** 2 :f}",
verbose=verbose)

# Generate temporal signals
Expand Down
3 changes: 1 addition & 2 deletions nilearn/_utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,5 @@ def fill_doc(f):
except (TypeError, ValueError, KeyError) as exp:
funcname = f.__name__
funcname = docstring.split('\n')[0] if funcname is None else funcname
raise RuntimeError('Error documenting %s:\n%s'
% (funcname, str(exp)))
raise RuntimeError(f'Error documenting {funcname}:\n{str(exp)}')
return f
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,6 @@ junit_family = "xunit2"
[tool.codespell]
skip = "./.git,plotly-gl3d-latest.min.js,jquery.min.js,localizer_behavioural.tsv,.mypy_cache,env,venv,./doc/auto_examples"
ignore-words = ".github/codespell_ignore_words.txt"

[tool.flynt]
exclude = "tempita"

0 comments on commit 88b4232

Please sign in to comment.