From dbbec65bce7fa98249c585aec24df0e8dfb217f8 Mon Sep 17 00:00:00 2001 From: Eduardo Klosowski Date: Mon, 29 Jan 2024 22:24:58 -0300 Subject: [PATCH 1/5] Configure devcontainer --- .devcontainer/devcontainer.json | 34 ++++++++++++++++++++++++++++++ scripts/init-project.sh | 7 ++++++ scripts/update-tools-completion.sh | 11 ++++++++++ 3 files changed, 52 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100755 scripts/init-project.sh create mode 100755 scripts/update-tools-completion.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7ebdb3b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,34 @@ +{ + "name": "qldebugger", + + "image": "mcr.microsoft.com/devcontainers/python:3.8-bookworm", + "features": { + "ghcr.io/devcontainers-contrib/features/apt-packages:1": { + "packages": "bash-completion" + }, + "ghcr.io/devcontainers-contrib/features/poetry:2": {} + }, + + "containerUser": "vscode", + "runArgs": [ + "--userns=keep-id" + ], + "mounts": [ + { + "type": "bind", + "source": "/etc/localtime", + "target": "/etc/localtime" + } + ], + + "postCreateCommand": "scripts/update-tools-completion.sh\nscripts/init-project.sh", + + "customizations": { + "vscode": { + "extensions": [ + "editorconfig.editorconfig", + "tamasfe.even-better-toml" + ] + } + } +} diff --git a/scripts/init-project.sh b/scripts/init-project.sh new file mode 100755 index 0000000..d51be35 --- /dev/null +++ b/scripts/init-project.sh @@ -0,0 +1,7 @@ +#!/bin/bash -xe + +# Project dependencies +poetry install --with=docs + +# Visual Studio Code +[ -e .vscode/settings.json ] || cp .vscode/settings.json.example .vscode/settings.json diff --git a/scripts/update-tools-completion.sh b/scripts/update-tools-completion.sh new file mode 100755 index 0000000..f1144df --- /dev/null +++ b/scripts/update-tools-completion.sh @@ -0,0 +1,11 @@ +#!/bin/bash -xe + +# Dependencies +which register-python-argcomplete >/dev/null || /usr/local/bin/pip install --user argcomplete +mkdir -p ~/.local/share/bash-completion/completions + +# pipx +echo 'eval "$(register-python-argcomplete pipx)"' > ~/.local/share/bash-completion/completions/pipx + +# Poetry +echo 'eval "$(poetry completions bash)"' > ~/.local/share/bash-completion/completions/poetry From 7509cf07d46555e2d1624975e030d1e8ce886717 Mon Sep 17 00:00:00 2001 From: Eduardo Klosowski Date: Mon, 29 Jan 2024 22:27:05 -0300 Subject: [PATCH 2/5] Configure Python default interpreter --- .vscode/settings.json.example | 1 + scripts/init-project.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json.example b/.vscode/settings.json.example index 840c35d..fa18fce 100644 --- a/.vscode/settings.json.example +++ b/.vscode/settings.json.example @@ -1,4 +1,5 @@ { + "python.defaultInterpreterPath": "python", "python.formatting.provider": "autopep8", "ruff.importStrategy": "fromEnvironment", "python.linting.mypyEnabled": true, diff --git a/scripts/init-project.sh b/scripts/init-project.sh index d51be35..6342000 100755 --- a/scripts/init-project.sh +++ b/scripts/init-project.sh @@ -4,4 +4,4 @@ poetry install --with=docs # Visual Studio Code -[ -e .vscode/settings.json ] || cp .vscode/settings.json.example .vscode/settings.json +[ -e .vscode/settings.json ] || jq ".[\"python.defaultInterpreterPath\"] = \"$(poetry env info -e)\"" .vscode/settings.json.example > .vscode/settings.json From 19a3cac1782bcb87d91fdee9edc676f2cbe04bb0 Mon Sep 17 00:00:00 2001 From: Eduardo Klosowski Date: Mon, 29 Jan 2024 22:31:14 -0300 Subject: [PATCH 3/5] Configure autopep8 vscode plugin --- .devcontainer/devcontainer.json | 3 ++- .vscode/settings.json.example | 7 +++++-- Makefile | 4 ++-- pyproject.toml | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7ebdb3b..816e383 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,7 +27,8 @@ "vscode": { "extensions": [ "editorconfig.editorconfig", - "tamasfe.even-better-toml" + "tamasfe.even-better-toml", + "ms-python.autopep8" ] } } diff --git a/.vscode/settings.json.example b/.vscode/settings.json.example index fa18fce..d0a65fb 100644 --- a/.vscode/settings.json.example +++ b/.vscode/settings.json.example @@ -1,11 +1,14 @@ { "python.defaultInterpreterPath": "python", - "python.formatting.provider": "autopep8", + "autopep8.importStrategy": "fromEnvironment", "ruff.importStrategy": "fromEnvironment", "python.linting.mypyEnabled": true, "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ "--no-cov", "tests" - ] + ], + "[python]": { + "editor.defaultFormatter": "ms-python.autopep8" + } } diff --git a/Makefile b/Makefile index 625d625..e5ee980 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ build: .PHONY: fmt fmt: - poetry run autopep8 --in-place $(srcdir) $(testsdir) + poetry run autopep8 --recursive --in-place $(srcdir) $(testsdir) poetry run ruff --fix $(srcdir) $(testsdir) @@ -34,7 +34,7 @@ lint-pycodestyle: poetry run pycodestyle --show-source $(srcdir) $(testsdir) lint-autopep8: - poetry run autopep8 --diff --exit-code $(srcdir) $(testsdir) + poetry run autopep8 --diff --exit-code --recursive $(srcdir) $(testsdir) lint-ruff: poetry run ruff check --show-source $(srcdir) $(testsdir) diff --git a/pyproject.toml b/pyproject.toml index 00fb2c5..f6ee3c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,6 @@ mkdocs = "^1.4" qldebugger = "qldebugger.cli:cli" [tool.autopep8] -recursive = true aggressive = 3 [tool.ruff] From bfc7a85199cd9ca664dcb712c44b6c7baea0d3e4 Mon Sep 17 00:00:00 2001 From: Eduardo Klosowski Date: Mon, 29 Jan 2024 22:32:31 -0300 Subject: [PATCH 4/5] Configure ruff vscode plugin --- .devcontainer/devcontainer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 816e383..234de27 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -28,7 +28,8 @@ "extensions": [ "editorconfig.editorconfig", "tamasfe.even-better-toml", - "ms-python.autopep8" + "ms-python.autopep8", + "charliermarsh.ruff" ] } } From a47ca56af78b2474e731d96c74d75e276042cfcb Mon Sep 17 00:00:00 2001 From: Eduardo Klosowski Date: Mon, 29 Jan 2024 22:34:49 -0300 Subject: [PATCH 5/5] Configure mypy vscode plugin --- .devcontainer/devcontainer.json | 3 ++- .vscode/settings.json.example | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 234de27..da411c2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -29,7 +29,8 @@ "editorconfig.editorconfig", "tamasfe.even-better-toml", "ms-python.autopep8", - "charliermarsh.ruff" + "charliermarsh.ruff", + "matangover.mypy" ] } } diff --git a/.vscode/settings.json.example b/.vscode/settings.json.example index d0a65fb..0c3395a 100644 --- a/.vscode/settings.json.example +++ b/.vscode/settings.json.example @@ -2,7 +2,11 @@ "python.defaultInterpreterPath": "python", "autopep8.importStrategy": "fromEnvironment", "ruff.importStrategy": "fromEnvironment", - "python.linting.mypyEnabled": true, + "mypy.runUsingActiveInterpreter": true, + "mypy.targets": [ + "qldebugger", + "tests" + ], "python.testing.pytestEnabled": true, "python.testing.pytestArgs": [ "--no-cov",