[PR #150] feat: add LSP client for Python type information extraction #268

Open
opened 2026-03-15 11:56:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/awslabs/iam-policy-autopilot/pull/150
Author: @adpaco-aws
Created: 2/13/2026
Status: 🔄 Open

Base: mainHead: feat-lsp-client-impl


📝 Commits (1)

  • cd5c98a feat: add LSP client for Python type information extraction

📊 Changes

7 files changed (+2027 additions, -6 deletions)

View changed files

📝 iam-policy-autopilot-policy-generation/Cargo.toml (+6 -6)
📝 iam-policy-autopilot-policy-generation/src/lib.rs (+3 -0)
iam-policy-autopilot-policy-generation/src/lsp/error.rs (+36 -0)
iam-policy-autopilot-policy-generation/src/lsp/mod.rs (+819 -0)
iam-policy-autopilot-policy-generation/src/lsp/protocol.rs (+680 -0)
iam-policy-autopilot-policy-generation/src/lsp/test_utils.rs (+113 -0)
iam-policy-autopilot-policy-generation/tests/lsp_integration_tests.rs (+370 -0)

📄 Description

Issue #, if available: N/A

Description of changes:

Implements a standalone LSP client for the ty Python type checker to enable type information extraction from Python code. This client will support future enhancements to Python SDK call extraction by providing accurate type information for boto3 clients and method calls.

Changes

  • Add TyLspClient for managing ty server lifecycle and querying type information
  • Implement JSON-RPC 2.0 protocol handlers for LSP communication over stdin/stdout
  • Add comprehensive error handling with timeout protection (10s initialize, 5s hover, 2s shutdown)
  • Include response ID matching to handle concurrent requests and server notifications
  • Add 25 unit tests covering protocol, error handling, and response parsing
  • Add 6 integration tests with sequential execution using #[serial] attribute
  • Add test utilities with is_lsp_ready() checking both ty and boto3-stubs availability

Notes

  • LSP client is standalone and not yet integrated with the extraction pipeline
  • Integrations tests are skipped if ty and boto3-stubs are not installed. They can be installed with:
pip install ty
pip install 'boto3-stubs[essential|full|all]

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/awslabs/iam-policy-autopilot/pull/150 **Author:** [@adpaco-aws](https://github.com/adpaco-aws) **Created:** 2/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat-lsp-client-impl` --- ### 📝 Commits (1) - [`cd5c98a`](https://github.com/awslabs/iam-policy-autopilot/commit/cd5c98addad7d31729b68b60076a1e5fa51836db) feat: add LSP client for Python type information extraction ### 📊 Changes **7 files changed** (+2027 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `iam-policy-autopilot-policy-generation/Cargo.toml` (+6 -6) 📝 `iam-policy-autopilot-policy-generation/src/lib.rs` (+3 -0) ➕ `iam-policy-autopilot-policy-generation/src/lsp/error.rs` (+36 -0) ➕ `iam-policy-autopilot-policy-generation/src/lsp/mod.rs` (+819 -0) ➕ `iam-policy-autopilot-policy-generation/src/lsp/protocol.rs` (+680 -0) ➕ `iam-policy-autopilot-policy-generation/src/lsp/test_utils.rs` (+113 -0) ➕ `iam-policy-autopilot-policy-generation/tests/lsp_integration_tests.rs` (+370 -0) </details> ### 📄 Description *Issue #, if available:* N/A *Description of changes:* Implements a standalone LSP client for [the ty Python type checker](https://docs.astral.sh/ty/) to enable type information extraction from Python code. This client will support future enhancements to Python SDK call extraction by providing accurate type information for boto3 clients and method calls. ### Changes - Add `TyLspClient` for managing ty server lifecycle and querying type information - Implement JSON-RPC 2.0 protocol handlers for LSP communication over stdin/stdout - Add comprehensive error handling with timeout protection (10s initialize, 5s hover, 2s shutdown) - Include response ID matching to handle concurrent requests and server notifications - Add 25 unit tests covering protocol, error handling, and response parsing - Add 6 integration tests with sequential execution using `#[serial]` attribute - Add test utilities with `is_lsp_ready()` checking both ty and boto3-stubs availability ### Notes - LSP client is standalone and not yet integrated with the extraction pipeline - Integrations tests are skipped if ty and boto3-stubs are not installed. They can be installed with: ``` pip install ty pip install 'boto3-stubs[essential|full|all] ``` By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/iam-policy-autopilot#268
No description provided.