python-lsp / pylsp-mypy

Mypy plugin for the Python LSP Server.
MIT License
130 stars 37 forks source link

how to extract type information? #69

Closed code2graph closed 1 year ago

code2graph commented 1 year ago

Issue: I need to programmatically analyze a Python codebase and extract type information for specific variables. I am thinking to use pylsp-mypy for this task.

Objective: I would like to programmatically use pylsp-mypy to analyze Python code and retrieve type information for specific variables.

Approaches Considered: As pylsp operates as a language server, I am considering to set up a LSP client, starting the pylsp language server with pylsp-mypy enabled, and then sending LSP requests to get type information. However, I'm unsure about the specifics and feasibility of this approach.

Questions:

  1. What's the suggested method for extracting type information programmatically with pylsp-mypy?
  2. Does pylsp-mypy offer any internal APIs or features that can assist in this task?

Thank you for your time and for the fantastic work on pylsp-mypy!

Richardk2n commented 1 year ago

You should probably use the inspect feature of dmypy directly.