Skip to content
Draft
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
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mypy:
# Optionally test with pyright (we don't aim yet)
[group('qa')]
pyright:
uv run --python 3.12 --extra all --with pyright pyright
uv run --extra all --with pyright pyright

# Run all the pre-commit checks on the whole code-base
pre-commit:
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies = [
"click>=8.1.8",
"narwhals>=2.0.1",
"rich>=14.1.0",
"basedpyright>=1.39.9",
]

[dependency-groups]
Expand Down Expand Up @@ -74,6 +75,10 @@ ignore_missing_imports = true
# plugins = ["numpy.typing.mypy_plugin"]
exclude = ["docs"]

[tool.pyright]
reportImplicitOverride = false
reportExplicitAny = false

[tool.isort]
profile = "black"

Expand Down
12 changes: 5 additions & 7 deletions src/physt/_bin_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import numpy as np

if TYPE_CHECKING:
from typing import Optional, Tuple, Union

from typing_extensions import Literal

from physt.typing_aliases import ArrayLike
Expand Down Expand Up @@ -68,7 +66,7 @@ def to_numpy_bins(bins: ArrayLike) -> np.ndarray:
return np.concatenate([bins[:1, 0], bins[:, 1]])


def to_numpy_bins_with_mask(bins: ArrayLike) -> Tuple[np.ndarray, np.ndarray]:
def to_numpy_bins_with_mask(bins: ArrayLike) -> tuple[np.ndarray, np.ndarray]:
"""Numpy binning edges including gaps.

Parameters
Expand All @@ -90,9 +88,9 @@ def to_numpy_bins_with_mask(bins: ArrayLike) -> Tuple[np.ndarray, np.ndarray]:
"""
bins = np.asarray(bins)
if bins.ndim == 1:
edges_: Union[np.ndarray, list] = bins
edges_: np.ndarray | list[float] = bins
if bins.shape[0] > 1:
mask_: Union[np.ndarray, list] = np.arange(bins.shape[0] - 1)
mask_: np.ndarray | list[int] = np.arange(bins.shape[0] - 1)
else:
mask_ = []
elif bins.ndim == 2:
Expand Down Expand Up @@ -135,7 +133,7 @@ def is_rising(bins: ArrayLike) -> bool:
return True


def is_consecutive(bins: ArrayLike, rtol: float = 1.0e-5, atol: float = 1.0e-8) -> bool:
def is_consecutive(bins: ArrayLike, *, rtol: float = 1.0e-5, atol: float = 1.0e-8) -> bool:
"""Check whether the bins are consecutive (edges match).

Does not check if the bins are in rising order.
Expand Down Expand Up @@ -209,7 +207,7 @@ def find_pretty_width_24(raw_width: float) -> int:


def find_pretty_width(
raw_width: float, kind: Optional[Literal["time"]] = None
raw_width: float, kind: Literal["time"] | None = None
) -> float:
"""Find the best pretty width close to a given raw_width."""
# TODO: Deal with infinity
Expand Down
6 changes: 3 additions & 3 deletions src/physt/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from typing import Any, Callable, Dict, Tuple
from typing import Any, Callable


def all_subclasses(cls: type) -> Tuple[type, ...]:
def all_subclasses(cls: type) -> tuple[type, ...]:
"""All subclasses of a class.

From: http://stackoverflow.com/a/17246726/2692780
Expand All @@ -41,7 +41,7 @@ def find_subclass(base: type, name: str) -> type:
return class_candidates[0]


def pop_many(a_dict: Dict[str, Any], *args: str, **kwargs) -> Dict[str, Any]:
def pop_many(a_dict: dict[str, Any], *args: str, **kwargs) -> dict[str, Any]:
"""Pop multiple items from a dictionary.

Parameters
Expand Down
Loading
Loading