File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313import numpy as np
1414import pandas as pd
15- import time_machine
1615from io import StringIO
1716from pandas .api .types import is_object_dtype
1817from sqlglot import Dialect , exp
@@ -670,13 +669,15 @@ def runTest(self) -> None:
670669
671670 def _execute_model (self ) -> pd .DataFrame :
672671 """Executes the python model and returns a DataFrame."""
673- time_ctx = (
674- time_machine .travel (self ._execution_time , tick = False )
675- if self ._execution_time
676- else nullcontext ()
677- )
672+ if self ._execution_time :
673+ import time_machine
674+
675+ time_ctx : AbstractContextManager = time_machine .travel (self ._execution_time , tick = False )
676+ else :
677+ time_ctx = nullcontext ()
678+
678679 with patch .dict (self ._test_adapter_dialect .generator_class .TRANSFORMS , self ._transforms ):
679- with t . cast ( AbstractContextManager , time_ctx ) :
680+ with time_ctx :
680681 variables = self .body .get ("vars" , {}).copy ()
681682 time_kwargs = {
682683 key : variables .pop (key ) for key in TIME_KWARG_KEYS if key in variables
You can’t perform that action at this time.
0 commit comments