Skip to content

Non-runtime_checkable subclass of a runtime_checkable Protocol allows isinstance() #132604

@JelleZijlstra

Description

@JelleZijlstra

Bug report

Bug description:

I would expect this to raise, but it passes on all versions:

from typing import runtime_checkable, Protocol
@runtime_checkable
class Foo(Protocol):
    x: int
class Bar(Foo, Protocol):
    y: str
isinstance(object(), Bar)

Some previous discussion in #132596 (comment) . We may not want to change this behavior for compatibility reasons, but I think it's a bug so I'm at least opening the issue.

CPython versions tested on:

CPython main branch, 3.13

Operating systems tested on:

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtopic-typingtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy