#11811·pyright

`__getattribute__` return type is not reflected in the type of attributes

Author: multimericCreated Oct 1, 2026Updated Oct 1, 2026
Labelsbug

Describe the bug When a class overrides __getattribute__ with a specific return type signature R, all attribute accesses to instances of that class should also have type R.

Code or Screenshots

python
from typing import TYPE_CHECKING

class FloatContainer:
    a = 1
    b = 2
    c = 3

    def __getattribute__(self, name: str) -> float:
        # Converts any attribute to float before returning it
        return float(super().__getattribute__(name))


if TYPE_CHECKING:
    reveal_type(FloatContainer().a)
print(type(FloatContainer().a))

Pyright says

information: Type of "FloatContainer().a" is "int"

Python says:

<class 'float'>

Version

bash
uv run pyright --version                                                                      
pyright 1.1.414

Other

I don't think this behaviour is discussed in the typing spec, but I would expect it to be implicit from the data model spec which says __getattribute__ is

Called unconditionally to implement attribute accesses for instances of the class. [...] This method should return the (computed) attribute value or raise an AttributeError exception.

Happy to raise this issue as a clarification of the spec in https://discuss.python.org. I can't find any existing threads about this: https://discuss.python.org/search?expanded=true&q=__getattribute__%20%23typing