Skip to content

Extending ProbablisticModel protocol hierarchy breaks isinstance checks #836

@uri-granta

Description

@uri-granta

Running the following code snippet in a fresh Python 3.10 venv with trieste installed via pip:

from trieste.models.interfaces import ProbabilisticModel
from typing import Protocol
class SomeProbabilisticModel(ProbabilisticModel, Protocol): pass
assert not isinstance(1, ProbabilisticModel)

results in the following error:

TypeError: Protocols with non-method members don't support issubclass()

Removing the SomeProbabilisticModel definition on line 3 fixes the issue, as does moving the definition into trieste itself. It also seems to be fixed with Python 3.12.

It would be nice to figure out what is causing this, as it prevents us from reliably being able to use isinstance checks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions