Skip to content

Commit

Permalink
Update template to v0.3.1 (#806)
Browse files Browse the repository at this point in the history
Co-authored-by: scverse-bot <None>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Philipp A <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2024
1 parent 0485aef commit 3d0aa0b
Show file tree
Hide file tree
Showing 68 changed files with 218 additions and 298 deletions.
7 changes: 4 additions & 3 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/scverse/cookiecutter-scverse",
"commit": "8e96abb5c3e2d5078c44713958da672711cf2a48",
"checkout": "v0.3.0",
"commit": "586b1652162ff7994b0070a034023d64289ae416",
"checkout": "v0.3.1",
"context": {
"cookiecutter": {
"project_name": "squidpy",
Expand All @@ -13,7 +13,8 @@
"project_repo": "https://github.com/scverse/squidpy",
"license": "BSD 3-Clause License",
"_copy_without_render": [
".github/workflows/**.yaml",
".github/workflows/build.yaml",
".github/workflows/test.yaml",
"docs/_templates/autosummary/**.rst"
],
"_render_devdocs": false,
Expand Down
13 changes: 3 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ repos:
- id: mypy
additional_dependencies: [numpy, pandas, types-requests]
exclude: .scripts/ci/download_data.py|squidpy/datasets/_(dataset|image).py # See https://github.com/pre-commit/mirrors-mypy/issues/33
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
additional_dependencies: [toml]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down Expand Up @@ -50,16 +45,14 @@ repos:
- id: script-must-have-extension
name: Check executable files use .sh extension
types: [shell, executable]
- repo: https://github.com/asottile/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.2
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format
types_or: [python, pyi, jupyter]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down
2 changes: 2 additions & 0 deletions .scripts/ci/download_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python3
from __future__ import annotations

import argparse
from pathlib import Path
from typing import Any
Expand Down
4 changes: 3 additions & 1 deletion docs/_ext/typed_returns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import re
from typing import Iterable, Iterator, List
from collections.abc import Iterable, Iterator

from sphinx.application import Sphinx
from sphinx.ext.napoleon import NumpyDocstring
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from __future__ import annotations

# -- Path setup --------------------------------------------------------------
import os
import sys
Expand Down
10 changes: 6 additions & 4 deletions docs/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import annotations

import os
import re
from logging import info, warning
from pathlib import Path
from shutil import copytree, rmtree
from tempfile import TemporaryDirectory
from typing import Any, Dict, ForwardRef, List, Union
from typing import Any, ForwardRef

from enchant.tokenize import Filter
from git import Repo
Expand All @@ -14,7 +16,7 @@


def _fetch_notebooks(repo_url: str) -> None:
def copy_files(repo_path: Union[str, Path]) -> None:
def copy_files(repo_path: str | Path) -> None:
repo_path = Path(repo_path)

for dirname in ["tutorials", "auto_examples", "gen_modules"]:
Expand All @@ -30,7 +32,7 @@ def fetch_remote(repo_url: str) -> None:

copy_files(repo_dir)

def fetch_local(repo_path: Union[str, Path]) -> None:
def fetch_local(repo_path: str | Path) -> None:
info(f"Fetching notebooks from local path `{repo_path}`")
repo_path = Path(repo_path)
if not repo_path.is_dir():
Expand Down Expand Up @@ -75,7 +77,7 @@ def run(self) -> list[str]:
return []


def _get_thumbnails(root: Union[str, Path]) -> dict[str, str]:
def _get_thumbnails(root: str | Path) -> dict[str, str]:
res = {}
root = Path(root)
thumb_path = Path(__file__).parent.parent.parent / "docs" / "source"
Expand Down
93 changes: 23 additions & 70 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -117,65 +117,11 @@ include-package-data = true

[tool.setuptools_scm]

[tool.black]
line-length = 120
target-version = ['py39']
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
)
'''

[tool.isort]
profile = "black"
py_version = "38"
skip = "docs/source/conf.py,.tox,build"
line_length = 88
multi_line_output = 3
include_trailing_comma = true
use_parentheses = true
known_stdlib = "joblib"
known_bio = "anndata,scanpy"
known_num = "numpy,numba,scipy,sklearn,statsmodels,pandas,xarray,dask"
known_plot = "matplotlib,seaborn,napari"
known_gui = "PyQt5,superqt"
known_img = "skimage,tifffile,dask_image"
known_graph = "networkx"
sections = "FUTURE,STDLIB,THIRDPARTY,BIO,NUM,GUI,PLOT,IMG,GRAPH,FIRSTPARTY,LOCALFOLDER"
no_lines_before="LOCALFOLDER"
balanced_wrapping = true
force_grid_wrap = 0
length_sort = "1"
indent = " "
from_first = true
order_by_type = true
atomic = true
combine_star = true
combine_as_imports = true
honor_noqa = true
remove_redundant_aliases = true
only_modified = true
group_by_package = true
force_alphabetical_sort_within_sections = true
lexicographical = true

[tool.hatch.version]
source = "vcs"

[tool.ruff]
line-length = 120
exclude = [
".git",
".tox",
Expand All @@ -185,8 +131,13 @@ exclude = [
"dist",
"setup.py"
]

[tool.ruff.format]
docstring-code-format = true

[tool.ruff.lint]
ignore = [
# line too long -> we accept long comment lines; black gets rid of long code lines
# line too long -> we accept long comment lines; formatter gets rid of long code lines
"E501",
# Do not assign a lambda expression, use a def -> lambda expression assignments are convenient
"E731",
Expand Down Expand Up @@ -243,7 +194,6 @@ ignore = [
# "E111",
# "E114",
]
line-length = 120
select = [
"I", # isort
"E", # pycodestyle
Expand All @@ -255,19 +205,22 @@ select = [
"B", # flake8-bugbear
"BLE", # flake8-blind-except
]
unfixable = ["B", "UP", "C4", "BLE"]
target-version = "py38"
[tool.ruff.per-file-ignores]
"*/__init__.py" = ["D104", "F401"]
"tests/*"= ["D"]
"docs/*"= ["D","B"]
"squidpy/pl/_ligrec.py"= ["D","B"]
"squidpy/_constants/_pkg_constants.py"= ["D101","D102","D106"]
"squidpy/_constants/_constants.py"= ["D101"]
"squidpy/pl/_interactive/_widgets.py"= ["D"]
".scripts/ci/download_data.py"= ["D","B"]
# "squidpy/*.py"= ["RST303"]
unfixable = ["B", "C4", "BLE"]

[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]

[tool.ruff.lint.per-file-ignores]
"*/__init__.py" = ["D104", "F401"]
"tests/*"= ["D"]
"docs/*"= ["D","B"]
"squidpy/pl/_ligrec.py"= ["D","B"]
"squidpy/_constants/_pkg_constants.py"= ["D101","D102","D106"]
"squidpy/_constants/_constants.py"= ["D101"]
"squidpy/pl/_interactive/_widgets.py"= ["D"]
".scripts/ci/download_data.py"= ["D","B"]
# "squidpy/*.py"= ["RST303"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
# Disallow all relative imports.
ban-relative-imports = "all"
2 changes: 2 additions & 0 deletions src/squidpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from importlib import metadata

from squidpy import datasets, gr, im, pl, read, tl
Expand Down
2 changes: 2 additions & 0 deletions src/squidpy/_constants/_constants.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Constants that user deals with."""

from __future__ import annotations

from enum import unique

from squidpy._constants._utils import ModeEnum
Expand Down
3 changes: 2 additions & 1 deletion src/squidpy/_constants/_pkg_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from __future__ import annotations

from typing import Any, Callable, Mapping, Optional, Sequence, Union
from collections.abc import Callable, Mapping, Sequence
from typing import Any

from anndata import AnnData

Expand Down
7 changes: 5 additions & 2 deletions src/squidpy/_constants/_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from __future__ import annotations

from abc import ABC, ABCMeta
from collections.abc import Mapping
from enum import Enum, EnumMeta
from functools import wraps
from typing import Any, Callable, Mapping, Tuple
from typing import Any, Callable


def _pretty_raise_enum(cls: type[ModeEnum], fun: Callable[..., Any]) -> Callable[..., Any]:
Expand Down Expand Up @@ -33,7 +34,9 @@ class ErrorFormatterABC(ABC):
@classmethod
def _format(cls, value: Enum) -> str:
return cls.__error_format__.format(
value, cls.__name__, [m.value for m in cls.__members__.values()] # type: ignore[attr-defined]
value,
cls.__name__,
[m.value for m in cls.__members__.values()], # type: ignore[attr-defined]
)


Expand Down
12 changes: 2 additions & 10 deletions src/squidpy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,13 @@
import functools
import inspect
import warnings
from collections.abc import Generator, Hashable, Iterable, Sequence
from contextlib import contextmanager
from enum import Enum
from multiprocessing import Manager, cpu_count
from queue import Queue
from threading import Thread
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Hashable,
Iterable,
Sequence,
Union, # noqa: F401
)
from typing import TYPE_CHECKING, Any, Callable

import joblib as jl
import numpy as np
Expand Down
2 changes: 2 additions & 0 deletions src/squidpy/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from squidpy.datasets._10x_datasets import visium
from squidpy.datasets._dataset import * # noqa: F403
from squidpy.datasets._image import * # noqa: F403
2 changes: 2 additions & 0 deletions src/squidpy/datasets/_dataset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from copy import copy

from squidpy.datasets._utils import AMetadata
Expand Down
2 changes: 2 additions & 0 deletions src/squidpy/datasets/_image.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from copy import copy

from squidpy.datasets._utils import ImgMetadata
Expand Down
15 changes: 9 additions & 6 deletions src/squidpy/datasets/_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations

import os
from abc import ABC, abstractmethod
from collections.abc import Sequence
from dataclasses import dataclass, field
from inspect import Parameter, Signature, signature
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Sequence, Tuple, Union
from typing import Any, Callable, Union

import anndata
from anndata import AnnData
Expand All @@ -22,10 +25,10 @@ class Metadata(ABC):
name: str
url: str

doc_header: Optional[str] = field(default=None, repr=False)
path: Optional[PathLike] = field(default=None, repr=False)
shape: Optional[tuple[int, int]] = field(default=None, repr=False)
library_id: Optional[Union[str, Sequence[str]]] = field(default=None, repr=False)
doc_header: str | None = field(default=None, repr=False)
path: PathLike | None = field(default=None, repr=False)
shape: tuple[int, int] | None = field(default=None, repr=False)
library_id: str | Sequence[str] | None = field(default=None, repr=False)

_DOC_FMT = ""

Expand Down Expand Up @@ -66,7 +69,7 @@ def _create_function(self, name: str, glob_ns: dict[str, Any]) -> None:
glob_ns,
)

def download(self, fpath: Optional[PathLike] = None, **kwargs: Any) -> Any:
def download(self, fpath: PathLike | None = None, **kwargs: Any) -> Any:
"""Download the dataset into ``fpath``."""
fpath = str(self.path if fpath is None else fpath)
if not fpath.endswith(self._extension):
Expand Down
2 changes: 2 additions & 0 deletions src/squidpy/gr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""The graph module."""

from __future__ import annotations

from squidpy.gr._build import spatial_neighbors
from squidpy.gr._ligrec import ligrec
from squidpy.gr._nhood import centrality_scores, interaction_matrix, nhood_enrichment
Expand Down
2 changes: 1 addition & 1 deletion src/squidpy/gr/_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

import warnings
from collections.abc import Iterable # noqa: F401
from functools import partial
from itertools import chain
from typing import Iterable, List, Tuple, Union # noqa: F401

import numpy as np
from anndata import AnnData
Expand Down
Loading

0 comments on commit 3d0aa0b

Please sign in to comment.