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

[spec] a protocol type should be assignable to object? #1780

Open
carljm opened this issue Jun 17, 2024 · 1 comment
Open

[spec] a protocol type should be assignable to object? #1780

carljm opened this issue Jun 17, 2024 · 1 comment
Labels
topic: typing spec For improving the typing spec

Comments

@carljm
Copy link
Member

carljm commented Jun 17, 2024

See #1743 (comment)

@carljm carljm added the topic: typing spec For improving the typing spec label Jun 17, 2024
@JelleZijlstra
Copy link
Member

Mypy, pyre, and pyright all already allow protocol types to be assigned to object. Test program:

from typing import Protocol

def f(x: object) -> None:
    pass

def g(x: int) -> None:
    pass

class X(Protocol):
    foo: int

def h(x: X) -> None:
    f(x)  # OK: protocol is assignable to object
    g(x)  # E: protocol is not assignable to int

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: typing spec For improving the typing spec
Projects
None yet
Development

No branches or pull requests

2 participants