python / python/mypy

Plugin hook for preprocessing annotations

Open
#7,758 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I want to add some custom annotations on my variables. For example,

def idiv(left: int, right: int | right != 0) -> int:
    return left // right

Mypy accepts only PEP 484 type hints, so I'd like to provide a plugin to pre-process this annotation and return a PEP 484-compatible hint before Mypy checks it. Could Mypy provide a preprocessing hook for such transformations?

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 names no files, tests, or entry points; start by locating mypy's plugin and annotation-processing interfaces. Clarify the supported transformation model and define completion with a documented hook that produces a PEP 484-compatible annotation before type checking.

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.