Skip to content

Include ambiguous into UninhabitedType identity #19648

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sterliakov
Copy link
Collaborator

Fixes #19641, but also reveals a test that was only passing by coincidence. This inference has never worked correctly:

from typing import Mapping, Never

d: dict[Never, Never]
def run() -> Mapping[str, int]:
    return d

Now - what is the desired behaviour here? I understand both "should be denied" and "should be allowed", but would prefer denying (as we do now). If everyone agrees, I will update the test case to remove xfail and add the error. Cc @ilevkivskyi as the original author (#16122)

…xing that to another PR, but this one only passed due to `foo` definition, removing it also causes failure on master

This comment has been minimized.

This comment has been minimized.

@ilevkivskyi
Copy link
Member

@sterliakov

Now - what is the desired behaviour here? I understand both "should be denied" and "should be allowed", but would prefer denying (as we do now).

Yeah, I think we should deny this (i.e. Never should be only handled specially if the ambiguous flag is set, otherwise regular subtyping rules should apply).

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sterliakov
Copy link
Collaborator Author

Ough, yes, we definitely should deny that - only inline empty collection literals should receive special treatment. https://mypy-play.net/?mypy=latest&python=3.12&flags=strict&gist=2000dac04e592ad8b92012aa697cdbe6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mypy thinks dict[Never, Never] is a subtype of Mapping[str, object]
2 participants