Search code examples
pythonsympypylance

Pylance and Sympy Object


I am working with SymPy package (https://www.sympy.org/en/index.html). The code runs fine, for example, this small portion of code:

from sympy import Symbol, exp, integrate
x = Symbol('x')
f = 2.5*exp(-0.5*x)
integrate(f, (x,0,1))

However in VSCode, Pylance always gives me this kind of warning/error:

Operator "*" not supported for types "float" and "exp"
Operator "*" not supported for types "float" and "Symbol"

Is it normal and is there any way to fix it?


Solution

  • This is because Pylance does not support SymPy expressions

    This will prevent the warnings from appearing:

    f: sympy.Expr = 2.5*exp(-0.5*x)
    

    Or Use MyPy instead of Pylance