Skip to content

Commit 2a54b45

Browse files
committed
Revert "Fix type checking issue in Python 3.9"
The commit contains unwanted changes, committed inadvertently, which introduced a regression, so revert it. This reverts commit ec8b29a.
1 parent a37b1fd commit 2a54b45

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

hooks/post_gen_project.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1+
import logging
12
import os
3+
from pathlib import Path, PurePath
24
import shutil
35
import subprocess
46
import sys
57

8+
from cookiecutter.config import get_user_config
9+
10+
11+
logger = logging.getLogger(__name__)
12+
13+
logger.info('Saving replay file for red-port')
14+
config_dict = get_user_config()
15+
template_name = '{{ cookiecutter._repo_dir.split('/')[-1] }}'
16+
target_replay_path = Path('.redport') / 'cookiecutter_replay'
17+
target_replay_path.mkdir(exist_ok=True)
18+
shutil.copy(
19+
(PurePath(config_dict['replay_dir']) / template_name).with_suffix('.json'),
20+
target_replay_path,
21+
)
22+
623
shutil.rmtree('licenses')
724

825
{% if cookiecutter.include_executable != "y" -%}

{{ cookiecutter.pypi_package_name }}/{{ cookiecutter.python_package_name }}/config.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
import json
44
import os
5-
{% if cookiecutter.use_alternative_union_syntax == "y" -%}
65
from typing import Any
7-
{%- else -%}
8-
from typing import Any, Optional
9-
{%- endif %}
106

117
import xdg.BaseDirectory # type: ignore
128

@@ -16,13 +12,7 @@
1612
logger = get_logger(__name__)
1713

1814

19-
{% if cookiecutter.use_alternative_union_syntax == "y" -%}
2015
def 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 %}
2616
"""Reads a config from the first level of a JSON file by key.
2717
2818
:param key: the name of the top-level JSON property.
@@ -84,11 +74,7 @@ def config_set(key: str, value: Any) -> None:
8474
logger.info('New value written')
8575

8676

87-
{% if cookiecutter.use_alternative_union_syntax == "y" -%}
8877
def config_dir(subdir: str | None = None) -> str:
89-
{%- else -%}
90-
def config_dir(subdir: Optional[str] = None) -> str:
91-
{%- endif %}
9278
"""Returns the configuration directory for this package.
9379
9480
Respects the XDG settings. Also creates the directory if it does

0 commit comments

Comments
 (0)