From 7e5808c99464e162a9c39775ea7ac21701c0f9d5 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 11 Aug 2023 07:38:27 +0000 Subject: [PATCH 1/5] Better consistency check. --- .github/workflows/ci.yml | 8 ++++++-- .github/workflows/ci.yml.jinja | 8 ++++++-- src/{{ module_name }}/settings.py.jinja | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b53ded7f..34d4f3ff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,8 +51,12 @@ jobs: cache: pip python-version: ${{ matrix.python-version }} - run: env | sort - - run: pip install copier - - run: copier copy -r HEAD -f . . + - name: Generate the project with the default value + # Workaround for self rendering as `src/serious_scaffold` should be excluded in other cases. + run: | + pip install copier + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | diff --git a/.github/workflows/ci.yml.jinja b/.github/workflows/ci.yml.jinja index 1eae4abd..1bddf080 100644 --- a/.github/workflows/ci.yml.jinja +++ b/.github/workflows/ci.yml.jinja @@ -69,8 +69,12 @@ jobs: cache: pip python-version: {{ '${{ matrix.python-version }}' }} - run: env | sort - - run: pip install copier - - run: copier copy -r HEAD -f . . + - name: Generate the project with the default value + # Workaround for self rendering as `src/serious_scaffold` should be excluded in other cases. + run: | + pip install copier + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | diff --git a/src/{{ module_name }}/settings.py.jinja b/src/{{ module_name }}/settings.py.jinja index e64fade3..fbccfc79 100644 --- a/src/{{ module_name }}/settings.py.jinja +++ b/src/{{ module_name }}/settings.py.jinja @@ -18,14 +18,15 @@ class GlobalSettings(BaseSettings): class Settings(BaseSettings): """Project specific settings.""" - {%- if version_lt(minimal_python_version, "3.10") | bool %} + # NOTE(huxuan): Pydantic cannot leverage future annotations at runtime prior to # Python 3.10, so `from __future__ import annotations` cannot be used here, and the # lint error need to be ignored unless the minimal Python version >= 3.10. # Reference: https://github.com/pydantic/pydantic/issues/3300#issuecomment-1034007897 logging_level: Optional[str] = getLevelName(logging.INFO) # noqa: FA100 {%- else %} + logging_level: str | None = getLevelName(logging.INFO) {%- endif %} """Default logging level for the project.""" From 41e31afc02cf0de7d483731972a0e3ba3003af21 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 11 Aug 2023 07:45:17 +0000 Subject: [PATCH 2/5] Test. --- .github/workflows/ci.yml | 5 +++-- .github/workflows/ci.yml.jinja | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34d4f3ff..4d7c9b83 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,10 +51,11 @@ jobs: cache: pip python-version: ${{ matrix.python-version }} - run: env | sort + - name: Install copier for template rendering + run: python -m pip install --user copier - name: Generate the project with the default value - # Workaround for self rendering as `src/serious_scaffold` should be excluded in other cases. + # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - pip install copier rm -rf src/serious_scaffold copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff diff --git a/.github/workflows/ci.yml.jinja b/.github/workflows/ci.yml.jinja index 1bddf080..938fb853 100644 --- a/.github/workflows/ci.yml.jinja +++ b/.github/workflows/ci.yml.jinja @@ -69,10 +69,11 @@ jobs: cache: pip python-version: {{ '${{ matrix.python-version }}' }} - run: env | sort + - name: Install copier for template rendering + run: python -m pip install --user copier - name: Generate the project with the default value - # Workaround for self rendering as `src/serious_scaffold` should be excluded in other cases. + # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - pip install copier rm -rf src/serious_scaffold copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff From 6e0465c0331fa2e55100bac3cb771edf9016c9b4 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 11 Aug 2023 07:49:35 +0000 Subject: [PATCH 3/5] Test. --- .github/workflows/ci.yml | 4 ++-- .github/workflows/ci.yml.jinja | 4 ++-- src/{{ module_name }}/settings.py.jinja | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d7c9b83..4e9bc65b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,8 +56,8 @@ jobs: - name: Generate the project with the default value # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - rm -rf src/serious_scaffold - copier copy -x '!src/serious_scaffold' -r HEAD -f . . + # rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -l . . - run: git diff - run: git status --porcelain - run: | diff --git a/.github/workflows/ci.yml.jinja b/.github/workflows/ci.yml.jinja index 938fb853..eb77df03 100644 --- a/.github/workflows/ci.yml.jinja +++ b/.github/workflows/ci.yml.jinja @@ -74,8 +74,8 @@ jobs: - name: Generate the project with the default value # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - rm -rf src/serious_scaffold - copier copy -x '!src/serious_scaffold' -r HEAD -f . . + # rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -l . . - run: git diff - run: git status --porcelain - run: | diff --git a/src/{{ module_name }}/settings.py.jinja b/src/{{ module_name }}/settings.py.jinja index fbccfc79..e64fade3 100644 --- a/src/{{ module_name }}/settings.py.jinja +++ b/src/{{ module_name }}/settings.py.jinja @@ -18,15 +18,14 @@ class GlobalSettings(BaseSettings): class Settings(BaseSettings): """Project specific settings.""" -{%- if version_lt(minimal_python_version, "3.10") | bool %} +{%- if version_lt(minimal_python_version, "3.10") | bool %} # NOTE(huxuan): Pydantic cannot leverage future annotations at runtime prior to # Python 3.10, so `from __future__ import annotations` cannot be used here, and the # lint error need to be ignored unless the minimal Python version >= 3.10. # Reference: https://github.com/pydantic/pydantic/issues/3300#issuecomment-1034007897 logging_level: Optional[str] = getLevelName(logging.INFO) # noqa: FA100 {%- else %} - logging_level: str | None = getLevelName(logging.INFO) {%- endif %} """Default logging level for the project.""" From 71ecfbb7f7f803d7adf2b7bc6f456dd0e9ae4e66 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 11 Aug 2023 08:32:40 +0000 Subject: [PATCH 4/5] Test. --- .github/workflows/ci.yml | 9 ++++++--- .github/workflows/ci.yml.jinja | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e9bc65b..d228dcdc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Git + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -54,10 +58,9 @@ jobs: - name: Install copier for template rendering run: python -m pip install --user copier - name: Generate the project with the default value - # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - # rm -rf src/serious_scaffold - copier copy -x '!src/serious_scaffold' -r HEAD -l . . + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | diff --git a/.github/workflows/ci.yml.jinja b/.github/workflows/ci.yml.jinja index eb77df03..d5fb1735 100644 --- a/.github/workflows/ci.yml.jinja +++ b/.github/workflows/ci.yml.jinja @@ -63,6 +63,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Set up Git + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com - name: Set up Python {{ '${{ matrix.python-version }}' }} uses: actions/setup-python@v4 with: @@ -72,10 +76,9 @@ jobs: - name: Install copier for template rendering run: python -m pip install --user copier - name: Generate the project with the default value - # Workaround for self rendering as `src/serious_scaffold` need to be excluded in other cases. run: | - # rm -rf src/serious_scaffold - copier copy -x '!src/serious_scaffold' -r HEAD -l . . + rm -rf src/serious_scaffold + copier copy -x '!src/serious_scaffold' -r HEAD -f . . - run: git diff - run: git status --porcelain - run: | From 262212256f835d29e69a9a5190af4ec3e36f2df4 Mon Sep 17 00:00:00 2001 From: Xuan Hu Date: Fri, 11 Aug 2023 08:58:48 +0000 Subject: [PATCH 5/5] Fix. --- src/{{ module_name }}/settings.py.jinja | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/{{ module_name }}/settings.py.jinja b/src/{{ module_name }}/settings.py.jinja index e64fade3..fbccfc79 100644 --- a/src/{{ module_name }}/settings.py.jinja +++ b/src/{{ module_name }}/settings.py.jinja @@ -18,14 +18,15 @@ class GlobalSettings(BaseSettings): class Settings(BaseSettings): """Project specific settings.""" - {%- if version_lt(minimal_python_version, "3.10") | bool %} + # NOTE(huxuan): Pydantic cannot leverage future annotations at runtime prior to # Python 3.10, so `from __future__ import annotations` cannot be used here, and the # lint error need to be ignored unless the minimal Python version >= 3.10. # Reference: https://github.com/pydantic/pydantic/issues/3300#issuecomment-1034007897 logging_level: Optional[str] = getLevelName(logging.INFO) # noqa: FA100 {%- else %} + logging_level: str | None = getLevelName(logging.INFO) {%- endif %} """Default logging level for the project."""