Skip to content

Commit 554f88a

Browse files
still need to add it to the namespaces
1 parent 2990350 commit 554f88a

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

schemascii/data_consumer.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,31 +54,33 @@ def __init_subclass__(cls, namespaces: tuple[str, ...] = ("*",)):
5454
and issubclass(b, DataConsumer)
5555
and b.options is cls.options):
5656
# 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+
8284
for ns in namespaces:
8385
for option in cls.options:
8486
_data.Data.define_option(ns, option)

0 commit comments

Comments
 (0)