Skip to content

Commit cda9327

Browse files
authored
Enhanced user input (#260)
* use a new toolkit for user prompting: questionary (patched). * multiline questions. * conditional questions. * new toolkit for ui tests: pexpect. * fix lots of tests. * fix windows builds with newer poetry-dynamic-versioning. * linters and mypy are now tests, to have faster ci. * update deprecated ci commands. * removed dependencies from old times. * Remove toml 0.5+ syntax (dotted keys) * Use powershell where syntax is compatible * Change skip to xfail * xfail pexpect tests on windows. I'm tired of trying to make it work * more docs * possibly something more.
1 parent a06ca18 commit cda9327

22 files changed

+1277
-850
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,11 @@ jobs:
4242
- name: Enable msys binaries
4343
if: ${{ runner.os == 'Windows' }}
4444
run: |
45-
echo "::add-path::C:\msys64\usr\bin"
45+
echo "C:\msys64\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
4646
rm C:\msys64\usr\bin\bash.exe
4747
- run: git config --global user.name copier-ci
48-
shell: bash
4948
- run: git config --global user.email copier@copier
50-
shell: bash
5149
- run: git config --global core.autocrlf input
52-
shell: bash
5350
- uses: actions/checkout@v2
5451
- name: Set up Python ${{ matrix.python-version }}
5552
uses: actions/setup-python@v2
@@ -58,8 +55,8 @@ jobs:
5855
- name: generate cache key PY
5956
shell: bash
6057
run:
61-
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
62-
-f1)"
58+
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
59+
$GITHUB_ENV
6360
- uses: actions/[email protected]
6461
with:
6562
path: |
@@ -69,22 +66,11 @@ jobs:
6966
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
7067
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
7168
- name: Install dependencies
72-
shell: bash
7369
run: |
74-
python -m pip install poetry poetry-dynamic-versioning poethepoet
75-
poetry run python -m pip install pip -U
76-
poetry install
77-
- name: Run pre-commit
78-
shell: bash
79-
run: poe lint --color=always
80-
# FIXME Make pre-commit pass reliably on Windows, and remove this
81-
continue-on-error: ${{ runner.os == 'Windows' }}
82-
- name: Run mypy
83-
shell: bash
84-
run: poe types
70+
python -m pip install poetry
71+
poetry install -vvv
8572
- name: Run pytest
86-
shell: bash
87-
run: poe test -ra .
73+
run: poetry run poe test -ra .
8874

8975
publish:
9076
if: github.event_name == 'release'
@@ -98,8 +84,8 @@ jobs:
9884
python-version: 3.8
9985
- name: generate cache key PY
10086
run:
101-
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
102-
-f1)"
87+
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
88+
$GITHUB_ENV
10389
- uses: actions/[email protected]
10490
with:
10591
path: |

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ jobs:
1919
- run: python -m pip install poetry poetry-dynamic-versioning
2020
- name: generate cache key PY
2121
run:
22-
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
23-
-f1)"
22+
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
23+
$GITHUB_ENV
2424
- uses: actions/[email protected]
2525
with:
2626
path: |

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ repos:
1111
# hooks running from local virtual environment
1212
- repo: local
1313
hooks:
14+
- id: autoflake
15+
name: autoflake
16+
entry: poetry run autoflake
17+
language: system
18+
types: [python]
19+
args: ["-i", "--remove-all-unused-imports", "--ignore-init-module-imports"]
1420
- id: black
1521
name: black
1622
entry: poetry run black

copier/config/factory.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def make_config(
132132
{k: v for k, v in questions_data.items() if k in data},
133133
{},
134134
data,
135+
init_args["data_from_template_defaults"],
135136
False,
136137
init_args["envops"],
137138
),
@@ -141,6 +142,7 @@ def make_config(
141142
questions_data,
142143
init_args["data_from_answers_file"],
143144
init_args["data_from_init"],
145+
init_args["data_from_template_defaults"],
144146
not force,
145147
init_args["envops"],
146148
)

copier/config/objects.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""Pydantic models, exceptions and default values."""
2-
32
import datetime
43
from collections import ChainMap
54
from copy import deepcopy
@@ -8,7 +7,7 @@
87
from pathlib import Path
98
from typing import Any, ChainMap as t_ChainMap, Sequence, Tuple, Union
109

11-
from pydantic import BaseModel, Extra, StrictBool, validator
10+
from pydantic import BaseModel, Extra, Field, StrictBool, validator
1211

1312
from ..types import AnyByStrDict, OptStr, PathSeq, StrOrPathSeq, StrSeq
1413

@@ -35,8 +34,6 @@
3534
class UserMessageError(Exception):
3635
"""Exit the program giving a message to the user."""
3736

38-
pass
39-
4037

4138
class NoSrcPathError(UserMessageError):
4239
pass
@@ -91,10 +88,10 @@ class ConfigData(BaseModel):
9188
migrations: Sequence[Migrations] = ()
9289
secret_questions: StrSeq = ()
9390
answers_file: Path = Path(".copier-answers.yml")
94-
data_from_init: AnyByStrDict = {}
95-
data_from_asking_user: AnyByStrDict = {}
96-
data_from_answers_file: AnyByStrDict = {}
97-
data_from_template_defaults: AnyByStrDict = {}
91+
data_from_init: AnyByStrDict = Field(default_factory=dict)
92+
data_from_asking_user: AnyByStrDict = Field(default_factory=dict)
93+
data_from_answers_file: AnyByStrDict = Field(default_factory=dict)
94+
data_from_template_defaults: AnyByStrDict = Field(default_factory=dict)
9895

9996
# Private
10097
_data_mutable: AnyByStrDict

0 commit comments

Comments
 (0)