Is it possible for 3rd party libraries to work with environment Python version when pythonVersion
is set?
#9607
-
I've been working on a project which is getting used mainly with Python 3.8 (to support Windows 7) and Python 3.13. The Pyright option The problem is, when I switch the developing environment to one based on Python 3.13, Version of from typing import TypeAlias
NDArray: TypeAlias = ... As you may have noticed, I see that different |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
No, it's not possible to set the As you've noted, you can specify a different If you're developing code that must remain compatible with Python 3.8, I recommend using a 3.8 environment for your development. This will keep the development and production environments aligned. If you switch to a newer version, you're likely to run into problems like the one you're experiencing. |
Beta Was this translation helpful? Give feedback.
No, it's not possible to set the
pythonVersion
to be different for a third-party library. Pyright doesn't analyze third-party libraries separately from your files. When you import a symbol from a third-party library, its type is evaluated using the settings from the file that imports it. After all, the code in your file will be executed in the same environment as the library code that it's importing.As you've noted, you can specify a different
pythonVersion
setting for different subdirectories in your project using the "execution environment" configuration support.If you're developing code that must remain compatible with Python 3.8, I recommend using a 3.8 environment for your developm…