Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reveal_type should indicate untyped defs with types #10509

Open
graingert opened this issue May 19, 2021 · 1 comment
Open

reveal_type should indicate untyped defs with types #10509

graingert opened this issue May 19, 2021 · 1 comment
Labels
feature topic-reveal-type reveal_type() and reveal_locals()

Comments

@graingert
Copy link
Contributor

graingert commented May 19, 2021

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 #5943 (comment)

this tripped up the anyio project in the definition of anyio.Lock agronholm/anyio#289

@adamchainz
Copy link

adamchainz commented May 19, 2021

The first error message could be main.py:11: error: Call to untyped function "Lock.__init__" in typed context - since it's the initializer not the constructor that's the problem. Presumably it's also possible to have a typed __new__ but untyped __init__?

reveal_type(Lock.__init__) says main.py:17: note: Revealed type is 'def (self: main.Lock) -> Any'

@AlexWaygood AlexWaygood added the topic-reveal-type reveal_type() and reveal_locals() label Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature topic-reveal-type reveal_type() and reveal_locals()
Projects
None yet
Development

No branches or pull requests

3 participants