Skip to content

Commit bdcef41

Browse files
authored
Add RUF lints (#3582)
1 parent 1c5432b commit bdcef41

File tree

27 files changed

+131
-136
lines changed

27 files changed

+131
-136
lines changed

benchmarks/benchmarks/preprocessing_counts.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class FastSuite:
8181
["pbmc3k", "pbmc68k_reduced", "bmmc", "lung93k"],
8282
["counts", "counts-off-axis"],
8383
)
84-
param_names = ["dataset", "layer"]
84+
param_names = ("dataset", "layer")
8585

8686
def time_calculate_qc_metrics(self, *_):
8787
sc.pp.calculate_qc_metrics(

benchmarks/benchmarks/preprocessing_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class FastSuite:
8484
["pbmc3k", "pbmc68k_reduced", "bmmc", "lung93k"],
8585
[None, "off-axis"],
8686
)
87-
param_names = ["dataset", "layer"]
87+
param_names = ("dataset", "layer")
8888

8989
def time_mean_var(self, *_):
9090
_get_mean_var(adata.X)

pyproject.toml

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ select = [
243243
"PT", # Pytest style
244244
"PTH", # Pathlib instead of os.path
245245
"PYI", # Typing
246-
"RUF100", # Unused noqa
246+
"RUF", # Miscellaneous Ruff-only lints
247247
"SIM", # Simplify control flow
248248
"TC", # Manage type checking blocks
249249
"UP", # Update legacy syntax
@@ -252,27 +252,18 @@ select = [
252252
]
253253
external = [ "PLR0917" ] # preview lint that we use
254254
ignore = [
255-
# dict() syntax is preferrable when creating dicts for kwargs
256-
"C408",
257-
# E266 too many leading '#' for block comment -> Scanpy allows them for comments into sections
258-
"E262",
259-
# module level import not at top of file -> required to circumvent circular imports for Scanpys API
260-
"E402",
261-
# line too long -> we accept long comment lines; black gets rid of long code lines
262-
"E501",
263-
# allow I, O, l as variable names -> I is the identity matrix, i, j, k, l is reasonable indexing notation
264-
"E741",
265-
# We ban blank lines before docstrings instead of the opposite
266-
"D203",
267-
# We want multiline summaries to start on the first line, not the second
268-
"D213",
269-
# TODO: replace our current param docs reuse with this and remove it here:
270-
"D417",
271-
# Numbers like “2” aren’t that “magic”.
272-
"PLR2004",
273-
# `Literal["..."] | str` is useful for autocompletion
274-
"PYI051",
255+
"C408", # dict() syntax is preferrable when creating dicts for kwargs
256+
"E262", # E266 too many leading '#' for block comment -> Scanpy allows them for comments into sections
257+
"E402", # module level import not at top of file -> required to circumvent circular imports for Scanpys API
258+
"E501", # line too long -> we accept long comment lines; black gets rid of long code lines
259+
"E741", # allow I, O, l as variable names -> I is the identity matrix, i, j, k, l is reasonable indexing notation
260+
"D203", # We ban blank lines before docstrings instead of the opposite
261+
"D213", # We want multiline summaries to start on the first line, not the second
262+
"D417", # TODO: replace our current param docs reuse with this and remove it here:
263+
"PLR2004", # Numbers like “2” aren’t that “magic”.
264+
"PYI051", # `Literal["..."] | str` is useful for autocompletion
275265
]
266+
allowed-confusables = [ "×", "", "", "α" ]
276267
[tool.ruff.lint.per-file-ignores]
277268
# Do not assign a lambda expression, use a def
278269
"src/scanpy/tools/_rank_genes_groups.py" = [ "E731" ]

src/scanpy/__init__.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,23 @@
6060
del sys, annotate_doc_types
6161

6262
__all__ = [
63-
"__version__",
6463
"AnnData",
64+
"Neighbors",
65+
"Verbosity",
66+
"__version__",
6567
"concat",
68+
"datasets",
69+
"experimental",
70+
"external",
71+
"get",
72+
"logging",
73+
"metrics",
74+
"pl",
75+
"pp",
76+
"queries",
77+
"read",
78+
"read_10x_h5",
79+
"read_10x_mtx",
6680
"read_csv",
6781
"read_excel",
6882
"read_h5ad",
@@ -71,23 +85,9 @@
7185
"read_mtx",
7286
"read_text",
7387
"read_umi_tools",
74-
"read",
75-
"read_10x_h5",
76-
"read_10x_mtx",
7788
"read_visium",
78-
"write",
79-
"datasets",
80-
"experimental",
81-
"external",
82-
"get",
83-
"logging",
84-
"metrics",
85-
"queries",
86-
"pl",
87-
"pp",
88-
"tl",
89-
"Verbosity",
90-
"settings",
91-
"Neighbors",
9289
"set_figure_params",
90+
"settings",
91+
"tl",
92+
"write",
9393
]

src/scanpy/_compat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@
4949
__all__ = [
5050
"DaskArray",
5151
"ZappyArray",
52+
"_numba_threading_layer",
53+
"deprecated",
5254
"fullname",
55+
"njit",
56+
"old_positionals",
5357
"pkg_metadata",
5458
"pkg_version",
55-
"old_positionals",
56-
"deprecated",
57-
"njit",
58-
"_numba_threading_layer",
5959
]
6060

6161

src/scanpy/datasets/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
__all__ = [
2020
"blobs",
2121
"burczynski06",
22+
"ebi_expression_atlas",
2223
"krumsiek11",
2324
"moignard15",
2425
"paul15",
@@ -27,5 +28,4 @@
2728
"pbmc68k_reduced",
2829
"toggleswitch",
2930
"visium_sge",
30-
"ebi_expression_atlas",
3131
]

src/scanpy/external/exporting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from anndata import AnnData
2424

25-
__all__ = ["spring_project", "cellbrowser"]
25+
__all__ = ["cellbrowser", "spring_project"]
2626

2727

2828
@old_positionals(

src/scanpy/external/pl.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
import matplotlib.pyplot as plt
99
import numpy as np
10-
from anndata import AnnData # noqa: TCH002
11-
from matplotlib.axes import Axes # noqa: TCH002
10+
from anndata import AnnData # noqa: TC002
11+
from matplotlib.axes import Axes # noqa: TC002
1212
from sklearn.utils import deprecated
1313

1414
from .._compat import old_positionals
@@ -30,10 +30,10 @@
3030

3131

3232
__all__ = [
33-
"phate",
34-
"trimap",
3533
"harmony_timeseries",
34+
"phate",
3635
"sam",
36+
"trimap",
3737
"wishbone_marker_trajectory",
3838
]
3939

src/scanpy/external/pp/_harmony_integrate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from __future__ import annotations
44

5-
from collections.abc import Sequence # noqa: TCH003
5+
from collections.abc import Sequence # noqa: TC003
66
from typing import TYPE_CHECKING
77

88
import numpy as np

src/scanpy/external/tl/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
from ._wishbone import wishbone
1313

1414
__all__ = [
15+
"cyclone",
1516
"harmony_timeseries",
1617
"palantir",
1718
"palantir_results",
1819
"phate",
1920
"phenograph",
20-
"cyclone",
21-
"sandbag",
2221
"sam",
22+
"sandbag",
2323
"trimap",
2424
"wishbone",
2525
]

0 commit comments

Comments
 (0)