Version-Specific Features

Python 3.15 — Disjoint bases for static typing

Marks a class as a disjoint base for static analysis of inheritance compatibility. Two unrelated disjoint bases cannot both be bases of a compatible subclass under the typing rules. This annotation does not replace runtime layout checks. Requires Python 3.15 or the relevant build; example is not executed locally.

Formal Syntax & Structure

python syntaxpython
@typing.disjoint_base

Return Value

Feature-specific

No single return type; see the example and feature description.

Working Example

Example Snippetpython
from typing import disjoint_base@disjoint_baseclass NativeLike: passclass Child(NativeLike): passprint(issubclass(Child, NativeLike))
Python Reference