See example below, since those methods on ID and Depsgraph are defined with -> ID, it always returns ID and doesn't consider the actual type.
To resolve this for ID methods using -> typing.Self would work.
For Depsgraph it would require a typing.TypeVar bounded to ID in both Depsgraph.id_eval_get argument and return types.
import bpy
from typing import assert_type
material = bpy.data.materials["test"]
# "assert_type" mismatch: expected "Material" but received "ID"
assert_type(material.copy(), bpy.types.Material)
obj = bpy.data.objects["Test"]
depsgraph = bpy.context.evaluated_depsgraph_get()
# "assert_type" mismatch: expected "Object" but received "ID"
assert_type(obj.override_create(), bpy.types.Object)
assert_type(obj.override_hierarchy_create(), bpy.types.Object)
assert_type(obj.make_local(), bpy.types.Object)
assert_type(obj.evaluated_get(depsgraph), bpy.types.Object)
assert_type(depsgraph.id_eval_get(obj), bpy.types.Object)
See example below, since those methods on
ID
andDepsgraph
are defined with-> ID
, it always returnsID
and doesn't consider the actual type.To resolve this for
ID
methods using-> typing.Self
would work. ForDepsgraph
it would require atyping.TypeVar
bounded toID
in bothDepsgraph.id_eval_get
argument and return types.