Skip to content

Commit

Permalink
[MNT] Drop python 3.9 and support python 3.13 (#343)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
mscheltienne and pre-commit-ci[bot] authored Oct 16, 2024
1 parent e74566d commit 59a221f
Show file tree
Hide file tree
Showing 44 changed files with 258 additions and 267 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.9, "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
Expand Down Expand Up @@ -110,7 +110,7 @@ jobs:
fail-fast: false
matrix:
mne-version: ["1.4.2", "1.5.0"]
python-version: [3.9]
python-version: ["3.10"]
name: mne compat ${{ matrix.mne-version }} - py${{ matrix.python-version }}
runs-on: ubuntu-latest
defaults:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ transmitted wirelessly. For more information about LSL, please visit the

# Install

MNE-LSL supports `python ≥ 3.9` and is available on
MNE-LSL supports `python ≥ 3.10` and is available on
[PyPI](https://pypi.org/project/mne-lsl/) and on
[conda-forge](https://anaconda.org/conda-forge/mne-lsl).
Install instruction can be found on the
Expand Down
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from datetime import date
from importlib import import_module
from pathlib import Path
from typing import Optional

import mne
from intersphinx_registry import get_intersphinx_mapping
Expand Down Expand Up @@ -210,7 +209,7 @@
# https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html


def linkcode_resolve(domain: str, info: dict[str, str]) -> Optional[str]:
def linkcode_resolve(domain: str, info: dict[str, str]) -> str | None:
"""Determine the URL corresponding to a Python object.
Parameters
Expand Down
2 changes: 1 addition & 1 deletion doc/resources/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Install
Default install
---------------

``MNE-LSL`` requires Python version ``3.9`` or higher and is available on
``MNE-LSL`` requires Python version ``3.10`` or higher and is available on
`PyPI <project pypi_>`_ and `conda-forge <project conda_>`_. It requires
`liblsl <lsl lib_>`_ which will be either fetch from the path in the environment
variable ``MNE_LSL_LIB`` (or ``PYLSL_LIB``), or from the system directories, or
Expand Down
2 changes: 2 additions & 0 deletions examples/10_peak_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
for raw_, label in zip(
(raw, raw_notched, raw_bandpassed, raw_lowpassed),
("raw", "notched", "bandpassed", "lowpassed"),
strict=True,
):
data, times = raw_[:, start:stop] # select 5 seconds
data -= data.mean() # detrend
Expand All @@ -97,6 +98,7 @@
for raw_, label in zip(
(raw, raw_notched, raw_bandpassed, raw_lowpassed),
("raw", "notched", "bandpassed", "lowpassed"),
strict=True,
):
data, times = raw_[:, start:stop] # select 5 seconds
data -= data.mean() # detrend
Expand Down
3 changes: 1 addition & 2 deletions mne_lsl/datasets/_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@

if TYPE_CHECKING:
from pathlib import Path
from typing import Union


def fetch_dataset(path: Path, base_url: str, registry: Union[str, Path]) -> Path:
def fetch_dataset(path: Path, base_url: str, registry: str | Path) -> Path:
"""Fetch a dataset from the remote.
Parameters
Expand Down
6 changes: 1 addition & 5 deletions mne_lsl/datasets/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@

from importlib.resources import files
from pathlib import Path
from typing import TYPE_CHECKING

import pooch
from mne.utils import get_config

from ..utils._checks import ensure_path
from ._fetch import fetch_dataset

if TYPE_CHECKING:
from typing import Optional, Union

_REGISTRY: Path = files("mne_lsl.datasets") / "sample-registry.txt"


def _make_registry(
folder: Union[str, Path], output: Optional[Union[str, Path]] = None
folder: str | Path, output: str | Path | None = None
) -> None: # pragma: no cover
"""Create the registry file for the sample dataset.
Expand Down
8 changes: 1 addition & 7 deletions mne_lsl/datasets/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@

from importlib.resources import files
from pathlib import Path
from typing import TYPE_CHECKING

import pooch
from mne.utils import get_config

from ..utils._checks import ensure_path
from ._fetch import fetch_dataset

if TYPE_CHECKING:
from typing import Optional, Union

_REGISTRY: Path = files("mne_lsl.datasets") / "testing-registry.txt"


def _make_registry(
folder: Union[str, Path], output: Optional[Union[str, Path]] = None
) -> None:
def _make_registry(folder: str | Path, output: str | Path | None = None) -> None:
"""Create the registry file for the testing dataset.
Parameters
Expand Down
6 changes: 1 addition & 5 deletions mne_lsl/datasets/tests/test_fetch.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
from __future__ import annotations

from pathlib import Path
from typing import TYPE_CHECKING

import pooch
import pytest

from mne_lsl.datasets._fetch import fetch_dataset

if TYPE_CHECKING:
from typing import Optional


@pytest.fixture
def license_file() -> Optional[Path]:
def license_file() -> Path | None:
"""Find the license file if present."""
fname = Path(__file__).parent.parent.parent.parent / "LICENSE"
if fname.exists():
Expand Down
3 changes: 1 addition & 2 deletions mne_lsl/lsl/_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ctypes import POINTER, c_int, c_void_p, cast
from typing import Optional

from .load_liblsl import lib

Expand Down Expand Up @@ -193,7 +192,7 @@ def free_char_p_array_memory(char_p_array): # noqa: D103


# -- Static checker -----------------------------------------------------------
def check_timeout(timeout: Optional[float]) -> float:
def check_timeout(timeout: float | None) -> float:
"""Check that the provided timeout is valid.
Parameters
Expand Down
12 changes: 4 additions & 8 deletions mne_lsl/lsl/functions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
from __future__ import annotations

from ctypes import byref, c_char_p, c_double, c_void_p
from typing import TYPE_CHECKING

from ..utils._checks import check_type, ensure_int
from .load_liblsl import lib
from .stream_info import _BaseStreamInfo

if TYPE_CHECKING:
from typing import Optional


def library_version() -> int:
"""Version of the binary LSL library.
Expand Down Expand Up @@ -55,9 +51,9 @@ def local_clock() -> float:

def resolve_streams(
timeout: float = 1.0,
name: Optional[str] = None,
stype: Optional[str] = None,
source_id: Optional[str] = None,
name: str | None = None,
stype: str | None = None,
source_id: str | None = None,
minimum: int = 1,
) -> list[_BaseStreamInfo]:
"""Resolve streams on the network.
Expand Down Expand Up @@ -116,7 +112,7 @@ def resolve_streams(
properties = [
# filter out the properties set to None
(prop, name)
for prop, name in zip(properties, ("name", "stype", "source_id"))
for prop, name in zip(properties, ("name", "stype", "source_id"), strict=True)
if prop is not None
]
timeout /= len(properties)
Expand Down
14 changes: 6 additions & 8 deletions mne_lsl/lsl/load_liblsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
from ..utils.logs import logger, warn

if TYPE_CHECKING:
from typing import Optional, Union

from pooch import Pooch


Expand Down Expand Up @@ -71,7 +69,7 @@ def load_liblsl() -> CDLL:
return _set_types(lib)


def _load_liblsl_environment_variables() -> Optional[str]:
def _load_liblsl_environment_variables() -> str | None:
"""Load the binary LSL library from the environment variables.
Returns
Expand Down Expand Up @@ -101,7 +99,7 @@ def _load_liblsl_environment_variables() -> Optional[str]:
return None


def _load_liblsl_system() -> Optional[str]:
def _load_liblsl_system() -> str | None:
"""Load the binary LSL library from the system path/folders.
Returns
Expand All @@ -128,7 +126,7 @@ def _load_liblsl_system() -> Optional[str]:
return None


def _load_liblsl_mne_lsl(*, folder: Path = _LIB_FOLDER) -> Optional[str]:
def _load_liblsl_mne_lsl(*, folder: Path = _LIB_FOLDER) -> str | None:
"""Load the binary LSL library from the system path/folders.
Parameters
Expand Down Expand Up @@ -173,7 +171,7 @@ def _load_liblsl_mne_lsl(*, folder: Path = _LIB_FOLDER) -> Optional[str]:

def _fetch_liblsl(
*,
folder: Union[str, Path] = _LIB_FOLDER,
folder: str | Path = _LIB_FOLDER,
url: str = "https://api.github.com/repos/sccn/liblsl/releases/latest",
) -> str:
"""Fetch liblsl on the release page.
Expand Down Expand Up @@ -420,8 +418,8 @@ def _is_valid_libpath(libpath: str) -> bool:


def _attempt_load_liblsl(
libpath: Union[str, Path], *, issue_warning: bool = True
) -> tuple[str, Optional[int]]:
libpath: str | Path, *, issue_warning: bool = True
) -> tuple[str, int | None]:
"""Try loading a binary LSL library.
Parameters
Expand Down
Loading

0 comments on commit 59a221f

Please sign in to comment.