11from datetime import timedelta
22import os
33import dataclasses
4+ from typing import Optional , Dict , Tuple , Any
45
56import cocoindex
67from markdown_it import MarkdownIt
78
89_markdown_it = MarkdownIt ("gfm-like" )
910
1011
12+ @dataclasses .dataclass
1113class LocalFileTarget (cocoindex .op .TargetSpec ):
1214 """Represents the custom target spec."""
1315
@@ -36,7 +38,9 @@ def describe(key: str) -> str:
3638
3739 @staticmethod
3840 def apply_setup_change (
39- key : str , previous : LocalFileTarget | None , current : LocalFileTarget | None
41+ key : str ,
42+ previous : Optional [LocalFileTarget ],
43+ current : Optional [LocalFileTarget ]
4044 ) -> None :
4145 """
4246 Apply setup changes to the target.
@@ -68,7 +72,7 @@ def prepare(spec: LocalFileTarget) -> LocalFileTarget:
6872
6973 @staticmethod
7074 def mutate (
71- * all_mutations : tuple [LocalFileTarget , dict [str , LocalFileTargetValues | None ]],
75+ * all_mutations : Tuple [LocalFileTarget , Dict [str , Optional [ LocalFileTargetValues ] ]],
7276 ) -> None :
7377 """
7478 Mutate the target.
@@ -90,7 +94,7 @@ def mutate(
9094 except FileNotFoundError :
9195 pass
9296 else :
93- with open (full_path , "w" ) as f :
97+ with open (full_path , "w" , encoding = "utf-8" ) as f :
9498 f .write (mutation .html )
9599
96100
0 commit comments