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

0
3 comments

How is y_train declared?
I can't reproduce the issue in PyCharm 2022.2.3

0

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. 

 

0

I still can't reproduce it.
What Python version do you use?
How did you install PyCharm?

0

Please sign in to leave a comment.