From af18718fead1e8ecbcb37563d8b85cc9c94fe343 Mon Sep 17 00:00:00 2001 From: Jaehyun Yeom Date: Sat, 24 Jan 2026 07:21:02 +0000 Subject: [PATCH] feat(ansible): Add mypy for Python type checking This change introduces the `mypy` static type checker to the development environment. Key changes: - Added `mypy` to `packages_data.go` with installation methods for macOS, Debian, and Termux. - Created a new `setup-python-tools.yml` playbook to group `ruff`, `pylsp`, and `mypy`. - Updated `all.yml` to import the new grouping playbook. - Ensured all changes pass the `make check` validation. --- devtools/setup-dev/ansible/BUILD.bazel | 35 +++++++++++++++ devtools/setup-dev/ansible/README.org | 1 + devtools/setup-dev/ansible/all.yml | 1 + devtools/setup-dev/ansible/mypy.yml | 44 +++++++++++++++++++ devtools/setup-dev/ansible/packages_data.go | 9 ++++ .../setup-dev/ansible/setup-python-tools.yml | 5 +++ 6 files changed, 95 insertions(+) create mode 100644 devtools/setup-dev/ansible/mypy.yml create mode 100644 devtools/setup-dev/ansible/setup-python-tools.yml diff --git a/devtools/setup-dev/ansible/BUILD.bazel b/devtools/setup-dev/ansible/BUILD.bazel index 4bceeeb..f7f621b 100644 --- a/devtools/setup-dev/ansible/BUILD.bazel +++ b/devtools/setup-dev/ansible/BUILD.bazel @@ -167,6 +167,7 @@ sh_test( "libvterm.yml", "locate.yml", "man.yml", + "mypy.yml", "notmuch.yml", "npm.yml", "nvm.yml", @@ -208,6 +209,7 @@ sh_test( "setup-npm.yml", "setup-nvm.yml", "setup-perplexity-mcp.yml", + "setup-python-tools.yml", "setup-rust.yml", "setup-rust-tools.yml", "setup-shell-profile.yml", @@ -1385,6 +1387,20 @@ sh_test( ], ) +sh_test( + name = "mypy_syntax_test", + srcs = ["test_ansible_syntax.sh"], + args = ["mypy.yml"], + data = [ + "mypy.yml", + "uv.yml", + ], + tags = [ + "ansible", + "local", + ], +) + sh_test( name = "notmuch_syntax_test", srcs = ["test_ansible_syntax.sh"], @@ -2266,6 +2282,23 @@ sh_test( ], ) +sh_test( + name = "setup-python-tools_syntax_test", + srcs = ["test_ansible_syntax.sh"], + args = ["setup-python-tools.yml"], + data = [ + "mypy.yml", + "pylsp.yml", + "ruff.yml", + "setup-python-tools.yml", + "uv.yml", + ], + tags = [ + "ansible", + "local", + ], +) + sh_test( name = "setup-rust_syntax_test", srcs = ["test_ansible_syntax.sh"], @@ -2979,6 +3012,7 @@ test_suite( ":make_syntax_test", ":man_syntax_test", ":mono_syntax_test", + ":mypy_syntax_test", ":notmuch_syntax_test", ":npm_syntax_test", ":nvm_syntax_test", @@ -3033,6 +3067,7 @@ test_suite( ":setup-nvm_syntax_test", ":setup-pass_syntax_test", ":setup-perplexity-mcp_syntax_test", + ":setup-python-tools_syntax_test", ":setup-rust-tools_syntax_test", ":setup-rust_syntax_test", ":setup-shell-profile_syntax_test", diff --git a/devtools/setup-dev/ansible/README.org b/devtools/setup-dev/ansible/README.org index 5aa1238..b82402b 100644 --- a/devtools/setup-dev/ansible/README.org +++ b/devtools/setup-dev/ansible/README.org @@ -223,6 +223,7 @@ These files are playbooks not generated from =generate_packages.go=: - setup-nvm.yml - setup-pass.yml - setup-perplexity-mcp.yml +- setup-python-tools.yml - setup-rust.yml - setup-rust-tools.yml - setup-shell-profile.yml diff --git a/devtools/setup-dev/ansible/all.yml b/devtools/setup-dev/ansible/all.yml index c794545..0c9699c 100644 --- a/devtools/setup-dev/ansible/all.yml +++ b/devtools/setup-dev/ansible/all.yml @@ -18,4 +18,5 @@ when: ansible_facts['os_family'] == "Darwin" - import_playbook: setup-rust-tools.yml - import_playbook: setup-sql-tools.yml +- import_playbook: setup-python-tools.yml - import_playbook: setup-devtools.yml diff --git a/devtools/setup-dev/ansible/mypy.yml b/devtools/setup-dev/ansible/mypy.yml new file mode 100644 index 0000000..925e380 --- /dev/null +++ b/devtools/setup-dev/ansible/mypy.yml @@ -0,0 +1,44 @@ +--- +# THIS FILE IS AUTO-GENERATED by generate_packages.go - DO NOT EDIT MANUALLY +# To make changes, modify generate_packages.go, install_methods.go, packages_data.go, or templates.go +# and then run: make +- import_playbook: uv.yml + +- name: Ensure mypy is present + hosts: all + tasks: + - name: Include guard for mypy playbook + block: + - name: Stop early if the mypy playbook is already included + meta: end_play + when: mypy_playbook_imported is defined + - name: Ensure the mypy playbook is not included + set_fact: + mypy_playbook_imported: true + when: mypy_playbook_imported is not defined + + - name: Ensure mypy is present on MacOS + block: + - name: Check if mypy is installed + shell: command -v mypy + changed_when: False + rescue: + - name: Install mypy on MacOS + community.general.homebrew: + name: mypy + state: present + when: ansible_facts['os_family'] == "Darwin" + + - name: Ensure mypy is present on Termux + block: + - name: Ensure mypy is installed with uv + shell: uv tool install mypy + args: + creates: ~/.local/bin/mypy + when: ansible_facts['env']['TERMUX_VERSION'] is defined + + - name: Ensure mypy is installed with uv + shell: uv tool install mypy + args: + creates: ~/.local/bin/mypy + when: ansible_facts['env']['TERMUX_VERSION'] is not defined and ansible_facts['os_family'] != "Darwin" diff --git a/devtools/setup-dev/ansible/packages_data.go b/devtools/setup-dev/ansible/packages_data.go index 8e6dfc0..fb71e6e 100644 --- a/devtools/setup-dev/ansible/packages_data.go +++ b/devtools/setup-dev/ansible/packages_data.go @@ -311,6 +311,15 @@ rm -rf $TMPDIR/codex }, Imports: nil, }, + { + command: "mypy", + platforms: map[PlatformName]InstallMethod{ + PlatformDarwin: BrewInstallMethod{Name: "mypy"}, + PlatformDebianLike: UvInstallMethod{Name: "mypy"}, + PlatformTermux: UvInstallMethod{Name: "mypy"}, + }, + Imports: nil, + }, { command: "nvm", platforms: map[PlatformName]InstallMethod{ diff --git a/devtools/setup-dev/ansible/setup-python-tools.yml b/devtools/setup-dev/ansible/setup-python-tools.yml new file mode 100644 index 0000000..1a70b53 --- /dev/null +++ b/devtools/setup-dev/ansible/setup-python-tools.yml @@ -0,0 +1,5 @@ +--- +# setup-python-tools.yml - Python development tools +- import_playbook: ruff.yml # Formatter + Linter (already exists) +- import_playbook: pylsp.yml # Language server (already exists) +- import_playbook: mypy.yml # Type checker (to be added)