@@ -95,21 +95,25 @@ def get_child_spec(spec: object, child_name: str) -> object:
9595 # falling back to type annotations for attributes
9696 child_hint = _get_type_hints (spec ).get (child_name )
9797 child_source = inspect .getattr_static (spec , child_name , child_hint )
98- unwrapped_child_source = inspect .unwrap (child_source )
98+
99+ if isinstance (child_source , property ):
100+ return _unwrap_type_alias (_get_type_hints (child_source .fget ).get ("return" ))
101+
102+ if isinstance (child_source , functools .cached_property ):
103+ return _unwrap_type_alias (_get_type_hints (child_source .func ).get ("return" ))
99104
100105 if isinstance (child_source , staticmethod ):
101- return unwrapped_child_source
106+ return child_source . __func__
102107
103- if isinstance (unwrapped_child_source , property ):
104- return _unwrap_type_alias (
105- _get_type_hints (unwrapped_child_source .fget ).get ("return" )
106- )
108+ # consume `cls` argument
109+ if isinstance (child_source , classmethod ):
110+ return functools .partial (child_source .__func__ , spec )
107111
108- # consume `self` and `cls` arguments
109- if inspect .isroutine (unwrapped_child_source ):
110- return functools .partial (unwrapped_child_source , None )
112+ # consume `self` argument
113+ if inspect .isroutine (child_source ) and callable ( child_source ):
114+ return functools .partial (child_source , None )
111115
112- return _unwrap_type_alias (unwrapped_child_source )
116+ return _unwrap_type_alias (child_source )
113117
114118 return None
115119
0 commit comments