Skip to content

Commit 04f77a4

Browse files
Backport PR #2007 on branch 0.11.x ([pre-commit.ci] pre-commit autoupdate) (#2030)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 71f984c commit 04f77a4

18 files changed

Lines changed: 63 additions & 59 deletions

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.12
3+
rev: v0.12.3
44
hooks:
5-
- id: ruff
5+
- id: ruff-check
66
args: ["--fix"]
77
- id: ruff-format
88
- repo: https://github.com/biomejs/pre-commit
9-
rev: v1.9.4
9+
rev: v2.1.1
1010
hooks:
1111
- id: biome-format
1212
- repo: https://github.com/ComPWA/taplo-pre-commit

biome.jsonc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.1.1/schema.json",
33
"formatter": { "useEditorconfig": true },
44
"overrides": [
55
{
6-
"include": ["./.vscode/*.json", "**/*.jsonc", "**/asv.conf.json"],
6+
"includes": ["./.vscode/*.json", "**/*.jsonc", "**/asv.conf.json"],
77
"json": {
88
"formatter": {
99
"trailingCommas": "all",

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,20 @@ def setup(app: Sphinx):
103103
awkward=("https://awkward-array.org/doc/stable", None),
104104
cupy=("https://docs.cupy.dev/en/stable", None),
105105
dask=("https://docs.dask.org/en/stable", None),
106+
fsspec=("https://filesystem-spec.readthedocs.io/en/stable/", None),
106107
h5py=("https://docs.h5py.org/en/latest", None),
107108
hdf5plugin=("https://hdf5plugin.readthedocs.io/en/latest", None),
109+
kvikio=("https://docs.rapids.ai/api/kvikio/stable/", None),
108110
loompy=("https://linnarssonlab.org/loompy", None),
109111
numpy=("https://numpy.org/doc/stable", None),
112+
obstore=("https://developmentseed.org/obstore/latest/", None),
110113
pandas=("https://pandas.pydata.org/pandas-docs/stable", None),
111114
python=("https://docs.python.org/3", None),
112115
scipy=("https://docs.scipy.org/doc/scipy", None),
113116
sklearn=("https://scikit-learn.org/stable", None),
114117
xarray=("https://docs.xarray.dev/en/stable", None),
115118
zarr=("https://zarr.readthedocs.io/en/v2.18.4/", None),
119+
zarrs=("https://zarrs-python.readthedocs.io/en/stable/", None),
116120
)
117121
qualname_overrides = {
118122
"h5py._hl.group.Group": "h5py.Group",

pyproject.toml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,12 @@ select = [
189189
"PYI", # Typing
190190
]
191191
ignore = [
192-
# line too long -> we accept long comment lines; formatter gets rid of long code lines
193-
"E501",
194-
# Do not assign a lambda expression, use a def -> AnnData allows lambda expression assignments,
195-
"E731",
196-
# allow I, O, l as variable names -> I is the identity matrix, i, j, k, l is reasonable indexing notation
197-
"E741",
198-
# We use relative imports from parent modules
199-
"TID252",
200-
# Shadowing loop variables isn’t a big deal
201-
"PLW2901",
192+
"E501", # line too long -> we accept long comment lines; formatter gets rid of long code lines
193+
"E731", # Do not assign a lambda expression, use a def -> AnnData allows lambda expression assignments,
194+
"E741", # allow I, O, l as variable names -> I is the identity matrix, i, j, k, l is reasonable indexing notation
195+
"TID252", # We use relative imports from parent modules
196+
"PLC0415", # We use a lot of non-top-level imports
197+
"PLW2901", # Shadowing loop variables isn’t a big deal
202198
]
203199
[tool.ruff.lint.per-file-ignores]
204200
# E721 comparing types, but we specifically are checking that we aren't getting subtypes (views)

src/anndata/_core/aligned_df.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def mk_index(l: int) -> pd.Index:
4242
df = pd.DataFrame(
4343
anno,
4444
index=None if length is None else mk_index(length),
45-
columns=None if len(anno) else [],
45+
columns=None if anno else [],
4646
)
4747

4848
if length is None:

src/anndata/_core/anndata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
from .index import Index
6363

6464

65-
class AnnData(metaclass=utils.DeprecationMixinMeta):
65+
class AnnData(metaclass=utils.DeprecationMixinMeta): # noqa: PLW1641
6666
"""\
6767
An annotated data matrix.
6868

src/anndata/_io/h5ad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def read_h5ad_backed(
174174

175175
def read_h5ad(
176176
filename: PathLike[str] | str,
177-
backed: Literal["r", "r+"] | bool | None = None,
177+
backed: Literal["r", "r+"] | bool | None = None, # noqa: FBT001
178178
*,
179179
as_sparse: Sequence[str] = (),
180180
as_sparse_fmt: type[CSMatrix] = sparse.csr_matrix,

src/anndata/_io/read.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def _iter_lines(file_like: Iterable[str]) -> Generator[str, None, None]:
368368
def _read_text(
369369
f: Iterator[str],
370370
delimiter: str | None,
371-
first_column_names: bool | None,
371+
first_column_names: bool | None, # noqa: FBT001
372372
dtype: str,
373373
) -> AnnData:
374374
comments = []

src/anndata/_io/specs/methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ def read_dataframe_partial(
949949
df = pd.DataFrame(
950950
{k: read_elem_partial(elem[k], indices=indices[0]) for k in columns},
951951
index=read_elem_partial(elem[idx_key], indices=indices[0]),
952-
columns=columns if len(columns) else None,
952+
columns=columns if columns else None,
953953
)
954954
if idx_key != "_index":
955955
df.index.name = idx_key

src/anndata/utils.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,15 @@ def make_index_unique(index: pd.Index, join: str = "-"):
265265
example_colliding_values.append(tentative_new_name)
266266

267267
if issue_interpretation_warning:
268-
warnings.warn(
269-
f"Suffix used ({join}[0-9]+) to deduplicate index values may make index "
270-
+ "values difficult to interpret. There values with a similar suffixes in "
271-
+ "the index. Consider using a different delimiter by passing "
272-
+ "`join={delimiter}`"
273-
+ "Example key collisions generated by the make_index_unique algorithm: "
274-
+ str(example_colliding_values)
268+
msg = (
269+
f"Suffix used ({join}[0-9]+) to deduplicate index values may make index values difficult to interpret. "
270+
"There values with a similar suffixes in the index. "
271+
"Consider using a different delimiter by passing `join={delimiter}`. "
272+
"Example key collisions generated by the make_index_unique algorithm: "
273+
f"{example_colliding_values}"
275274
)
275+
# 3: caller -> 2: `{obs,var}_names_make_unique` -> 1: here
276+
warnings.warn(msg, UserWarning, stacklevel=3)
276277
values[indices_dup] = values_dup
277278
index = pd.Index(values, name=index.name)
278279
return index

0 commit comments

Comments
 (0)