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] add workflow to check for f strings #3759

Merged
merged 10 commits into from
Jun 20, 2023
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 isort"
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved
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}",
Remi-Gau marked this conversation as resolved.
Show resolved Hide resolved
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 @@
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)}')

Check warning on line 905 in nilearn/_utils/docs.py

View check run for this annotation

Codecov / codecov/patch

nilearn/_utils/docs.py#L905

Added line #L905 was not covered by tests
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"