For a 2x2 matrix (linear fit line) you can use:R2=cov(x,y)⋅cov(x,y)/(var(x)⋅var(y)). in python this would be:
parameters, covariance = curve_fit(lin_func, x, y)
r_squared = covariance[0][1]*covariance[1][0]/(covariance[0][0]*covariance[1][1])
got the formula from: https://stats.stackexchange.com/questions/17050/explanation-for-r-squared-as-ratio-of-covariances-and-variances