Skip to content

isinstance on runtime_checkableProtocol has side-effects for @property methods#102433

@chrisjsewell

Description

@chrisjsewell

For example:

fromtypingimportProtocol, runtime_checkable@runtime_checkableclassX(Protocol): @propertydefmyproperty(self): ... classY: @propertydefmyproperty(self): raiseRuntimeError("hallo") isinstance(Y(), X)

will raise the RuntimeError

This is an issue, for example, if myproperty is an expensive call, has unwanted side effects, or excepts outside of a context manager

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions