python / python/mypy

Implement an analog of map_instance_to_supertype() for protocol supertypes

Open
#7,431 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

In certain situation (like e.g. when dealing with *args) we want to know what are the type arguments of a generic protocol that a given type implements. Currently this is done in ad-hoc way in few places, but it would be great to have a dedicated helper.

This will also help with some advanced issues like https://github.com/python/mypy/issues/3829

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 by locating map_instance_to_supertype() and the existing ad-hoc handling for generic protocols, especially the path involving *args. Read the related discussion in issue #3829 and trace how protocol type arguments are currently inferred. Done means a dedicated helper provides the equivalent mapping for protocol supertypes and the relevant ad-hoc cases can use it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers
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.