python / python/mypy

reveal_type should indicate untyped defs with types

Open
#10,509 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Feature

It's possible to make a def that's simultaneously typed and untyped eg: https://mypy-play.net/?mypy=latest&python=3.9&flags=disallow-untyped-calls&gist=7946ef5bbce794503defa44284147e56

Here Lock is "untyped" but appears to be a main.py:17: note: Revealed type is 'def () -> main.Lock'

Pitch
reveal_type should let me know that this object has an untyped constructor:

main.py:17: note: Revealed type is 'Untyped[def () -> main.Lock']

See also https://github.com/python/mypy/issues/5943#issuecomment-516075196

this tripped up the anyio project in the definition of anyio.Lock https://github.com/agronholm/anyio/pull/289

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 linked mypy-play example and the existing reveal_type behavior described in the issue. Determine how reveal_type should represent definitions that are both typed and untyped, then verify that the output distinguishes the untyped constructor while preserving the revealed function type.

Written by the indexing model from the issue text.

Assessment

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