Skip to content

Commit 202d6df

Browse files
committed
changes to make ruff happy
1 parent b52816e commit 202d6df

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/bids_validator/__main__.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
# ruff: noqa: D100
2+
# ruff: noqa: D103
3+
14
try:
25
import typer
36
except ImportError:
47
print('⚠️ CLI dependencies are not installed. Install "bids_validator[cli]"')
58
raise SystemExit(1) from None
69

710
import sys
8-
from typing_extensions import Annotated
9-
import importlib.metadata
11+
from typing import Annotated
1012

1113
from bids_validator import BIDSValidator
1214
from bids_validator.types.files import FileTree
@@ -32,6 +34,7 @@ def walk(tree: FileTree):
3234
else:
3335
yield child
3436

37+
3538
def validate(tree: FileTree):
3639
"""Check if the file path is BIDS compliant.
3740
@@ -44,22 +47,24 @@ def validate(tree: FileTree):
4447
validator = BIDSValidator()
4548

4649
for file in walk(tree):
47-
# The output of the FileTree.relative_path method always drops the initial for the path which
48-
# makes it fail the validator.is_bids check. Not sure if it's a Windows specific thing.
50+
# The output of the FileTree.relative_path method always drops the initial for the path
51+
# which makes it fail the validator.is_bids check. THis may be a Windows specific thing.
4952
# This line adds it back.
5053
path = f'/{file.relative_path}'
5154

5255
if not validator.is_bids(path):
5356
print(f'{path} is not a valid bids filename')
5457

58+
5559
def show_version():
56-
"""Show bids-validator version
57-
"""
60+
"""Show bids-validator version."""
5861
from . import __version__
62+
5963
print(f'bids-validator {__version__} (Python {sys.version.split()[0]})')
6064

65+
6166
def version_callback(value: bool):
62-
"""Callback for CLI version flag
67+
"""Run the callback for CLI version flag.
6368
6469
Parameters
6570
----------
@@ -70,27 +75,29 @@ def version_callback(value: bool):
7075
------
7176
typer.Exit
7277
Exit without any errors
78+
7379
"""
7480
if value:
7581
show_version()
7682
raise typer.Exit()
7783

84+
7885
@app.command()
7986
def main(
8087
bids_path: str,
81-
verbose: Annotated[bool, typer.Option(
82-
"--verbose", "-v",
83-
help="Show verbose output"
84-
)] = False,
85-
version: Annotated[bool, typer.Option(
86-
"--version",
87-
help="Show version",
88-
callback=version_callback,
89-
is_eager=True,
90-
)] = False
88+
verbose: Annotated[bool, typer.Option('--verbose', '-v', help='Show verbose output')] = False,
89+
version: Annotated[
90+
bool,
91+
typer.Option(
92+
'--version',
93+
help='Show version',
94+
callback=version_callback,
95+
is_eager=True,
96+
),
97+
] = False,
9198
) -> None:
92-
93-
if verbose: show_version()
99+
if verbose:
100+
show_version()
94101

95102
root_path = FileTree.read_from_filesystem(bids_path)
96103

src/bids_validator/types/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import stat
66
from functools import cached_property
77
from pathlib import Path
8-
from typing import Dict, Union
8+
from typing import Union
99

1010
import attrs
1111
from typing_extensions import Self # PY310
@@ -72,7 +72,7 @@ class FileTree:
7272
direntry: Union[os.DirEntry, UserDirEntry] = attrs.field(repr=False, converter=as_direntry)
7373
parent: Union['FileTree', None] = attrs.field(repr=False, default=None)
7474
is_dir: bool = attrs.field(default=False)
75-
children: Dict[str, 'FileTree'] = attrs.field(repr=False, factory=dict)
75+
children: dict[str, 'FileTree'] = attrs.field(repr=False, factory=dict)
7676
name: str = attrs.field(init=False)
7777

7878
def __attrs_post_init__(self):

tests/types/test_files.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# ruff: noqa: D100
2+
13
import attrs
4+
25
from bids_validator.types.files import FileTree
36

47

0 commit comments

Comments
 (0)