File tree Expand file tree Collapse file tree
{{ cookiecutter.pypi_package_name }}/{{ cookiecutter.python_package_name }} Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import json
44import os
5+ {% if cookiecutter .use_alternative_union_syntax == "y" - % }
56from typing import Any
7+ {% - else - % }
8+ from typing import Any , Optional
9+ {% - endif % }
610
711import xdg .BaseDirectory # type: ignore
812
1216logger = get_logger (__name__ )
1317
1418
19+ {% if cookiecutter .use_alternative_union_syntax == "y" - % }
1520def config_get (key : str , default : Any | None = None ) -> Any | None :
21+ {% - else - % }
22+ def config_get (
23+ key : str , default : Optional [Any ] = None
24+ ) -> Optional [Any ]:
25+ {% - endif % }
1626 """Reads a config from the first level of a JSON file by key.
1727
1828 :param key: the name of the top-level JSON property.
@@ -74,7 +84,11 @@ def config_set(key: str, value: Any) -> None:
7484 logger .info ('New value written' )
7585
7686
87+ {% if cookiecutter .use_alternative_union_syntax == "y" - % }
7788def config_dir (subdir : str | None = None ) -> str :
89+ {% - else - % }
90+ def config_dir (subdir : Optional [str ] = None ) -> str :
91+ {% - endif % }
7892 """Returns the configuration directory for this package.
7993
8094 Respects the XDG settings. Also creates the directory if it does
You can’t perform that action at this time.
0 commit comments