diff --git a/python/hopsworks/decorators.py b/python/hopsworks/decorators.py index 51b7d635a..915ccc134 100644 --- a/python/hopsworks/decorators.py +++ b/python/hopsworks/decorators.py @@ -15,6 +15,7 @@ # import functools +import os def not_connected(fn): @@ -53,3 +54,15 @@ def __init__(self): super().__init__( "Connection is not active. Needs to be connected for hopsworks operations." ) + +if os.environ.get("HOPSWORKS_RUN_WITH_TYPECHECK", False): + from typeguard import typechecked +else: + from typing import TypeVar + + _T = TypeVar("_T") + + def typechecked( + target: _T, + ) -> _T: + return target if target else typechecked