@@ -54,31 +54,33 @@ def __init_subclass__(cls, namespaces: tuple[str, ...] = ("*",)):
54
54
and issubclass (b , DataConsumer )
55
55
and b .options is cls .options ):
56
56
# if we literally just inherit the attribute,
57
- # don't bother reprocessing it
58
- return
59
-
60
- def coalesce_options (cls : type [DataConsumer ]) -> list [Option ]:
61
- if DataConsumer not in cls .mro ():
62
- return []
63
- seen_inherit = False
64
- opts = []
65
- for opt in cls .options :
66
- if opt == "inherit" :
67
- if seen_inherit :
68
- raise ValueError ("can't use 'inherit' twice" )
69
-
70
- seen_inherit = True
71
- elif isinstance (opt , tuple ):
72
- for base in cls .__bases__ :
73
- opts .extend (o for o in coalesce_options (base )
74
- if o .name in opt )
75
- elif isinstance (opt , Option ):
76
- opts .append (opt )
77
- else :
78
- raise TypeError (f"unknown option definition: { opt !r} " )
79
- return opts
80
-
81
- cls .options = coalesce_options (cls )
57
+ # don't bother reprocessing it - just assign it in the
58
+ # namespaces
59
+ break
60
+ else :
61
+ def coalesce_options (cls : type [DataConsumer ]) -> list [Option ]:
62
+ if DataConsumer not in cls .mro ():
63
+ return []
64
+ seen_inherit = False
65
+ opts = []
66
+ for opt in cls .options :
67
+ if opt == "inherit" :
68
+ if seen_inherit :
69
+ raise ValueError ("can't use 'inherit' twice" )
70
+
71
+ seen_inherit = True
72
+ elif isinstance (opt , tuple ):
73
+ for base in cls .__bases__ :
74
+ opts .extend (o for o in coalesce_options (base )
75
+ if o .name in opt )
76
+ elif isinstance (opt , Option ):
77
+ opts .append (opt )
78
+ else :
79
+ raise TypeError (f"unknown option definition: { opt !r} " )
80
+ return opts
81
+
82
+ cls .options = coalesce_options (cls )
83
+
82
84
for ns in namespaces :
83
85
for option in cls .options :
84
86
_data .Data .define_option (ns , option )
0 commit comments