False Positive Warning with Type Hinting of Integer Variables
Answered
Using Pycharm 2022.2.3 on Ubuntu 20.04. This is the code sample.
from typing import cast
samples: int = cast(typ=int, val=len(y_train))
The warning says
Expected type Sized, got Iterable[float]
Seems like PyCharm has some wrong assumption about the signature of the len function and does not count y_train as Sized.
Please sign in to leave a comment.
How is y_train declared?
I can't reproduce the issue in PyCharm 2022.2.3
Sergey Karpov I am using Pycharm 2022.2.3 on Ubuntu 20.04.
y_train is basically a pandas Series of float values, which is the target of an ML model training process.
I still can't reproduce it.
What Python version do you use?
How did you install PyCharm?