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

Update dependencies #420

Merged
merged 3 commits into from
May 1, 2024
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
457 changes: 224 additions & 233 deletions poetry.lock

Large diffs are not rendered by default.

36 changes: 16 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ docutils = "!=0.21.post1"
pluggy = ">=1.3"

[tool.poetry.group.dev.dependencies]
pytest = "^7.0.0"
pytest = "^8"
pytest-mock = "^3.7.0"
poethepoet = "^0.25.1"
poethepoet = "^0.26"
pre-commit = "^3.0.0"
# a mkinit dep has the 'platform_system == "Windows"' as a marker on an incompatible dependeny
# (pydantic<2.0 cf copier), so set the inverse as a marker here so mkinit can
Expand All @@ -95,7 +95,7 @@ pathvalidate = "^3.0.0"
# Bug in .358 preventing the types from the converter arguments of attrs classes to
# propogate properly
pyright = "^1.1.339,<1.1.358"
ruff = "^0.1.7"
ruff = "^0.4"
pytest-xdist = "^3.3.1"
pytest-split = "^0.8.1"
tomli = "^2.0.1"
Expand All @@ -107,9 +107,9 @@ docstring-parser = "^0.16"
[tool.poetry.group.docs.dependencies]
sphinx = "^7"
sphinx-argparse = "^0.4.0"
sphinxcontrib-asciinema = "^0.3.8"
myst-parser = "^2.0.0"
furo = "^2023.9.10"
sphinxcontrib-asciinema = "^0.4"
myst-parser = "^3"
furo = "^2024.4.27"
sphinx-copybutton = "^0.5.2"
sphinx-reredirects = "^0.1.3"
sphinx-design = "^0.5.0"
Expand Down Expand Up @@ -152,15 +152,11 @@ docs = "sphinx-autobuild docs build/docs --watch snakebids -W"
script = "scripts.update_bids:main"
[[tool.poe.tasks.update-bids.sequence]]
ref = "mkinit"
[[tool.poe.tasks.update-bids.sequence]]
ref = "fmt"

[[tool.poe.tasks.mkinit.sequence]]
cmd = "mkinit --recursive --nomods --lazy_loader_typed --relative -i snakebids"
[[tool.poe.tasks.mkinit.sequence]]
ref = "sort snakebids/**/__init__.py*"
[[tool.poe.tasks.mkinit.sequence]]
ref = "fmt snakebids/**/__init__.py*"
ref = "fix"

[tool.poe.tasks._get_version]
imports = ["platform"]
Expand All @@ -178,6 +174,7 @@ cmd = """
[tool.pytest.ini_options]
markers = [
"docker: marks tests as requiring docker (deselect with '-m \"not docker\"')",
"disable_fakefs: disable the fake filesystem in a hypothesis test"
]

[tool.coverage.run]
Expand All @@ -204,6 +201,9 @@ reportPrivateUsage = false
reportImportCycles = false

[tool.ruff]
target-version = "py38"

[tool.ruff.lint]
select = [
"E", # pycodestyle error
"W", # pycodestyle warning
Expand Down Expand Up @@ -267,11 +267,7 @@ ignore = [
"ISC002",
]


target-version = "py38"


[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"snakebids/project_template/**" = ["N999"]
"snakebids/tests/**" = [
"D",
Expand All @@ -280,14 +276,14 @@ target-version = "py38"
"SLF",
]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
convention = "numpy"
ignore-decorators = ["snakebids.utils.utils.property_alias"]

[tool.ruff.flake8-builtins]
[tool.ruff.lint.flake8-builtins]
builtins-ignorelist = ["filter"]

[tool.ruff.flake8-import-conventions.extend-aliases]
[tool.ruff.lint.flake8-import-conventions.extend-aliases]
itertools = "it"
functools = "ft"
operator = "op"
Expand All @@ -300,5 +296,5 @@ more_itertools = "itx"
"snakebids.tests.strategies" = "sb_st"
"snakebids.utils.sb_itertools" = "sb_it"

[tool.ruff.flake8-pytest-style]
[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
1 change: 1 addition & 0 deletions scripts/update_bids.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Recompile the bids function stub file based on latest specs."""

from __future__ import annotations

import inspect
Expand Down
1 change: 1 addition & 0 deletions snakebids/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
bidsapp.app([plugins.SnakemakeBidsApp(...)])

"""

from __future__ import annotations

import logging
Expand Down
6 changes: 2 additions & 4 deletions snakebids/core/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,10 @@ def __repr__(self) -> str:
return self.pformat()

@overload
def __getitem__(self, key: str, /) -> BidsComponentRow:
...
def __getitem__(self, key: str, /) -> BidsComponentRow: ...

@overload
def __getitem__(self, key: tuple[str, ...], /) -> BidsPartialComponent:
...
def __getitem__(self, key: tuple[str, ...], /) -> BidsPartialComponent: ...

def __getitem__(
self, key: str | tuple[str, ...], /
Expand Down
6 changes: 2 additions & 4 deletions snakebids/core/filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def filter_list(
filters: Mapping[str, Iterable[str] | str],
return_indices_only: Literal[False] = ...,
regex_search: bool = ...,
) -> ZipList:
...
) -> ZipList: ...


@overload
Expand All @@ -27,8 +26,7 @@ def filter_list(
filters: Mapping[str, Iterable[str] | str],
return_indices_only: Literal[True],
regex_search: bool = ...,
) -> list[int]:
...
) -> list[int]: ...


def filter_list(
Expand Down
7 changes: 3 additions & 4 deletions snakebids/core/input_generation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for converting Snakemake apps to BIDS apps."""

from __future__ import annotations

import json
Expand Down Expand Up @@ -60,8 +61,7 @@ def generate_inputs(
validate: bool = ...,
pybids_database_dir: Path | str | None = ...,
pybids_reset_database: bool = ...,
) -> BidsDataset:
...
) -> BidsDataset: ...


@overload
Expand All @@ -80,8 +80,7 @@ def generate_inputs(
validate: bool = ...,
pybids_database_dir: Path | str | None = ...,
pybids_reset_database: bool = ...,
) -> BidsDatasetDict:
...
) -> BidsDatasetDict: ...


def generate_inputs(
Expand Down
1 change: 1 addition & 0 deletions snakebids/io/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""

from __future__ import annotations

import functools as ft
Expand Down
2 changes: 1 addition & 1 deletion snakebids/jinja2_ext/toml_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def toml_string(item: str):
Technically encodes as json, a (mostly) strict subset of toml, with some encoding
fixes
"""
return json.dumps(item, ensure_ascii=False).replace("\x7F", "\\u007f")
return json.dumps(item, ensure_ascii=False).replace("\x7f", "\\u007f")


def toml_encode(item: str):
Expand Down
3 changes: 1 addition & 2 deletions snakebids/paths/_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def __call__(
suffix: str | None = None,
extension: str | None = None,
**entities: str | bool,
) -> str:
...
) -> str: ...


def _handle_subses_dir(
Expand Down
3 changes: 0 additions & 3 deletions snakebids/paths/specs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def v0_0_0(subject_dir: bool = True, session_dir: bool = True) -> BidsPathSpec:
If False, downstream path generator will not include the session dir
`*/ses-{session}/*`
"""
...

def v0_11_0(subject_dir: bool = True, session_dir: bool = True) -> BidsPathSpec:
"""Spec corresponding to `BIDS v1.9.0`_.
Expand Down Expand Up @@ -67,7 +66,6 @@ def v0_11_0(subject_dir: bool = True, session_dir: bool = True) -> BidsPathSpec:
If False, downstream path generator will not include the session dir
`*/ses-{session}/*`
"""
...

def latest(subject_dir: bool = True, session_dir: bool = True) -> BidsPathSpec:
"""Spec corresponding to `BIDS v1.9.0`_.
Expand Down Expand Up @@ -101,4 +99,3 @@ def latest(subject_dir: bool = True, session_dir: bool = True) -> BidsPathSpec:
If False, downstream path generator will not include the session dir
`*/ses-{session}/*`
"""
...
6 changes: 2 additions & 4 deletions snakebids/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,10 @@ class PluginBase:
PREFIX = ""

@overload
def pop(self, mapping: dict[str, Any], key: str, default: Any, /) -> Any:
...
def pop(self, mapping: dict[str, Any], key: str, default: Any, /) -> Any: ...

@overload
def pop(self, mapping: dict[str, Any], key: str, /) -> Any:
...
def pop(self, mapping: dict[str, Any], key: str, /) -> Any: ...

def pop(self, mapping: dict[str, Any], *args: Any):
"""Remove specified key from mapping, prepending the plugin prefix."""
Expand Down
6 changes: 3 additions & 3 deletions snakebids/plugins/pybidsdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ def update_cli_namespace(self, namespace: dict[str, Any], config: dict[str, Any]
if config["pybidsdb_dir"] is not None
else None
)
config[
"pybids_db_reset"
] = f"{DEPRECATION_FLAG}{int(config['pybidsdb_reset'])}{DEPRECATION_FLAG}"
config["pybids_db_reset"] = (
f"{DEPRECATION_FLAG}{int(config['pybidsdb_reset'])}{DEPRECATION_FLAG}"
)
6 changes: 2 additions & 4 deletions snakebids/plugins/snakemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ def wrapper(self: SnakemakeBidsApp):


@overload
def _resolve_path(path_candidate: Sequence[Any]) -> list[Any]:
...
def _resolve_path(path_candidate: Sequence[Any]) -> list[Any]: ...


@overload
def _resolve_path(path_candidate: _T) -> _T:
...
def _resolve_path(path_candidate: _T) -> _T: ...


def _resolve_path(path_candidate: Any) -> Any:
Expand Down
1 change: 0 additions & 1 deletion snakebids/snakemake_compat.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def expand(
with their values as lists. If allow_missing=True is included
wildcards in filepattern without values will stay unformatted.
"""
...

class Namedlist[T](list[T | Iterable[T]]): ...

Expand Down
11 changes: 6 additions & 5 deletions snakebids/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Helper functions and classes for tests"""

from __future__ import annotations

import functools as ft
Expand All @@ -24,9 +25,10 @@
from hypothesis import HealthCheck, example, settings
from typing_extensions import ParamSpec

from snakebids import bids
from snakebids import bids_factory
from snakebids.core.datasets import BidsDataset
from snakebids.core.input_generation import generate_inputs
from snakebids.paths import specs
from snakebids.types import InputsConfig, ZipList, ZipListLike
from snakebids.utils.containers import MultiSelectDict, UserDictPy38
from snakebids.utils.utils import BidsEntity
Expand Down Expand Up @@ -102,6 +104,7 @@ def get_bids_path(entities: Iterable[str | BidsEntity], **extras: str) -> str:
def get_tag(entity: BidsEntity) -> tuple[str, str]:
return entity.wildcard, f"{{{entity.wildcard}}}"

bids = bids_factory(specs.latest())
return bids(
**dict(get_tag(BidsEntity(entity)) for entity in sorted(entities)),
**{BidsEntity(entity).wildcard: value for entity, value in extras.items()},
Expand Down Expand Up @@ -339,16 +342,14 @@ def inner(func: Callable[_P, _T]) -> Callable[_P, _T]:
class Benchmark(Protocol):
def __call__(
self, func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs
) -> _T:
...
) -> _T: ...


"""Comparison Dunders copied from typeshed"""


class SupportsDunderLT(Protocol[_T_contra]):
def __lt__(self, __other: _T_contra) -> bool:
...
def __lt__(self, __other: _T_contra) -> bool: ...


def is_strictly_increasing(items: Iterable[SupportsDunderLT[Any]]) -> bool:
Expand Down
6 changes: 2 additions & 4 deletions snakebids/tests/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,9 @@ def multiselect_dicts(

if TYPE_CHECKING:

def everything() -> st.SearchStrategy[Any]:
...
def everything() -> st.SearchStrategy[Any]: ...

def everything_except(*excluded_types: type[Any]) -> st.SearchStrategy[Any]:
...
def everything_except(*excluded_types: type[Any]) -> st.SearchStrategy[Any]: ...

else:

Expand Down
26 changes: 17 additions & 9 deletions snakebids/tests/test_generate_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,23 @@ def test_second_return_never_none(
pybidsdb_reset: bool | None,
pybids_database_reset: bool | None,
):
assert (
_normalize_database_args(
None,
pybidsdb_reset,
None,
pybids_database_reset,
)[1]
is not None
)
with warnings.catch_warnings():
warnings.filterwarnings(
"ignore",
message=r"The parameter `pybids_reset_database` in generate_inputs\(\) "
"is deprecated and will be removed in the next release. To reset the "
"pybids database, use the `pybidsdb_reset` parameter instead",
category=UserWarning,
)
assert (
_normalize_database_args(
None,
pybidsdb_reset,
None,
pybids_database_reset,
)[1]
is not None
)

@given(pybidsdb_dir=st.text().filter(_not_deprecated))
def test_deprecated_dir_raises_warning(self, pybidsdb_dir: str):
Expand Down
1 change: 1 addition & 0 deletions snakebids/tests/test_snakemake_io.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests for snakemake_io"""

from snakebids.utils import snakemake_io


Expand Down
Loading