Skip to content

Commit 2e29930

Browse files
Fix env caching (#79)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 71501f4 commit 2e29930

File tree

4 files changed

+48
-9
lines changed

4 files changed

+48
-9
lines changed

.github/workflows/publish.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3+
4+
name: Upload Python Package
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.x"
23+
cache: "pip"
24+
cache-dependency-path: pyproject.toml
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip wheel
28+
pip install build
29+
- name: Build package
30+
run: python -m build
31+
- name: Publish package
32+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
33+
with:
34+
user: __token__
35+
password: ${{ secrets.PYPI_API_TOKEN }}

.readthedocs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ python:
1111
- doc
1212
sphinx:
1313
configuration: docs/conf.py
14+
fail_on_warning: true

docs/conf.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
from datetime import datetime
22
from importlib.metadata import metadata
3-
from pathlib import Path
3+
from pathlib import PurePosixPath
44

55
from sphinx.application import Sphinx
66

77

8-
HERE = Path(__file__).parent
9-
10-
# Clean build env
11-
for file in HERE.glob("scanpydoc.*.rst"):
12-
file.unlink()
13-
148
extensions = [
159
"sphinx.ext.intersphinx",
1610
"sphinx.ext.napoleon",
@@ -56,7 +50,7 @@
5650
use_repository_button=True,
5751
)
5852

59-
rtd_links_prefix = "src"
53+
rtd_links_prefix = PurePosixPath("src")
6054

6155

6256
def setup(app: Sphinx):

src/scanpydoc/elegant_typehints/__init__.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def x() -> Tuple[int, float]:
4747
from __future__ import annotations
4848

4949
from collections import ChainMap
50+
from collections.abc import Callable
51+
from dataclasses import dataclass
5052
from functools import partial
5153
from pathlib import Path
5254
from typing import Any
@@ -91,6 +93,13 @@ def _init_vars(app: Sphinx, config: Config):
9193
config.html_static_path.append(str(HERE / "static"))
9294

9395

96+
@dataclass
97+
class PickleableCallable:
98+
func: Callable
99+
100+
__call__ = property(lambda self: self.func)
101+
102+
94103
@_setup_sig
95104
def setup(app: Sphinx) -> dict[str, Any]:
96105
"""Patches :mod:`sphinx_autodoc_typehints` for a more elegant display."""
@@ -103,7 +112,7 @@ def setup(app: Sphinx) -> dict[str, Any]:
103112

104113
from .formatting import _role_annot, format_annotation
105114

106-
app.config.typehints_formatter = format_annotation
115+
app.config["typehints_formatter"] = PickleableCallable(format_annotation)
107116
for name in ["annotation-terse", "annotation-full"]:
108117
roles.register_canonical_role(
109118
name, partial(_role_annot, additional_classes=name.split("-"))

0 commit comments

Comments
 (0)