Bug report
Bug description:
import abc
from collections.abc import Iterator
from typing import Protocol
# ---- Expected behavior:
class Steppable(metaclass=abc.ABCMeta):
pass
class Module:
@classmethod
def __init_subclass__(cls, **kwargs) -> None:
super().__init_subclass__(**kwargs)
name, annotation, default = "name", str | None, "abc"
cls.__annotations__[name] = annotation
setattr(cls, name, default)
class SequenceLayer1(Module, Steppable):
pass
print(SequenceLayer1.__dict__.get("__annotations__"))
# {'name': str | None}
assert SequenceLayer1.__dict__.get("__annotations__") is not None
# ---- Unexpected behavior:
class CheckpointableIterator(Iterator, Protocol):
pass
isinstance(CheckpointableIterator, Iterator)
class SequenceLayer2(Module, Steppable):
pass
print(SequenceLayer2.__dict__.get("__annotations__"))
# None
assert SequenceLayer2.__dict__.get("__annotations__") is not None
- Failing on 3.12 and 3.13
- Passing on 3.11 and 3.14 (For 3.14 it is expected to have
__dict__["__annotations__"] missing)
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Bug report
Bug description:
__dict__["__annotations__"]missing)CPython versions tested on:
3.12
Operating systems tested on:
Linux