fix: Fix mypy TorchTensor type alias error - #6712
Conversation
| @@ -26,10 +26,9 @@ | |||
|
|
|||
| if TYPE_CHECKING: | |||
| import torch | |||
There was a problem hiding this comment.
This must not be needed anymore.
|
Good catch — removed the redundant |
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 feast-dev#5563 Signed-off-by: Nithin <kumbam.nithingoud@gmail.com>
6765bd1 to
0cbce28
Compare
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>
0cbce28 to
a0c040f
Compare
|
@jyejare @ntkathole @franciscojavierarceo — the nitpick is fixed and DCO is green. Could you please approve the workflow runs for this PR so CI can finish and it can be merged? Thank you! |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6712 +/- ##
=======================================
Coverage 46.76% 46.76%
=======================================
Files 415 415
Lines 50392 50392
Branches 7214 7214
=======================================
Hits 23567 23567
Misses 25171 25171
Partials 1654 1654
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What this PR does / why we need it
In
online_response.py,TorchTensoris defined usingTypeAliasinside both conditional branches ofif TYPE_CHECKING:. Mypy complains:Variable "feast.online_response.TorchTensor" is not valid as a typebecause it parses it as a variable inside the runtime fallback branch.This PR fixes the typing syntax in
online_response.pyby definingTorchTensorcleanly withoutTypeAliasin the fallback branch so mypy parses the type correctly.Which issue(s) this PR fixes
Fixes #5563
Checks
git commit -s)