Skip to content

Commit

Permalink
Add more ruff rules (#177)
Browse files Browse the repository at this point in the history
* Add more ruff rules

* remove bandit

* Add FA

* fixes

* Remove D400
  • Loading branch information
adamgayoso authored Sep 1, 2024
1 parent f41e432 commit 876e8fd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
10 changes: 6 additions & 4 deletions docs/extensions/typed_returns.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# code from https://github.com/theislab/scanpy/blob/master/docs/extensions/typed_returns.py
# with some minor adjustment
from __future__ import annotations

from sphinx.ext.napoleon import NumpyDocstring
from typing import TYPE_CHECKING
import re
from collections.abc import Generator, Iterable

from sphinx.application import Sphinx
from sphinx.ext.napoleon import NumpyDocstring
if TYPE_CHECKING:
from collections.abc import Generator, Iterable

from sphinx.application import Sphinx


def _process_return(lines: Iterable[str]) -> Generator[str, None, None]:
Expand Down
32 changes: 15 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ dependencies = [
]

[project.optional-dependencies]
dev = [
"pre-commit",
"twine>=4.0.2",
]
dev = ["pre-commit", "twine>=4.0.2"]
doc = [
"sphinx>=4",
"sphinx-book-theme>=1.0",
Expand Down Expand Up @@ -93,17 +90,20 @@ xfail_strict = true
src = ["src"]
line-length = 120
lint.select = [
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"I", # isort
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
"C4", # flake8-comprehensions
"BLE", # flake8-blind-except
"UP", # pyupgrade
"RUF100", # Report unused noqa directives
"F", # Errors detected by Pyflakes
"E", # Error detected by Pycodestyle
"W", # Warning detected by Pycodestyle
"I", # isort
"D", # pydocstyle
"B", # flake8-bugbear
"TID", # flake8-tidy-imports
"C4", # flake8-comprehensions
"BLE", # flake8-blind-except
"UP", # pyupgrade
"RUF100", # Report unused noqa directives
"ICN", # flake8-import-conventions
"TCH", # flake8-type-checking
"FA", # flake8-future-annotations
]
lint.ignore = [
# line too long -> we accept long comment lines; formatter gets rid of long code lines
Expand All @@ -122,8 +122,6 @@ lint.ignore = [
"B008",
# __magic__ methods are are often self-explanatory, allow missing docstrings
"D105",
# first line should end with a period [Bug: doesn't work with single-line docstrings]
"D400",
# First line should be in imperative mood; try rephrasing
"D401",
## Disable one in each pair of mutually incompatible rules
Expand Down
8 changes: 4 additions & 4 deletions src/scib_metrics/benchmark/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from functools import partial
from typing import Any

import matplotlib
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -297,7 +297,7 @@ def plot_results_table(self, min_max_scale: bool = True, show: bool = True, save
The directory to save the plot to. If `None`, the plot is not saved.
"""
num_embeds = len(self._embedding_obsm_keys)
cmap_fn = lambda col_data: normed_cmap(col_data, cmap=matplotlib.cm.PRGn, num_stds=2.5)
cmap_fn = lambda col_data: normed_cmap(col_data, cmap=mpl.cm.PRGn, num_stds=2.5)
df = self.get_results(min_max_scale=min_max_scale)
# Do not want to plot what kind of metric it is
plot_df = df.drop(_METRIC_TYPE, axis=0)
Expand Down Expand Up @@ -335,7 +335,7 @@ def plot_results_table(self, min_max_scale: bool = True, show: bool = True, save
title=col.replace(" ", "\n", 1),
plot_fn=bar,
plot_kw={
"cmap": matplotlib.cm.YlGnBu,
"cmap": mpl.cm.YlGnBu,
"plot_bg_bar": False,
"annotate": True,
"height": 0.9,
Expand All @@ -347,7 +347,7 @@ def plot_results_table(self, min_max_scale: bool = True, show: bool = True, save
for i, col in enumerate(score_cols)
]
# Allow to manipulate text post-hoc (in illustrator)
with matplotlib.rc_context({"svg.fonttype": "none"}):
with mpl.rc_context({"svg.fonttype": "none"}):
fig, ax = plt.subplots(figsize=(len(df.columns) * 1.25, 3 + 0.3 * num_embeds))
tab = Table(
plot_df,
Expand Down

0 comments on commit 876e8fd

Please sign in to comment.