I\'m getting code inspection warnings from PyCharm. I understand the logic, but I\'m not clear on the appropriate way to fix it. Say I have the following example function:
Pycharm has type hinting features that may be of use.
For example in this case, the following code makes the errors go away:
import numpy as np
def get_ydata(xdata):
ydata = xdata ** 2 # type: np.ndarray
for i in range(len(ydata)):
print(ydata[i])
return ydata
Recent python versions also include support for type annotations
import numpy as np
def get_ydata(xdata: np.ndarray):
...