Skip to content

Commit dd6c368

Browse files
committed
Move typing into code quality multi select + less questions
1 parent 8a8083d commit dd6c368

File tree

11 files changed

+32
-60
lines changed

11 files changed

+32
-60
lines changed

copier.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
# community features
3131
!include copier/questions/features_community.yml
3232

33-
---
34-
# typing features
35-
!include copier/questions/features_typing.yml
36-
3733
---
3834
# global flags
3935
!include copier/global_flags.yml

copier/global_flags.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ HasWorkflows:
1212
or AddOnlineDocumentation
1313
or AddSonarCloud
1414
or AddZenodo
15-
or AddLinting
16-
or AddGithubActionTypeCheck }}"
15+
or AddLinting }}"
1716
when: false

copier/questions/features_code_quality.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SelectCodeQualityFeatures:
77
type: yaml
88
default: |-
99
{% if template_profile == 'recommended' %}
10-
[AddLocalTests_flag, SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag]
10+
[AddLocalTests_flag, SelectGitHubActions_flag, AddLinting_flag, AddSonarCloud_flag, AddEditorConfig_flag, AddTyping_flag]
1111
{%- else -%}
1212
[]
1313
{%- endif %}
@@ -32,7 +32,8 @@ SelectCodeQualityFeatures:
3232
Editorconfig:
3333
value: AddEditorConfig_flag
3434
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
35-
35+
Typing (select type checker later):
36+
value: AddTyping_flag
3637

3738
# Sub-menus
3839
SelectGitHubActions:
@@ -54,6 +55,10 @@ SelectGitHubActions:
5455
value: AddLinkCheck_flag
5556
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
5657

58+
---
59+
# typing features
60+
!include copier/questions/features_typing.yml
61+
---
5762

5863
# computed features
5964
AddLocalTests:

copier/questions/features_documentation.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ AddGitHubActionDocumentation:
4444
type: bool
4545
default: "{{ 'AddGitHubActionDocumentation_flag' in SelectDocumentationFeatures }}"
4646
when: false
47+
AddTypingInDocs:
48+
type: bool
49+
default: "{{ AddTyping and AddLocalDocumentation }}"
50+
when: false
Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
11
---
22
# Questions for typing features
33

4-
# the main menu
5-
SelectTypingFeatures:
6-
when: "{{ template_profile != 'minimum' }}"
7-
type: yaml
8-
default: |-
9-
{% if template_profile == 'recommended' %}
10-
[AddTyping_flag, AddTypingInDocs_flag, AddGitHubActionTypeCheck_flag]
11-
{%- else -%}
12-
[]
13-
{%- endif %}
14-
help: Select typing features
15-
multiselect: true
16-
choices:
17-
Support Typing (add py.typed file):
18-
value: AddTyping_flag
19-
GitHub Action to type check:
20-
value: AddGitHubActionTypeCheck_flag
21-
Typing in API documentation:
22-
value: AddTypingInDocs_flag
23-
24-
# TODO add runtime type checking (using pydantic or typeguard)
4+
AddTyping:
5+
type: bool
6+
default: "{{ 'AddTyping_flag' in SelectCodeQualityFeatures }}"
7+
when: false
258

269
SelectTypeChecker:
27-
when: "{{ template_profile != 'minimum' and 'AddTyping_flag' in SelectTypingFeatures }}"
10+
when: "{{ template_profile != 'minimum' and AddTyping }}"
2811
type: str
29-
default: |-
30-
{%- if template_profile == 'recommended' -%}
31-
pyright
32-
{%- endif %}
12+
default: pyright
3313
help: Select a type checker
3414
choices:
3515
Mypy:
@@ -39,19 +19,6 @@ SelectTypeChecker:
3919
# TODO add pyrefly https://pyrefly.org/
4020
# TODO add ty https://github.com/astral-sh/ty
4121

42-
AddPyTyped:
43-
type: bool
44-
default: "{{ 'AddTyping_flag' in SelectTypingFeatures }}"
45-
when: false
46-
47-
AddGithubActionTypeCheck:
48-
type: bool
49-
default: "{{ 'AddGitHubActionTypeCheck_flag' in SelectTypingFeatures and SelectTypeChecker != '' }}"
50-
when: false
51-
52-
AddTypingInDocs:
53-
type: bool
54-
default: "{{ 'AddTypingInDocs_flag' in SelectTypingFeatures }}"
55-
when: false
22+
# TODO add runtime type checking (using pydantic or typeguard)
5623

57-
# TODO ask how strict to typecheck
24+
# TODO ask how strict to typecheck

template/README.md.jinja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@
2929
{% if AddLinkCheck -%}
3030
| Link checker | [![link-check]({{repository_url}}/actions/workflows/link-check.yml/badge.svg)]({{repository_url}}/actions/workflows/link-check.yml) |
3131
{%- endif -%}
32+
{% if AddTyping -%}
3233
{% if SelectTypeChecker == 'pyright' -%}
3334
| Type checker | [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/) |
3435
{%- endif -%}
3536
{% if SelectTypeChecker == 'mypy' -%}
3637
| Type checker | [![Checked with mypy](https://mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/) |
3738
{%- endif -%}
39+
{%- endif %}
3840

3941
## How to use {{ package_name }}
4042

template/pyproject.toml.jinja

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ dev = [
5858
{%- endif %}
5959
"tox",
6060
"myst_parser",
61-
{% if SelectTypeChecker -%}
61+
{% if AddTyping and SelectTypeChecker -%}
6262
"{{ SelectTypeChecker }}",
6363
{%- endif %}
64-
{%- if 'AddTypingInDocs_flag' in SelectTypingFeatures %}
64+
{%- if AddTypingInDocs %}
6565
"sphinx-autodoc-typehints",
6666
{%- endif %}
6767
]
@@ -71,7 +71,7 @@ docs = [
7171
"sphinx_rtd_theme",
7272
"sphinx-autoapi",
7373
"myst_parser",
74-
{%- if 'AddTypingInDocs_flag' in SelectTypingFeatures %}
74+
{%- if AddTypingInDocs %}
7575
"sphinx-autodoc-typehints",
7676
{%- endif %}
7777
]
@@ -156,6 +156,7 @@ known-first-party = ["{{ package_name }}"]
156156
force-single-line = true
157157
no-lines-before = ["future","standard-library","third-party","first-party","local-folder"]
158158

159+
{% if AddTyping -%}
159160
{% if SelectTypeChecker == 'pyright' -%}
160161
[tool.pyright]
161162
include = ["src"]
@@ -164,6 +165,7 @@ include = ["src"]
164165
[tool.mypy]
165166
files = ["src"]
166167
{%- endif %}
168+
{%- endif %}
167169

168170
[tool.bumpversion]
169171
current_version = "{{ version }}"

template/src/{{package_name}}/{% if AddPyTyped %}py.typed{% endif %} renamed to template/src/{{package_name}}/{% if AddTyping %}py.typed{% endif %}

File renamed without changes.

template/{% if AddDevDoc %}README.dev.md{% endif %}.jinja

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ git config --local core.hooksPath .githooks
8787
```
8888
{%- endif -%}
8989

90-
{%- if SelectTypeChecker -%}
90+
{% if AddTyping %}
9191
## Type checking
9292

9393
{% if SelectTypeChecker == 'pyright' -%}
@@ -104,7 +104,6 @@ We use [mypy](http://mypy-lang.org/) for type checking.
104104
```shell
105105
mypy .
106106
```
107-
108107
{% endif -%}
109108
{% endif -%}
110109

template/{% if AddPreCommit %}.githooks{% endif %}/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ echo "Starting ruff analysis..."
99
ruff check --fix
1010
ruff format
1111

12-
# TODO add type checker
12+
# TODO add type checker?
1313

1414
# use return code to abort commit if necessary
1515
if [ $? != "0" ]; then

0 commit comments

Comments
 (0)