diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..da411c2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,37 @@ +{ + "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", + "ms-python.autopep8", + "charliermarsh.ruff", + "matangover.mypy" + ] + } + } +} diff --git a/.vscode/settings.json.example b/.vscode/settings.json.example index 840c35d..0c3395a 100644 --- a/.vscode/settings.json.example +++ b/.vscode/settings.json.example @@ -1,10 +1,18 @@ { - "python.formatting.provider": "autopep8", + "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", "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] diff --git a/scripts/init-project.sh b/scripts/init-project.sh new file mode 100755 index 0000000..6342000 --- /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 ] || jq ".[\"python.defaultInterpreterPath\"] = \"$(poetry env info -e)\"" .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