Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Assignees
Labels
3.13bugs and security fixes 3.14bugs and security fixes 3.15new features, bugs and security fixes stdlibStandard Library Python modules in the Lib/ directory topic-typing type-bugAn unexpected behavior, bug, or error
@JelleZijlstra

Description

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

Linked PRs

Metadata

Metadata

Labels

3.13bugs and security fixes 3.14bugs and security fixes 3.15new features, bugs and security fixes stdlibStandard Library Python modules in the Lib/ directory topic-typing type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /