Skip to content

Commit c7e1c10

Browse files
committed
sty: ruff check --fix && ruff format [ignore-rev]
1 parent d09791d commit c7e1c10

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

src/bids_validator/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import sys
1111
from collections.abc import Iterator
12-
from typing import Annotated, Optional
12+
from typing import Annotated
1313

1414
from bidsschematools.schema import load_schema
1515
from bidsschematools.types import Namespace
@@ -100,7 +100,7 @@ def version_callback(value: bool):
100100
@app.command()
101101
def main(
102102
bids_path: str,
103-
schema_path: Optional[str] = None,
103+
schema_path: str | None = None,
104104
verbose: Annotated[bool, typer.Option('--verbose', '-v', help='Show verbose output')] = False,
105105
version: Annotated[
106106
bool,

src/bids_validator/bidsignore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import os
44
import re
55
from functools import lru_cache
6-
from typing import Protocol, Union
6+
from typing import Protocol
77

88
import attrs
99

1010
from .types.files import FileTree
1111

1212

1313
@lru_cache
14-
def compile_pat(pattern: str) -> Union[re.Pattern, None]:
14+
def compile_pat(pattern: str) -> re.Pattern | None:
1515
"""Compile .gitignore-style ignore lines to regular expressions."""
1616
orig = pattern
1717
# A line starting with # serves as a comment.

src/bids_validator/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def load_tsv(file: FileTree, *, max_rows=0) -> Namespace:
6767
fobj = itertools.islice(fobj, max_rows)
6868
contents = (line.rstrip('\r\n').split('\t') for line in fobj)
6969
# Extract headers then transpose rows to columns
70-
return Namespace(zip(next(contents), zip(*contents)))
70+
return Namespace(zip(next(contents), zip(*contents, strict=False), strict=False))
7171

7272

7373
@cache
@@ -78,7 +78,7 @@ def load_tsv_gz(file: FileTree, headers: tuple[str], *, max_rows=0) -> Namespace
7878
if max_rows > 0:
7979
gzobj = itertools.islice(gzobj, max_rows)
8080
contents = (line.decode().rstrip('\r\n').split('\t') for line in gzobj)
81-
return Namespace(zip(headers, zip(*contents)))
81+
return Namespace(zip(headers, zip(*contents, strict=False), strict=False))
8282

8383

8484
@cache

tests/test_context.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,24 +163,28 @@ def test_sessions(synthetic_dataset):
163163

164164

165165
def test_load_tsv(synthetic_dataset):
166-
167166
tsv_file_tree = synthetic_dataset / 'participants.tsv'
168167
tsv_file = context.load_tsv(tsv_file_tree)
169168

170169
data_set = {
171-
"participant_id": ("sub-01", "sub-02", "sub-03", "sub-04", "sub-05"),
172-
"age": (34, 38, 22, 21, 42),
173-
"sex": ("F", "M", "M", "F", "M")
170+
'participant_id': ('sub-01', 'sub-02', 'sub-03', 'sub-04', 'sub-05'),
171+
'age': (34, 38, 22, 21, 42),
172+
'sex': ('F', 'M', 'M', 'F', 'M'),
174173
}
175174

176175
assert tsv_file.keys() == data_set.keys()
177-
assert [tsv_file[key] == data_set[key] for key in tsv_file.keys()]
176+
assert [tsv_file[key] == data_set[key] for key in tsv_file.keys()]
178177

179178

180179
def test_load_tsv_gz(synthetic_dataset):
181-
182-
headers = ("respiratory", "cardiac")
183-
tsvgz_file_tree = synthetic_dataset / "sub-01" / "ses-01" / "func" /"sub-01_ses-01_task-nback_run-01_stim.tsv.gz"
180+
headers = ('respiratory', 'cardiac')
181+
tsvgz_file_tree = (
182+
synthetic_dataset
183+
/ 'sub-01'
184+
/ 'ses-01'
185+
/ 'func'
186+
/ 'sub-01_ses-01_task-nback_run-01_stim.tsv.gz'
187+
)
184188

185189
tsvgz_file = context.load_tsv_gz(tsvgz_file_tree, headers)
186190

0 commit comments

Comments
 (0)