python / python/mypy

Support `reveal_type` from dmypy

Open
#10,510 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-daemon topic-reveal-type
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

Support invoking reveal_type from dmypy (similar to suggest) to enable tooling to use mypy for type information.

Pitch

libCST is an extremely powerful tool for supporting refactoring Python code, and it has support for type information, but currently only supports Pyre:
https://libcst.readthedocs.io/en/latest/_modules/libcst/metadata/type_inference_provider.html#TypeInferenceProvider

Pyre and Mypy result in slightly different type information so I'd prefer to get our type data from mypy itself.

Existing solutions seem pretty janky -
https://github.com/fortana-co/sublime-mypy-reveal/blob/master/mypy_reveal.py#L72-L102 modifies the code and invokes reveal_type, https://github.com/matangover/mypy-vscode/blob/master/README.md#caveats imports mypy which isn't well supported.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dmypy entry point and the existing suggest command to understand how requests and type information are handled. Define how a client can invoke reveal_type and receive its result without modifying source files; done means tooling can request mypy's type data through dmypy.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.