Skip to content

Commit d9ebe1f

Browse files
authored
Merge pull request #25 from effigies/mnt/cleanup
chore: Cleanups unrelated to context
2 parents 7b8b72a + a354d5a commit d9ebe1f

File tree

6 files changed

+52
-34
lines changed

6 files changed

+52
-34
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,8 @@ jobs:
8383
python-version: ${{ matrix.python-version }}
8484
allow-prereleases: true
8585

86-
- name: Install git-annex ubuntu
87-
if: matrix.os == 'ubuntu-latest'
88-
run: sudo apt-get update && sudo apt-get install git-annex
89-
90-
- name: Install git-annex macos
91-
if: matrix.os == 'macos-latest'
92-
run: brew install git-annex
93-
94-
- name: Install git-annex windows
95-
if: matrix.os == 'windows-latest'
96-
uses: crazy-max/ghaction-chocolatey@v3
97-
with:
98-
args: install git-annex --yes --ignore-checksums
99-
continue-on-error: true # This can fail for stupid reasons ¯\_(ツ)_/¯
86+
- name: Install git-annex
87+
run: uv tool install git-annex
10088

10189
- name: Show software versions
10290
run: |

pyproject.toml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,11 @@ classifiers = [
2222
]
2323
requires-python = ">=3.9"
2424
dependencies = [
25-
"bidsschematools >=1.0",
25+
"attrs >=24.1",
26+
"bidsschematools >= 1.0.10",
2627
]
2728

2829
[project.optional-dependencies]
29-
test = [
30-
"pytest >=8",
31-
"pytest-cov >=5",
32-
"coverage[toml] >=7.2",
33-
"datalad >=1.1",
34-
]
3530
cli = [
3631
"typer >=0.15",
3732
]
@@ -97,7 +92,10 @@ exclude = ".*"
9792

9893
[tool.ruff]
9994
line-length = 99
100-
extend-exclude = ["_version.py"]
95+
extend-exclude = [
96+
"_version.py",
97+
"tests/data",
98+
]
10199

102100
[tool.ruff.lint]
103101
extend-select = [
@@ -136,7 +134,19 @@ inline-quotes = "single"
136134

137135
[tool.ruff.lint.extend-per-file-ignores]
138136
"setup.py" = ["D"]
139-
"*/test_*.py" = ["S101"]
137+
"*/test_*.py" = [
138+
"S101",
139+
"D",
140+
]
140141

141142
[tool.ruff.format]
142143
quote-style = "single"
144+
145+
[dependency-groups]
146+
test = [
147+
"pytest >=8",
148+
"pytest-cov >=5",
149+
"coverage[toml] >=7.2",
150+
"datalad >=1.1",
151+
"cattrs>=24.1.3",
152+
]

src/bids_validator/types/_typings.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
__all__ = (
2+
'Self',
3+
'TYPE_CHECKING',
4+
'Any',
5+
)
6+
7+
TYPE_CHECKING = False
8+
if TYPE_CHECKING:
9+
from typing import Any, Self
10+
else:
11+
12+
def __getattr__(name: str):
13+
if name in __all__:
14+
import typing
15+
16+
return getattr(typing, name)
17+
18+
msg = f'Module {__name__!r} has no attribute {name!r}'
19+
raise AttributeError(msg)

src/bids_validator/types/files.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
"""Types for working with file trees."""
22

3+
from __future__ import annotations
4+
35
import os
46
import posixpath
57
import stat
68
from functools import cached_property
79
from pathlib import Path
8-
from typing import Union
910

1011
import attrs
11-
from typing_extensions import Self # PY310
12+
13+
from . import _typings as t
1214

1315
__all__ = ('FileTree',)
1416

@@ -58,7 +60,7 @@ def is_symlink(self) -> bool:
5860
return stat.S_ISLNK(_stat.st_mode)
5961

6062

61-
def as_direntry(obj: os.PathLike) -> Union[os.DirEntry, UserDirEntry]:
63+
def as_direntry(obj: os.PathLike) -> os.DirEntry | UserDirEntry:
6264
"""Convert PathLike into DirEntry-like object."""
6365
if isinstance(obj, os.DirEntry):
6466
return obj
@@ -69,10 +71,10 @@ def as_direntry(obj: os.PathLike) -> Union[os.DirEntry, UserDirEntry]:
6971
class FileTree:
7072
"""Represent a FileTree with cached metadata."""
7173

72-
direntry: Union[os.DirEntry, UserDirEntry] = attrs.field(repr=False, converter=as_direntry)
73-
parent: Union['FileTree', None] = attrs.field(repr=False, default=None)
74+
direntry: os.DirEntry | UserDirEntry = attrs.field(repr=False, converter=as_direntry)
75+
parent: FileTree | None = attrs.field(repr=False, default=None)
7476
is_dir: bool = attrs.field(default=False)
75-
children: dict[str, 'FileTree'] = attrs.field(repr=False, factory=dict)
77+
children: dict[str, FileTree] = attrs.field(repr=False, factory=dict)
7678
name: str = attrs.field(init=False)
7779

7880
def __attrs_post_init__(self):
@@ -85,8 +87,8 @@ def __attrs_post_init__(self):
8587
def read_from_filesystem(
8688
cls,
8789
direntry: os.PathLike,
88-
parent: Union['FileTree', None] = None,
89-
) -> Self:
90+
parent: FileTree | None = None,
91+
) -> t.Self:
9092
"""Read a FileTree from the filesystem.
9193
9294
Uses :func:`os.scandir` to walk the directory tree.

tests/types/test_files.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# ruff: noqa: D100
2-
31
import attrs
42

53
from bids_validator.types.files import FileTree

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ pass_env =
4545
CLICOLOR
4646
CLICOLOR_FORCE
4747
extras =
48-
test
4948
cli
49+
dependency_groups =
50+
test
5051
uv_resolution =
5152
min: lowest-direct
5253
deps =

0 commit comments

Comments
 (0)