python / python/mypy

Plugin: Use mypy to enrich AST with types

Open
#12,513 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-plugins
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

With the inspect/ast modules I can get an AST of e.g. a function and inspect variables - but in terms of types, I can only get the annotations from the signature (AFAIK).

Can mypy enrich the rest of the tree with types? And preferably expose this so that plugins can be written for it?

Does mypy already build a typed AST under the hood? Can you point me to where it happens?

Thank you

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

The issue mentions Python's inspect and ast modules but names no mypy files, tests, or entry points. Start by locating where mypy builds its typed AST and determine whether a supported plugin-facing interface is feasible; done would require a defined way for plugins to access inferred types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.