1515from typemap .type_eval import _apply_generic , _typing_inspect
1616from typemap .type_eval ._eval_typing import (
1717 _child_context ,
18+ _eval_args ,
1819 _eval_types ,
1920 EvalContext ,
2021)
@@ -192,7 +193,8 @@ def _eval_init_subclass(
192193 """Get type after all __init_subclass__ with UpdateClass are evaluated."""
193194 for abox in box .mro [1 :]: # Skip the type itself
194195 with _child_context () as ctx :
195- if ms := _get_update_class_members (box , abox , ctx = ctx ):
196+ ms = _get_update_class_members (box , abox , ctx = ctx )
197+ if ms is not None :
196198 nbox = _apply_generic .box (
197199 _create_updated_class (box , ms , ctx = ctx )
198200 )
@@ -208,7 +210,7 @@ def _get_update_class_members(
208210 box : _apply_generic .Boxed ,
209211 boxed_base : _apply_generic .Boxed ,
210212 ctx : EvalContext ,
211- ) -> list [Member ] | None :
213+ ) -> typing . Sequence [Member ] | None :
212214 cls = box .cls
213215
214216 # Get __init_subclass__ from the base class's origin if base is generic.
@@ -267,13 +269,13 @@ def _get_update_class_members(
267269 _typing_inspect .is_generic_alias (evaled_ret )
268270 and typing .get_origin (evaled_ret ) is UpdateClass
269271 ):
270- return [ m for m in typing .get_args (evaled_ret )]
272+ return _eval_args ( typing .get_args (evaled_ret ), ctx )
271273
272274 return None
273275
274276
275277def _create_updated_class (
276- box : _apply_generic .Boxed , ms : list [Member ], ctx : EvalContext
278+ box : _apply_generic .Boxed , ms : typing . Sequence [Member ], ctx : EvalContext
277279) -> type :
278280 t = box .cls
279281 dct : dict [str , object ] = {}
@@ -289,9 +291,11 @@ def _create_updated_class(
289291 typ = _eval_types (typ , ctx )
290292 tquals = _eval_types (quals , ctx )
291293
292- if type_eval .issubtype (
293- typing .Literal ["ClassVar" ], tquals
294- ) and _is_method_like (typ ):
294+ if (
295+ type_eval .issubtype (typing .Literal ["ClassVar" ], tquals )
296+ and _is_method_like (typ )
297+ and _typing_inspect .get_head (typ ) is not GenericCallable
298+ ):
295299 dct [member_name ] = _callable_type_to_method (member_name , typ , ctx )
296300 else :
297301 # Update/add the annotation
0 commit comments