Skip to content

Commit 7d46dfc

Browse files
committed
sty: pyupgrade --py39-plus
1 parent 2cbdf82 commit 7d46dfc

File tree

5 files changed

+7
-16
lines changed

5 files changed

+7
-16
lines changed

tools/schemacode/src/bidsschematools/__main__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@
33
import os
44
import re
55
import sys
6+
from importlib.resources import files
67
from itertools import chain
78

89
import click
910

10-
if sys.version_info < (3, 9):
11-
from importlib_resources import files
12-
else:
13-
from importlib.resources import files
14-
1511
from .rules import regexify_filename_rules
1612
from .schema import export_schema, load_schema
1713
from .validator import _bidsignore_check

tools/schemacode/src/bidsschematools/render/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def _make_entity_definition(entity, entity_info):
6060
"""Describe an entity."""
6161
entity_shorthand = entity_info["name"]
6262
text = ""
63-
text += "## {}".format(entity_shorthand)
63+
text += f"## {entity_shorthand}"
6464
text += "\n\n"
6565
text += f"**Full name**: {entity_info['display_name']}"
6666
text += "\n\n"

tools/schemacode/src/bidsschematools/rules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _optional_regex(regex, optional):
6464
return f"(?:{regex})?" if optional else regex
6565

6666

67-
@lru_cache()
67+
@lru_cache
6868
def _format_entity(entity, name, pattern, level, directory=False):
6969
if directory and entity not in DIR_ENTITIES:
7070
return ""
@@ -237,7 +237,7 @@ def regexify_filename_rules(
237237
return regex_schema
238238

239239

240-
@lru_cache()
240+
@lru_cache
241241
def regexify_all(schema_dir=None):
242242
"""
243243
Create full path regexes for all BIDS specification files.

tools/schemacode/src/bidsschematools/schema.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
import json
44
import os
55
import re
6-
import sys
76
import tempfile
87
from collections.abc import Iterable, Mapping
98
from copy import deepcopy
109
from functools import lru_cache
10+
from importlib.resources import files
1111

1212
from jsonschema import ValidationError, validate
1313

14-
if sys.version_info < (3, 9):
15-
from importlib_resources import files
16-
else:
17-
from importlib.resources import files
18-
1914
from . import __bids_version__, __version__, utils
2015
from .types import Namespace
2116

@@ -183,7 +178,7 @@ def flatten_enums(namespace, inplace=True):
183178
return namespace
184179

185180

186-
@lru_cache()
181+
@lru_cache
187182
def load_schema(schema_path=None):
188183
"""Load the schema into a dictionary.
189184

tools/schemacode/src/bidsschematools/validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _bids_schema_versioncheck(schema_dir, compatibility=VALIDATOR_SCHEMA_COMPATI
4343

4444
schema_version_file = os.path.join(schema_dir, "SCHEMA_VERSION")
4545
try:
46-
with open(schema_version_file, "r") as f:
46+
with open(schema_version_file) as f:
4747
schema_version = f.readlines()[0].strip()
4848
except FileNotFoundError:
4949
lgr.warning(

0 commit comments

Comments
 (0)