diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d8c075..02ca4db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: '^docs/conf.py' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: check-added-large-files @@ -18,22 +18,22 @@ repos: args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows - repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 + rev: v1.7.8 hooks: - id: docformatter additional_dependencies: [tomli] args: [--in-place, --wrap-descriptions=120, --wrap-summaries=120] # --config, ./pyproject.toml -- repo: https://github.com/psf/black - rev: 23.9.1 +- repo: https://github.com/psf/black-pre-commit-mirror + rev: 26.5.1 hooks: - id: black language_version: python3 - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.0.287 + rev: v0.16.2 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/setup.py b/setup.py index 6829222..9271379 100644 --- a/setup.py +++ b/setup.py @@ -1,15 +1,16 @@ -"""Setup file for biocborn. Use setup.cfg to configure your project. +"""Setup file for biocborn. -This file was generated with PyScaffold 4.5. -PyScaffold helps you to put up the scaffold of your new Python project. -Learn more under: https://pyscaffold.org/ +Use setup.cfg to configure your project. This file was generated with PyScaffold 4.5. PyScaffold helps you to put up the +scaffold of your new Python project. Learn more under: +https://pyscaffold.org/ """ + from setuptools import setup if __name__ == "__main__": try: setup(use_scm_version={"version_scheme": "no-guess-dev"}) - except: # noqa + except: print( "\n\nAn error occurred while building the project, " "please ensure you have the most updated version of setuptools, " diff --git a/src/biocborn/_checks.py b/src/biocborn/_checks.py index 67e5835..d5b8f73 100644 --- a/src/biocborn/_checks.py +++ b/src/biocborn/_checks.py @@ -1,4 +1,5 @@ -from typing import Any, Callable +from collections.abc import Callable +from typing import Any __author__ = "jkanche" __copyright__ = "jkanche" diff --git a/src/biocborn/heatmap.py b/src/biocborn/heatmap.py index 6052ce6..40f001d 100644 --- a/src/biocborn/heatmap.py +++ b/src/biocborn/heatmap.py @@ -1,5 +1,5 @@ +from collections.abc import Sequence from functools import singledispatch -from typing import Optional, Sequence, Union from biocframe import BiocFrame from matplotlib.axes import Axes @@ -26,9 +26,9 @@ def _heatmap_plot(x, kwargs) -> Axes: @singledispatch def plot_heatmap( x, - features: Optional[Union[str, Sequence]] = None, - annotations: Optional[Union[str, Sequence]] = None, - assay_name: Optional[str] = None, + features: str | Sequence | None = None, + annotations: str | Sequence | None = None, + assay_name: str | None = None, **kwargs, ): """Plot a heatmap. A wrapper around seaborn's @@ -96,9 +96,9 @@ def _plot_heatmap_df(x: DataFrame, **kwargs): @plot_heatmap.register def _plot_heatmap_sce( x: SingleCellExperiment, - features: Optional[Union[str, Sequence]] = None, - annotations: Optional[Union[str, Sequence]] = None, - assay_name: Optional[str] = None, + features: str | Sequence | None = None, + annotations: str | Sequence | None = None, + assay_name: str | None = None, **kwargs, ): if assay_name is None: diff --git a/src/biocborn/reduced_dims.py b/src/biocborn/reduced_dims.py index ee7c6b5..125c596 100644 --- a/src/biocborn/reduced_dims.py +++ b/src/biocborn/reduced_dims.py @@ -1,5 +1,5 @@ +from collections.abc import Sequence from functools import singledispatch -from typing import Optional, Sequence, Union from warnings import warn from numpy import ndarray @@ -28,11 +28,11 @@ def _dim_plot(x: ArrayLike, y: ArrayLike, kwargs) -> FacetGrid: @singledispatch def plot_reduced_dim( x, - dimred: Optional[str] = None, - color_by: Optional[Union[str, Sequence]] = None, - size_by: Optional[Union[str, Sequence]] = None, - shape_by: Optional[Union[str, Sequence]] = None, - assay_name: Optional[Union[str, Sequence]] = None, + dimred: str | None = None, + color_by: str | Sequence | None = None, + size_by: str | Sequence | None = None, + shape_by: str | Sequence | None = None, + assay_name: str | Sequence | None = None, **kwargs, ) -> FacetGrid: """Plot cell-level reduced dimensions. @@ -111,9 +111,9 @@ def plot_reduced_dim( @plot_reduced_dim.register def _plot_reduced_dim_numpy( x: ndarray, - color_by: Optional[Sequence] = None, - size_by: Optional[Sequence] = None, - shape_by: Optional[Sequence] = None, + color_by: Sequence | None = None, + size_by: Sequence | None = None, + shape_by: Sequence | None = None, **kwargs, ) -> FacetGrid: NCELLS = x.shape[0] @@ -160,11 +160,11 @@ def _plot_reduced_dim_numpy( @plot_reduced_dim.register def _plot_reduced_dim_sce( x: SingleCellExperiment, - dimred: Optional[str] = None, - color_by: Optional[Union[str, Sequence]] = None, - size_by: Optional[Union[str, Sequence]] = None, - shape_by: Optional[Union[str, Sequence]] = None, - assay_name: Optional[Union[str, Sequence]] = None, + dimred: str | None = None, + color_by: str | Sequence | None = None, + size_by: str | Sequence | None = None, + shape_by: str | Sequence | None = None, + assay_name: str | Sequence | None = None, **kwargs, ) -> FacetGrid: if assay_name is None: diff --git a/src/biocborn/types.py b/src/biocborn/types.py index cf8268b..ae9e0c8 100644 --- a/src/biocborn/types.py +++ b/src/biocborn/types.py @@ -1,4 +1,5 @@ -from typing import Sequence, Union +from collections.abc import Sequence +from typing import Union from numpy import ndarray diff --git a/src/biocborn/utils.py b/src/biocborn/utils.py index bf9e4a2..603fdb7 100644 --- a/src/biocborn/utils.py +++ b/src/biocborn/utils.py @@ -1,5 +1,6 @@ from collections import namedtuple -from typing import Literal, Sequence, Tuple +from collections.abc import Sequence +from typing import Literal from biocframe import BiocFrame from numpy import int32, zeros @@ -29,7 +30,6 @@ def factorize(x: Sequence) -> FactorizedArray: Returns: FactorizedArray: A factorized tuple. """ - if not isinstance(x, list): raise TypeError("x is not a list") @@ -68,7 +68,7 @@ def _extract_variable_from_sce( assay: str, check_col_data: bool = True, check_row_data: bool = True, -) -> Tuple[Sequence, Literal["annotation", "gene"]]: +) -> tuple[Sequence, Literal["annotation", "gene"]]: """Extract a variable from :py:class:`~singlecellexperiment.SingleCellExperiment.SingleCellExperiment`. Variable ``var_value`` can either be a column in the