File tree 4 files changed +48
-9
lines changed
src/scanpydoc/elegant_typehints
4 files changed +48
-9
lines changed Original file line number Diff line number Diff line change
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 }}
Original file line number Diff line number Diff line change @@ -11,3 +11,4 @@ python:
11
11
- doc
12
12
sphinx :
13
13
configuration : docs/conf.py
14
+ fail_on_warning : true
Original file line number Diff line number Diff line change 1
1
from datetime import datetime
2
2
from importlib .metadata import metadata
3
- from pathlib import Path
3
+ from pathlib import PurePosixPath
4
4
5
5
from sphinx .application import Sphinx
6
6
7
7
8
- HERE = Path (__file__ ).parent
9
-
10
- # Clean build env
11
- for file in HERE .glob ("scanpydoc.*.rst" ):
12
- file .unlink ()
13
-
14
8
extensions = [
15
9
"sphinx.ext.intersphinx" ,
16
10
"sphinx.ext.napoleon" ,
56
50
use_repository_button = True ,
57
51
)
58
52
59
- rtd_links_prefix = "src"
53
+ rtd_links_prefix = PurePosixPath ( "src" )
60
54
61
55
62
56
def setup (app : Sphinx ):
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ def x() -> Tuple[int, float]:
47
47
from __future__ import annotations
48
48
49
49
from collections import ChainMap
50
+ from collections .abc import Callable
51
+ from dataclasses import dataclass
50
52
from functools import partial
51
53
from pathlib import Path
52
54
from typing import Any
@@ -91,6 +93,13 @@ def _init_vars(app: Sphinx, config: Config):
91
93
config .html_static_path .append (str (HERE / "static" ))
92
94
93
95
96
+ @dataclass
97
+ class PickleableCallable :
98
+ func : Callable
99
+
100
+ __call__ = property (lambda self : self .func )
101
+
102
+
94
103
@_setup_sig
95
104
def setup (app : Sphinx ) -> dict [str , Any ]:
96
105
"""Patches :mod:`sphinx_autodoc_typehints` for a more elegant display."""
@@ -103,7 +112,7 @@ def setup(app: Sphinx) -> dict[str, Any]:
103
112
104
113
from .formatting import _role_annot , format_annotation
105
114
106
- app .config . typehints_formatter = format_annotation
115
+ app .config [ " typehints_formatter" ] = PickleableCallable ( format_annotation )
107
116
for name in ["annotation-terse" , "annotation-full" ]:
108
117
roles .register_canonical_role (
109
118
name , partial (_role_annot , additional_classes = name .split ("-" ))
You can’t perform that action at this time.
0 commit comments