Skip to content

Commit 3b6e9af

Browse files
author
Joel Collins
committed
Switch away from dunder to LABTHINGS_EXTENSIONS
1 parent db5677a commit 3b6e9af

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/labthings/extensions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,25 @@ def find_extensions_in_file(extension_path: str, module_name="extensions") -> li
262262
)
263263
return []
264264
else:
265-
if hasattr(mod, "__extensions__"):
265+
if hasattr(mod, "LABTHINGS_EXTENSIONS"):
266+
return [
267+
ext_obj
268+
for ext_obj in getattr(mod, "LABTHINGS_EXTENSIONS")
269+
if isinstance(ext_obj, BaseExtension)
270+
]
271+
elif hasattr(mod, "__extensions__"):
272+
logging.warning(
273+
"Explicit extension list using the __extensions__ global is deprecated.",
274+
"Please use LABTHINGS_EXTENSIONS instead.",
275+
)
266276
return [
267277
getattr(mod, ext_name) for ext_name in getattr(mod, "__extensions__")
268278
]
269279
else:
280+
logging.warning(
281+
"No LTX_MANIFEST found for %s. Searching for implicit extension objects.",
282+
extension_path,
283+
)
270284
return find_instances_in_module(mod, BaseExtension)
271285

272286

0 commit comments

Comments
 (0)