Skip to content

Commit 34de6fa

Browse files
authored
fix: Fix mypy TorchTensor type alias error (#6712)
* fix: Fix mypy TorchTensor type alias error Fix the TypeAlias annotation of TorchTensor in the fallback branch of online_response.py to stop mypy from treating it as a variable and raising 'not valid as a type'. Fixes #5563 Signed-off-by: Nithin <kumbam.nithingoud@gmail.com> * fix: remove redundant `import torch` under TYPE_CHECKING block The bare `import torch` statement inside the `if TYPE_CHECKING:` branch was superseded by `from torch import Tensor as TorchTensor` on the following line. Since `TorchTensor` is the only torch symbol referenced in type annotations, the standalone module import is unnecessary and can be dropped without affecting runtime or static-analysis behaviour. Addresses nitpick raised in code review. Signed-off-by: Nithin <kumbam.nithingoud@gmail.com> --------- Signed-off-by: Nithin <kumbam.nithingoud@gmail.com>
1 parent 037c4cd commit 34de6fa

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

sdk/python/feast/online_response.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
import uuid as uuid_module
16-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeAlias, Union
16+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union
1717

1818
import pandas as pd
1919
import pyarrow as pa
@@ -25,11 +25,9 @@
2525
from feast.value_type import ValueType
2626

2727
if TYPE_CHECKING:
28-
import torch
29-
30-
TorchTensor: TypeAlias = torch.Tensor
28+
from torch import Tensor as TorchTensor
3129
else:
32-
TorchTensor: TypeAlias = Any
30+
TorchTensor = Any
3331

3432
TIMESTAMP_POSTFIX: str = "__ts"
3533

0 commit comments

Comments
 (0)