问题
I have very simple Python function that subtracts scalar value from pandas Series:
def sub(x: pd.Series, a: int) -> pd.Series:
return x - a
It works as expected. I'm using type hints to enable type checker directly in my PyCharm IDE. The issue here is I get this warning message:
Expected type 'Series', got 'int' instead
As you can see in the image below:
I understand that Python is dynamically typed language so in some cases type checking with type hints has its own limitations. But this sounds as a clear case to me. Do you know how to deal with it? Or am I missing something in my simple code?
(I am using Python 3.8.2, PyCharm 2020.1 - Professional Edition)
来源:https://stackoverflow.com/questions/60726641/pycharm-type-checker-expected-series-got-int