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

Upgrade to ruff 0.9.1 #3421

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .maint/update_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def get_git_lines(fname='line-contributors.txt'):
def _namelast(inlist):
retval = []
for i in inlist:
i['name'] = (f"{i.pop('name', '')} {i.pop('lastname', '')}").strip()
i['name'] = (f'{i.pop("name", "")} {i.pop("lastname", "")}').strip()
retval.append(i)
return retval

Expand Down Expand Up @@ -187,7 +187,7 @@ def zenodo(
misses = set(miss_creators).intersection(miss_contributors)
if misses:
print(
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
f'Some people made commits, but are missing in .maint/ files: {", ".join(misses)}',
file=sys.stderr,
)

Expand Down Expand Up @@ -268,7 +268,7 @@ def _aslist(value):

if misses:
print(
f"Some people made commits, but are missing in .maint/ files: {', '.join(misses)}",
f'Some people made commits, but are missing in .maint/ files: {", ".join(misses)}',
file=sys.stderr,
)

Expand Down
2 changes: 1 addition & 1 deletion .maint/update_zenodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def get_git_lines(fname='line-contributors.txt'):
if cmd == [None]:
cmd = [shutil.which('git-summary'), '--line']
if not lines and cmd[0]:
print(f"Running {' '.join(cmd)!r} on repo")
print(f'Running {" ".join(cmd)!r} on repo')
lines = sp.check_output(cmd).decode().splitlines()
lines = [line for line in lines if 'Not Committed Yet' not in line]
contrib_file.write_text('\n'.join(lines))
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
- id: check-toml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.2
rev: v0.9.1
hooks:
- id: ruff
args: [ --fix ]
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _warn(message, category=None, stacklevel=1, source=None):
category = type(category).__name__
category = category.replace('type', 'WARNING')

logging.getLogger('py.warnings').warning(f"{category or 'WARNING'}: {message}")
logging.getLogger('py.warnings').warning(f'{category or "WARNING"}: {message}')


def _showwarning(message, category, filename, lineno, file=None, line=None):
Expand Down
10 changes: 4 additions & 6 deletions fmriprep/cli/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class DeprecatedAction(Action):
def __call__(self, parser, namespace, values, option_string=None):
new_opt, rem_vers = deprecations.get(self.dest, (None, None))
msg = (
f"{self.option_strings} has been deprecated and will be removed in "
f"{rem_vers or 'a later version'}."
f'{self.option_strings} has been deprecated and will be removed in '
f'{rem_vers or "a later version"}.'
)
if new_opt:
msg += f' Please use `{new_opt}` instead.'
Expand Down Expand Up @@ -557,8 +557,7 @@ def _slice_time_ref(value, parser):
action='store',
default=0.5,
type=float,
help='Threshold for flagging a frame as an outlier on the basis of framewise '
'displacement',
help='Threshold for flagging a frame as an outlier on the basis of framewise displacement',
)
g_confounds.add_argument(
'--dvars-spike-threshold',
Expand Down Expand Up @@ -900,8 +899,7 @@ def parse_args(args=None, namespace=None):
from ..utils.bids import validate_input_dir

build_log.info(
'Making sure the input data is BIDS compliant (warnings can be ignored in most '
'cases).'
'Making sure the input data is BIDS compliant (warnings can be ignored in most cases).'
)
validate_input_dir(
config.environment.exec_env,
Expand Down
6 changes: 3 additions & 3 deletions fmriprep/cli/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@
notice_path = data.load.readable('NOTICE')
if notice_path.exists():
banner[0] += '\n'
banner += [f"License NOTICE {'#' * 50}"]
banner += [f'License NOTICE {"#" * 50}']

Check warning on line 61 in fmriprep/cli/workflow.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/cli/workflow.py#L61

Added line #L61 was not covered by tests
banner += [f'fMRIPrep {version}']
banner += notice_path.read_text().splitlines(keepends=False)[1:]
banner += ['#' * len(banner[1])]
build_log.log(25, f"\n{' ' * 9}".join(banner))
build_log.log(25, f'\n{" " * 9}'.join(banner))

Check warning on line 65 in fmriprep/cli/workflow.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/cli/workflow.py#L65

Added line #L65 was not covered by tests

# warn if older results exist: check for dataset_description.json in output folder
msg = check_pipeline_version('fMRIPrep', version, fmriprep_dir / 'dataset_description.json')
Expand Down Expand Up @@ -121,7 +121,7 @@
if config.execution.fs_subjects_dir:
init_msg += [f"Pre-run FreeSurfer's SUBJECTS_DIR: {config.execution.fs_subjects_dir}."]

build_log.log(25, f"\n{' ' * 11}* ".join(init_msg))
build_log.log(25, f'\n{" " * 11}* '.join(init_msg))

Check warning on line 124 in fmriprep/cli/workflow.py

View check run for this annotation

Codecov / codecov/patch

fmriprep/cli/workflow.py#L124

Added line #L124 was not covered by tests

retval['workflow'] = init_fmriprep_wf()

Expand Down
2 changes: 1 addition & 1 deletion fmriprep/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class execution(_Config):
the command line) as spatial references for outputs."""
reports_only = False
"""Only build the reports, based on the reportlets found in a cached working directory."""
run_uuid = f"{strftime('%Y%m%d-%H%M%S')}_{uuid4()}"
run_uuid = f'{strftime("%Y%m%d-%H%M%S")}_{uuid4()}'
"""Unique identifier of this particular run."""
participant_label = None
"""List of participant identifiers that are to be preprocessed."""
Expand Down
3 changes: 1 addition & 2 deletions fmriprep/interfaces/workbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ class MetricDilateInputSpec(OpenMPTraitedSpec):
argstr='-exponent %f ',
position=9,
default=6.0,
desc='exponent n to use in (area / (distance ^ n)) as the '
'weighting function (default 6)',
desc='exponent n to use in (area / (distance ^ n)) as the weighting function (default 6)',
)

corrected_areas = File(
Expand Down
12 changes: 6 additions & 6 deletions fmriprep/reports/tests/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ def mock_session_list(*args, **kwargs):

html_content = Path.read_text(tmp_path / expected_files[0])
if boilerplate:
assert (
'The boilerplate text was automatically generated' in html_content
), f'The file {expected_files[0]} did not contain the reported error.'
assert 'The boilerplate text was automatically generated' in html_content, (
f'The file {expected_files[0]} did not contain the reported error.'
)

if error:
assert (
'One or more execution steps failed' in html_content
), f'The file {expected_files[0]} did not contain the reported error.'
assert 'One or more execution steps failed' in html_content, (
f'The file {expected_files[0]} did not contain the reported error.'
)
2 changes: 1 addition & 1 deletion fmriprep/utils/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def write_derivative_description(bids_dir, deriv_dir, dataset_links=None):
if 'FMRIPREP_DOCKER_TAG' in os.environ:
desc['GeneratedBy'][0]['Container'] = {
'Type': 'docker',
'Tag': f"nipreps/fmriprep:{os.environ['FMRIPREP_DOCKER_TAG']}",
'Tag': f'nipreps/fmriprep:{os.environ["FMRIPREP_DOCKER_TAG"]}',
}
if 'FMRIPREP_SINGULARITY_URL' in os.environ:
desc['GeneratedBy'][0]['Container'] = {
Expand Down
8 changes: 4 additions & 4 deletions fmriprep/workflows/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ def init_single_subject_wf(subject_id: str):

if subject_data['roi']:
warnings.warn(
f"Lesion mask {subject_data['roi']} found. "
"Future versions of fMRIPrep will use alternative conventions. "
"Please refer to the documentation before upgrading.",
f'Lesion mask {subject_data["roi"]} found. '
'Future versions of fMRIPrep will use alternative conventions. '
'Please refer to the documentation before upgrading.',
FutureWarning,
stacklevel=1,
)
Expand Down Expand Up @@ -828,7 +828,7 @@ def map_fieldmap_estimation(
for bold_file, estimator_key in all_estimators.items():
if len(estimator_key) > 1:
config.loggers.workflow.warning(
f"Several fieldmaps <{', '.join(estimator_key)}> are "
f'Several fieldmaps <{", ".join(estimator_key)}> are '
f"'IntendedFor' <{bold_file}>, using {estimator_key[0]}"
)
estimator_key[1:] = []
Expand Down
2 changes: 1 addition & 1 deletion fmriprep/workflows/bold/stc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def init_bold_stc_wf(
slice_timing_correction = pe.Node(
TShift(
outputtype='NIFTI_GZ',
tr=f"{metadata['RepetitionTime']}s",
tr=f'{metadata["RepetitionTime"]}s',
slice_timing=metadata['SliceTiming'],
slice_encoding_direction=metadata.get('SliceEncodingDirection', 'k'),
tzero=tzero,
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ extend-select = [
]
ignore = [
"S311", # We are not using random for cryptographic purposes
"ISC001",
"S603",
]

Expand Down
1 change: 0 additions & 1 deletion wrapper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ extend-select = [
]
ignore = [
"S311", # We are not using random for cryptographic purposes
"ISC001",
]

[tool.ruff.lint.flake8-quotes]
Expand Down
Loading