python / python/mypy

Add `new_typeinfo` to public plugin API for both SemanticAnalyzer and TypeChecker

Open
#8,257 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In django-stubs, it's used in a lot of places to generate one-off classes.

For semanal, there's https://github.com/python/mypy/blob/master/mypy/semanal.py#L3029, which used for the special casing of NamedTuple/TypedDict/others, which basically plugins in the core.

For type checking, there's no equivalent, but similar code is used here https://github.com/python/mypy/blob/master/mypy/checker.py#L3659

It would be also nice to be able to specify more than one base class.

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

Read mypy/semanal.py#L3029 and mypy/checker.py#L3659 first, comparing the existing one-off class creation paths used by plugins and type checking. Define the public plugin API for both SemanticAnalyzer and TypeChecker, including support for multiple base classes; done when both entry points expose it for django-stubs-style use.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.