mypy with --warn-return-any gives a warning for this function:
def f() -> object:
x: Any = 1
return x
This code is correct in fact: any type is object, so we can safely return Any.
It can be fixed like that:
def f() -> object:
x: Any = 1
return cast(object, x)
but cast(object, ...) should be a no-op for mypy IMO.