From 7d628454aa0d56eb846e0ad63d7d5310b2c69665 Mon Sep 17 00:00:00 2001 From: David Vo Date: Sat, 11 Feb 2023 17:26:59 +1100 Subject: [PATCH] Try to fix recursion --- ctre/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ctre/__init__.py b/ctre/__init__.py index 1a664c7..d2380de 100644 --- a/ctre/__init__.py +++ b/ctre/__init__.py @@ -200,13 +200,15 @@ # backwards compat # TODO: remove in 2024 def __getattr__(name): - from . import sensors + if name != "sensors": + from .sensors import __all__ - if name in sensors.__all__: - import warnings + if name in __all__: + import warnings + from . import sensors - message = f"{__name__}.{name} has moved to {__name__}.sensors" - warnings.warn(message, FutureWarning, stacklevel=2) - return getattr(sensors, name) + message = f"{__name__}.{name} has moved to {__name__}.sensors" + warnings.warn(message, FutureWarning, stacklevel=2) + return getattr(sensors, name) raise AttributeError(f"module {__name__!r} has no attribute {name!r}")