From 6203644dc2f0bb5a20e38785a79d837ebe289c7d Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Thu, 11 Jul 2024 15:42:55 +0200 Subject: [PATCH] Fix typechecked not found error --- python/hopsworks/decorators.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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