Skip to content

Commit

Permalink
don't configure black (#2701)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Philipp A <flying-sheep@web.de>
  • Loading branch information
3 people committed Oct 24, 2023
1 parent eb87345 commit ec7f925
Show file tree
Hide file tree
Showing 130 changed files with 4,067 additions and 4,072 deletions.
148 changes: 74 additions & 74 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,29 @@
from packaging.version import parse as parse_version

# Don’t use tkinter agg when importing scanpy → … → matplotlib
matplotlib.use('agg')
matplotlib.use("agg")

HERE = Path(__file__).parent
sys.path[:0] = [str(HERE.parent), str(HERE / 'extensions')]
sys.path[:0] = [str(HERE.parent), str(HERE / "extensions")]
import scanpy # noqa


# -- General configuration ------------------------------------------------


nitpicky = True # Warn about broken links. This is here for a reason: Do not change.
needs_sphinx = '4.0' # Nicer param docs
needs_sphinx = "4.0" # Nicer param docs
suppress_warnings = [
'ref.citation',
'myst.header', # https://github.com/executablebooks/MyST-Parser/issues/262
"ref.citation",
"myst.header", # https://github.com/executablebooks/MyST-Parser/issues/262
]

# General information
project = 'Scanpy'
author = 'Scanpy development team'
project = "Scanpy"
author = "Scanpy development team"
repository_url = "https://github.com/scverse/scanpy"
copyright = f'{datetime.now():%Y}, the Scanpy development team.'
version = scanpy.__version__.replace('.dirty', '')
copyright = f"{datetime.now():%Y}, the Scanpy development team."
version = scanpy.__version__.replace(".dirty", "")

# Bumping the version updates all docs, so don't do that
if parse_version(version).is_devrelease:
Expand All @@ -41,44 +41,44 @@
release = version

# default settings
templates_path = ['_templates']
master_doc = 'index'
default_role = 'literal'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
templates_path = ["_templates"]
master_doc = "index"
default_role = "literal"
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "**.ipynb_checkpoints"]

extensions = [
'myst_nb',
'sphinx_copybutton',
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.doctest',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.napoleon',
'sphinx.ext.autosummary',
'sphinx.ext.extlinks',
'matplotlib.sphinxext.plot_directive',
'sphinx_autodoc_typehints', # needs to be after napoleon
'git_ref', # needs to be before scanpydoc.rtd_github_links
'scanpydoc', # needs to be before sphinx.ext.linkcode
'sphinx.ext.linkcode',
'sphinx_design',
'sphinxext.opengraph',
*[p.stem for p in (HERE / 'extensions').glob('*.py') if p.stem not in {'git_ref'}],
"myst_nb",
"sphinx_copybutton",
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.doctest",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
"sphinx.ext.autosummary",
"sphinx.ext.extlinks",
"matplotlib.sphinxext.plot_directive",
"sphinx_autodoc_typehints", # needs to be after napoleon
"git_ref", # needs to be before scanpydoc.rtd_github_links
"scanpydoc", # needs to be before sphinx.ext.linkcode
"sphinx.ext.linkcode",
"sphinx_design",
"sphinxext.opengraph",
*[p.stem for p in (HERE / "extensions").glob("*.py") if p.stem not in {"git_ref"}],
]

# Generate the API documentation when building
autosummary_generate = True
autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"
# autodoc_default_flags = ['members']
napoleon_google_docstring = False
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_use_rtype = True # having a separate entry generally helps readability
napoleon_use_param = True
napoleon_custom_sections = [('Params', 'Parameters')]
napoleon_custom_sections = [("Params", "Parameters")]
todo_include_todos = False
api_dir = HERE / 'api' # function_images
api_dir = HERE / "api" # function_images
myst_enable_extensions = [
"amsmath",
"colon_fence",
Expand All @@ -96,35 +96,35 @@
ogp_site_url = "https://scanpy.readthedocs.io/en/stable/"
ogp_image = "https://scanpy.readthedocs.io/en/stable/_static/Scanpy_Logo_BrightFG.svg"

typehints_defaults = 'braces'
typehints_defaults = "braces"

pygments_style = "default"
pygments_dark_style = "native"

intersphinx_mapping = dict(
anndata=('https://anndata.readthedocs.io/en/stable/', None),
bbknn=('https://bbknn.readthedocs.io/en/latest/', None),
cuml=('https://docs.rapids.ai/api/cuml/stable/', None),
cycler=('https://matplotlib.org/cycler/', None),
dask=('https://docs.dask.org/en/stable/', None),
dask_ml=('https://ml.dask.org/', None),
h5py=('https://docs.h5py.org/en/stable/', None),
ipython=('https://ipython.readthedocs.io/en/stable/', None),
igraph=('https://python.igraph.org/en/stable/api/', None),
leidenalg=('https://leidenalg.readthedocs.io/en/latest/', None),
louvain=('https://louvain-igraph.readthedocs.io/en/latest/', None),
matplotlib=('https://matplotlib.org/stable/', None),
networkx=('https://networkx.org/documentation/stable/', None),
numpy=('https://numpy.org/doc/stable/', None),
pandas=('https://pandas.pydata.org/pandas-docs/stable/', None),
pynndescent=('https://pynndescent.readthedocs.io/en/latest/', None),
pytest=('https://docs.pytest.org/en/latest/', None),
python=('https://docs.python.org/3', None),
rapids_singlecell=('https://rapids-singlecell.readthedocs.io/en/latest/', None),
scipy=('https://docs.scipy.org/doc/scipy/', None),
seaborn=('https://seaborn.pydata.org/', None),
sklearn=('https://scikit-learn.org/stable/', None),
tutorials=('https://scanpy-tutorials.readthedocs.io/en/latest/', None),
anndata=("https://anndata.readthedocs.io/en/stable/", None),
bbknn=("https://bbknn.readthedocs.io/en/latest/", None),
cuml=("https://docs.rapids.ai/api/cuml/stable/", None),
cycler=("https://matplotlib.org/cycler/", None),
dask=("https://docs.dask.org/en/stable/", None),
dask_ml=("https://ml.dask.org/", None),
h5py=("https://docs.h5py.org/en/stable/", None),
ipython=("https://ipython.readthedocs.io/en/stable/", None),
igraph=("https://python.igraph.org/en/stable/api/", None),
leidenalg=("https://leidenalg.readthedocs.io/en/latest/", None),
louvain=("https://louvain-igraph.readthedocs.io/en/latest/", None),
matplotlib=("https://matplotlib.org/stable/", None),
networkx=("https://networkx.org/documentation/stable/", None),
numpy=("https://numpy.org/doc/stable/", None),
pandas=("https://pandas.pydata.org/pandas-docs/stable/", None),
pynndescent=("https://pynndescent.readthedocs.io/en/latest/", None),
pytest=("https://docs.pytest.org/en/latest/", None),
python=("https://docs.python.org/3", None),
rapids_singlecell=("https://rapids-singlecell.readthedocs.io/en/latest/", None),
scipy=("https://docs.scipy.org/doc/scipy/", None),
seaborn=("https://seaborn.pydata.org/", None),
sklearn=("https://scikit-learn.org/stable/", None),
tutorials=("https://scanpy-tutorials.readthedocs.io/en/latest/", None),
)


Expand All @@ -135,10 +135,10 @@
"repository_url": repository_url,
"use_repository_button": True,
}
html_static_path = ['_static']
html_static_path = ["_static"]
html_css_files = ["css/override.css"]
html_show_sphinx = False
html_logo = '_static/img/Scanpy_Logo_BrightFG.svg'
html_logo = "_static/img/Scanpy_Logo_BrightFG.svg"
html_title = "scanpy"


Expand All @@ -159,9 +159,9 @@ def setup(app: Sphinx):

# -- Options for other output formats ------------------------------------------

htmlhelp_basename = f'{project}doc'
doc_title = f'{project} Documentation'
latex_documents = [(master_doc, f'{project}.tex', doc_title, author, 'manual')]
htmlhelp_basename = f"{project}doc"
doc_title = f"{project} Documentation"
latex_documents = [(master_doc, f"{project}.tex", doc_title, author, "manual")]
man_pages = [(master_doc, project, doc_title, [author], 1)]
texinfo_documents = [
(
Expand All @@ -170,8 +170,8 @@ def setup(app: Sphinx):
doc_title,
author,
project,
'One line description of project.',
'Miscellaneous',
"One line description of project.",
"Miscellaneous",
)
]

Expand All @@ -190,18 +190,18 @@ def setup(app: Sphinx):

nitpick_ignore = [
# Will probably be documented
('py:class', 'scanpy._settings.Verbosity'),
('py:class', 'scanpy.neighbors.OnFlySymMatrix'),
("py:class", "scanpy._settings.Verbosity"),
("py:class", "scanpy.neighbors.OnFlySymMatrix"),
# Currently undocumented: https://github.com/mwaskom/seaborn/issues/1810
('py:class', 'seaborn.ClusterGrid'),
("py:class", "seaborn.ClusterGrid"),
# Won’t be documented
('py:class', 'scanpy.plotting._utils._AxesSubplot'),
('py:class', 'scanpy._utils.Empty'),
('py:class', 'numpy.random.mtrand.RandomState'),
('py:class', 'scanpy.neighbors._types.KnnTransformerLike'),
("py:class", "scanpy.plotting._utils._AxesSubplot"),
("py:class", "scanpy._utils.Empty"),
("py:class", "numpy.random.mtrand.RandomState"),
("py:class", "scanpy.neighbors._types.KnnTransformerLike"),
# Will work once scipy 1.8 is released
('py:class', 'scipy.sparse.base.spmatrix'),
('py:class', 'scipy.sparse.csr.csr_matrix'),
("py:class", "scipy.sparse.base.spmatrix"),
("py:class", "scipy.sparse.csr.csr_matrix"),
]

# Options for plot examples
Expand Down
4 changes: 2 additions & 2 deletions docs/extensions/cite.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def cite_role(
content: Sequence[str] = (),
) -> tuple[list[nodes.Node], list[nodes.system_message]]:
key = utils.unescape(text)
node = nodes.citation_reference(f'[{key}]_', key)
node = nodes.citation_reference(f"[{key}]_", key)
return [node], []


def setup(app: Sphinx):
app.add_role('cite', cite_role, override=True)
app.add_role("cite", cite_role, override=True)
4 changes: 2 additions & 2 deletions docs/extensions/debug_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

def pd_new(app, what, name, obj, options, lines):
_pd_orig(app, what, name, obj, options, lines)
print(*lines, sep='\n')
print(*lines, sep="\n")


def setup(app: Sphinx):
if os.environ.get('DEBUG') is not None:
if os.environ.get("DEBUG") is not None:
sphinx.ext.napoleon._process_docstring = pd_new
16 changes: 8 additions & 8 deletions docs/extensions/function_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
def insert_function_images(
app: Sphinx, what: str, name: str, obj: Any, options: Options, lines: List[str]
):
path = app.config.api_dir / f'{name}.png'
if what != 'function' or not path.is_file():
path = app.config.api_dir / f"{name}.png"
if what != "function" or not path.is_file():
return
lines[0:0] = [
f'.. image:: {path.name}',
' :width: 200',
' :align: right',
'',
f".. image:: {path.name}",
" :width: 200",
" :align: right",
"",
]


def setup(app: Sphinx):
app.add_config_value('api_dir', Path(), 'env')
app.connect('autodoc-process-docstring', insert_function_images)
app.add_config_value("api_dir", Path(), "env")
app.connect("autodoc-process-docstring", insert_function_images)
2 changes: 1 addition & 1 deletion docs/extensions/git_ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def get() -> str | None:


def set_ref(app: Sphinx, config: Config):
app.config['html_theme_options']['repository_branch'] = get() or 'main'
app.config["html_theme_options"]["repository_branch"] = get() or "main"


def setup(app: Sphinx) -> None:
Expand Down
14 changes: 7 additions & 7 deletions docs/extensions/param_police.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
param_warnings = {}


def scanpy_log_param_types(self, fields, field_role='param', type_role='type'):
def scanpy_log_param_types(self, fields, field_role="param", type_role="type"):
for _name, _type, _desc in fields:
if not _type or not self._obj.__module__.startswith('scanpy'):
if not _type or not self._obj.__module__.startswith("scanpy"):
continue
w_list = param_warnings.setdefault((self._name, self._obj), [])
if (_name, _type) not in w_list:
Expand All @@ -24,18 +24,18 @@ def show_param_warnings(app, exception):
for (fname, fun), params in param_warnings.items():
_, line = inspect.getsourcelines(fun)
file_name = inspect.getsourcefile(fun)
params_str = '\n'.join(f'\t{n}: {t}' for n, t in params)
params_str = "\n".join(f"\t{n}: {t}" for n, t in params)
warnings.warn_explicit(
f'\nParameters in `{fname}` have types in docstring.\n'
f'Replace them with type annotations.\n{params_str}',
f"\nParameters in `{fname}` have types in docstring.\n"
f"Replace them with type annotations.\n{params_str}",
UserWarning,
file_name,
line,
)
if param_warnings:
raise RuntimeError('Encountered text parameter type. Use annotations.')
raise RuntimeError("Encountered text parameter type. Use annotations.")


def setup(app: Sphinx):
NumpyDocstring._format_docutils_params = scanpy_log_param_types
app.connect('build-finished', show_param_warnings)
app.connect("build-finished", show_param_warnings)
6 changes: 3 additions & 3 deletions docs/extensions/typed_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def process_return(lines):
for line in lines:
m = re.fullmatch(r'(?P<param>\w+)\s+:\s+(?P<type>[\w.]+)', line)
m = re.fullmatch(r"(?P<param>\w+)\s+:\s+(?P<type>[\w.]+)", line)
if m:
# Once this is in scanpydoc, we can use the fancy hover stuff
yield f'**{m["param"]}** : :class:`~{m["type"]}`'
Expand All @@ -16,9 +16,9 @@ def process_return(lines):

def scanpy_parse_returns_section(self, section):
lines_raw = list(process_return(self._dedent(self._consume_to_next_section())))
lines = self._format_block(':returns: ', lines_raw)
lines = self._format_block(":returns: ", lines_raw)
if lines and lines[-1]:
lines.append('')
lines.append("")
return lines


Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ omit = ["*/tests/*"]
[tool.coverage.paths]
source = [".", "**/site-packages"]

[tool.black]
skip-string-normalization = true

[tool.ruff]
select = [
"F", # Pyflakes
Expand Down
4 changes: 2 additions & 2 deletions scanpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
# has to be done at the end, after everything has been imported
import sys

sys.modules.update({f'{__name__}.{m}': globals()[m] for m in ['tl', 'pp', 'pl']})
sys.modules.update({f"{__name__}.{m}": globals()[m] for m in ["tl", "pp", "pl"]})
from ._utils import annotate_doc_types

annotate_doc_types(sys.modules[__name__], 'scanpy')
annotate_doc_types(sys.modules[__name__], "scanpy")
del sys, annotate_doc_types
6 changes: 3 additions & 3 deletions scanpy/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class DaskArray:
pass


__all__ = ['cache', 'DaskArray', 'fullname', 'pkg_metadata', 'pkg_version']
__all__ = ["cache", "DaskArray", "fullname", "pkg_metadata", "pkg_version"]


def fullname(typ: type) -> str:
module = typ.__module__
name = typ.__qualname__
if module == 'builtins' or module is None:
if module == "builtins" or module is None:
return name
return f'{module}.{name}'
return f"{module}.{name}"


def pkg_metadata(package):
Expand Down

0 comments on commit ec7f925

Please sign in to comment.