-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Open
Labels
3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
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
yihong0618
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error