1515from typemap .typing import (
1616 Attrs ,
1717 Capitalize ,
18+ DropAnnotations ,
1819 FromUnion ,
1920 GenericCallable ,
21+ GetAnnotations ,
2022 GetArg ,
2123 GetArgs ,
2224 GetAttr ,
23- GetAnnotations ,
24- DropAnnotations ,
2525 IsSubSimilar ,
2626 IsSubtype ,
2727 Iter ,
@@ -474,11 +474,8 @@ def _ann(x):
474474 return f
475475
476476
477- @type_eval .register_evaluator (Attrs )
478- @_lift_over_unions
479- def _eval_Attrs (tp , * , ctx ):
480- hints = get_annotated_type_hints (tp , include_extras = True )
481-
477+ def _hints_to_members (hints , ctx ):
478+ """Convert a hints dictionary to a tuple of Member types."""
482479 return tuple [
483480 * [
484481 Member [
@@ -492,21 +489,21 @@ def _eval_Attrs(tp, *, ctx):
492489 ]
493490
494491
492+ @type_eval .register_evaluator (Attrs )
493+ @_lift_over_unions
494+ def _eval_Attrs (tp , * , ctx ):
495+ hints = get_annotated_type_hints (tp , include_extras = True )
496+ return _hints_to_members (hints , ctx )
497+
498+
495499@type_eval .register_evaluator (Members )
496500@_lift_over_unions
497501def _eval_Members (tp , * , ctx ):
498502 hints = {
499503 ** get_annotated_type_hints (tp , include_extras = True ),
500504 ** get_annotated_method_hints (tp ),
501505 }
502-
503- attrs = [
504- Member [
505- typing .Literal [n ], _eval_types (t , ctx ), _mk_literal_union (* qs ), d
506- ]
507- for n , (t , qs , d ) in hints .items ()
508- ]
509- return tuple [* attrs ]
506+ return _hints_to_members (hints , ctx )
510507
511508
512509##################################################################
0 commit comments