Skip to content

Commit 9aaa5b6

Browse files
authored
Pylint fix and windows host helper (#21)
## Link to Issue or Slack thread pylint-dev/pylint#10289 ## Why is this change necessary? pylint pre-commit hook was erroring on install Trying to run copier updates in devcontainers on windows hosts was sometimes having issues ## How does this change address the issue? Pins a patched version of pylint Creates a helper script that can be run to reclone all the files inside the devcontainer on a windows host. ## What side effects does this change have? None ## How is this change tested? In several child and grandchild repositories ## Other Added some misc versions to context.py
1 parent 2a5ecdc commit 9aaa5b6

File tree

8 files changed

+78
-10
lines changed

8 files changed

+78
-10
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# If you are using a Windows host and you initially cloned the repository directly onto your hard drive, you may run into file permission issues when running copier updates. To avoid these, after initially building the devcontainer, run this from the repo root:
4+
# cp .devcontainer/windows-host-helper.sh ../
5+
# cd ..
6+
# bash windows-host-helper.sh <git-url>
7+
8+
# If you're still having issues, make sure in Windows Developer Settings that you enabled Developer Mode, and also that you set your git config to have `core.autocrlf=false` and `core.symlinks=true` globally
9+
10+
set -e # Exit immediately on error
11+
12+
if [ -z "$BASH_VERSION" ]; then
13+
echo "Error: This script must be run with bash (e.g., 'bash windows-host-helper.sh')." >&2
14+
exit 1
15+
fi
16+
17+
# Check for the git URL argument
18+
if [ -z "$1" ]; then
19+
echo "Usage: $0 <git-url>"
20+
exit 1
21+
fi
22+
23+
gitUrl="$1"
24+
25+
# Extract repository name (removes .git suffix if present)
26+
repoName=$(basename "$gitUrl" .git)
27+
28+
echo "Repo name extracted as '$repoName'"
29+
30+
# Remove any existing subfolder with the repository name and recreate it
31+
rm -rf "./$repoName" || true # sometimes deleting the .venv folder fails
32+
rm -rf "./$repoName/*.md" # for some reason, sometimes md files are left behind
33+
mkdir -p "./$repoName"
34+
35+
# Create a temporary directory for cloning
36+
tmpdir=$(mktemp -d)
37+
38+
# Clone the repository into a subfolder inside the temporary directory.
39+
# This creates "$tmpdir/$repoName" with the repository's contents.
40+
git clone "$gitUrl" "$tmpdir/$repoName"
41+
42+
# Enable dotglob so that '*' includes hidden files
43+
shopt -s dotglob
44+
45+
# Move all contents (including hidden files) from the cloned repo to the target folder
46+
mv "$tmpdir/$repoName"/* "./$repoName/"
47+
48+
# Clean up: remove the temporary directory
49+
rm -rf "$tmpdir"
50+
51+
echo "Repository '$repoName' has been updated."

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ repos:
191191
- id: ruff-format
192192

193193
- repo: https://github.com/pylint-dev/pylint
194-
rev: aaab3ccb541532d2bcdf0410ab93ff4fafc266f5 # frozen: v3.3.5
194+
rev: 88543500c70e3aa303b6c0861e2a7a006673f6a8
195195
hooks:
196196
- id: pylint
197197
name: pylint

extensions/context.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]:
1919
#######
2020
context["pnpm_version"] = "10.6.3"
2121
# These are duplicated in the pyproject.toml of this repository
22-
context["pyright_version"] = "1.1.396"
22+
context["pyright_version"] = "1.1.397"
2323
context["pytest_version"] = "8.3.4"
2424
context["pytest_randomly_version"] = "3.16.0"
2525
context["pytest_cov_version"] = "6.0.0"
@@ -42,17 +42,23 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]:
4242
context["gha_checkout"] = "v4.2.2"
4343
context["gha_setup_python"] = "v5.4.0"
4444
context["gha_cache"] = "v4.2.2"
45+
context["gha_linux_runner"] = "ubuntu-24.04"
4546
#######
46-
context["gha_upload_artifact"] = "v4.6.1"
47+
context["gha_upload_artifact"] = "v4.6.2"
48+
context["gha_download_artifact"] = "v4.2.1"
49+
context["gha_setup_buildx"] = "v3.10.0"
50+
context["gha_docker_build_push"] = "v6.15.0"
4751
context["gha_configure_aws_credentials"] = "v4.1.0"
4852
context["gha_setup_node"] = "v4.3.0"
4953
context["gha_mutex"] = "1ebad517141198e08d47cf72f3c0975316620a65 # v1.0.0-alpha.10"
50-
context["gha_linux_runner"] = "ubuntu-24.04"
54+
context["gha_windows_runner"] = "windows-2022"
55+
#######
56+
context["debian_release_name"] = "bookworm"
57+
context["alpine_image_version"] = "3.20"
5158
# These also in the tests/data.yml files in this repository and in copier.yaml
5259
context["py312_version"] = "3.12.7" # ReadTheDocs does not yet support 3.12.8
5360
context["py313_version"] = "3.13.2"
5461
#######
55-
context["gha_windows_runner"] = "windows-2022"
5662
# Kludge to allow for the same docker-compose file in child and grandchild templates
5763
context["aws_region_for_stack"] = "us-east-1"
5864
# Kludge to be able to stop symlinked jinja files from being updated in child templates when the variable is really meant for the instantiated grandchild template

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies = [
88
"pytest>=8.3.4",
99
"pytest-cov>=6.0.0",
1010
"pytest-randomly>=3.16.0",
11-
"pyright[nodejs]>=1.1.396",
11+
"pyright[nodejs]>=1.1.397",
1212
"copier>=9",
1313
"copier-templates-extensions>=0.3.0"
1414
]

template/.devcontainer/devcontainer.json.jinja-base

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
{% endraw %}{% if is_child_of_copier_base_template is not defined and template_uses_vuejs is defined and template_uses_vuejs is sameas(true) %}{% raw %}
4141
// VueJS
4242
43+
{% endraw %}{% endif %}{% raw %}{% endraw %}{% if is_child_of_copier_base_template is not defined and template_uses_javascript is defined and template_uses_javascript is sameas(true) %}{% raw %}
44+
// All javascript
45+
4346
{% endraw %}{% endif %}{% raw %}
4447

4548
// Misc file formats
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.devcontainer/windows-host-helper.sh

template/extensions/context.py.jinja-base

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ class ContextUpdater(ContextHook):
3838
context["gha_setup_python"] = "{{ gha_setup_python }}"
3939
context["gha_cache"] = "{{ gha_cache }}"
4040
context["gha_upload_artifact"] = "{{ gha_upload_artifact }}"
41+
context["gha_download_artifact"] = "{{ gha_download_artifact }}"
42+
context["gha_setup_buildx"] = "{{ gha_setup_buildx }}"
43+
context["gha_docker_build_push"] = "{{ gha_docker_build_push }}"
4144
context["gha_configure_aws_credentials"] = "{{ gha_configure_aws_credentials }}"
4245
context["gha_setup_node"] = "{{ gha_setup_node }}"
4346
context["gha_mutex"] = "{{ gha_mutex }}"
@@ -48,6 +51,9 @@ class ContextUpdater(ContextHook):
4851
context["py312_version"] = "{{ py312_version }}"
4952
context["py313_version"] = "{{ py313_version }}"
5053

54+
context["debian_release_name"] = "{{ debian_release_name }}"
55+
context["alpine_image_version"] = "{{ alpine_image_version }}"
56+
5157
# Kludge to be able to help symlinked jinja files in the child and grandchild templates
5258
context["template_uses_vuejs"] = {{ "True" if template_uses_vuejs else "False" }}
5359
context["template_uses_javascript"] = {{ "True" if template_uses_javascript else "False" }}

uv.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)