File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
tests/roots/test-ext-imgmockconverter Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change 2
2
Does foo.svg --> foo.pdf with no change to the file.
3
3
"""
4
4
5
+ from __future__ import annotations
6
+
5
7
import shutil
8
+ from typing import TYPE_CHECKING
6
9
7
10
from sphinx .transforms .post_transforms .images import ImageConverter
8
11
9
- if False :
10
- # For type annotation
11
- from typing import Any , Dict # NoQA
12
+ if TYPE_CHECKING :
13
+ from sphinx . application import Sphinx
14
+ from sphinx . util . typing import ExtensionMetadata
12
15
13
- from sphinx .application import Sphinx # NoQA
14
16
15
17
class MyConverter (ImageConverter ):
16
18
conversion_rules = [
17
19
('image/svg+xml' , 'application/pdf' ),
18
20
]
19
21
20
- def is_available (self ):
21
- # type: () -> bool
22
+ def is_available (self ) -> bool :
22
23
return True
23
24
24
- def convert (self , _from , _to ):
25
- # type: (unicode, unicode) -> bool
25
+ def convert (self , _from : str , _to : str ) -> bool :
26
26
"""Mock converts the image from SVG to PDF."""
27
27
shutil .copyfile (_from , _to )
28
28
return True
29
29
30
30
31
- def setup (app ):
32
- # type: (Sphinx) -> Dict[unicode, Any]
31
+ def setup (app : Sphinx ) -> ExtensionMetadata :
33
32
app .add_post_transform (MyConverter )
34
33
35
34
return {
You can’t perform that action at this time.
0 commit comments