Programmatic Access to Extract Type Information with mypy
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
I'm currently working on a project where I need to analyze a Python codebase programatically to extract type information for several variables. As mypy is a robust type-checker, I am keen on utilizing it for this purpose.
Objective: My goal is to use mypy programmatically to analyze Python code and obtain type information for specific variables.
Approaches Considered: As mypy can function as a language server, I am thinking to set up a LSP client, initiating the mypy language server, and subsequently dispatching LSP requests to gather type data. However, I am not sure about the viability of this strategy.
Direct Utilization of mypy: I am curious if there's a simpler way to leverage it directly as a library format for Python code analysis and extract type information extraction.
Questions:
Is there a recommended way to do programmatic type extraction using mypy?
Are there any internal APIs or tools within mypy that could be leveraged for this purpose?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the mypy language server and the proposed LSP-client approach, then investigate whether mypy exposes a direct library interface for extracting variable type information. The issue needs a concrete supported workflow and scope before implementation can begin; done would be a decided and documented programmatic access path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100