-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Open
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs 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:
Steps to reproduce:
- Create a runtime checkable protocol
- Create one base class with type hints
- Create a second base class that satisfies the protocol
- Create a derived class that inherits from both the base classes
get_type_hints
on the derived class and see they are correct- check the derived class
isinstance
of the protocol get_type_hints
on the derived class and see that they are a blank dictionary
from abc import abstractmethod
from typing import Protocol, get_type_hints, runtime_checkable
@runtime_checkable
class Hello(Protocol):
@abstractmethod
def hello(self) -> str: ...
class Base:
a: str
class Base2:
def hello(self) -> str:
return "hello"
class Thing(Base, Base2): ...
def test_hints():
t = Thing()
assert get_type_hints(t) == {"a": str}
assert isinstance(t, Hello)
assert get_type_hints(t) == {"a": str}
CPython versions tested on:
3.11, 3.13
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixes3.13bugs and security fixesbugs and security fixes3.14bugs 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