'Using python 3.10, but pylance still says "alternative syntax for unions requires python 3.10 or newer?"
So I just upgraded python to 3.10 for the new features, and when I do import sys; sys.version using the ipython console in vs code, it prints python version 3.10.0. But when I open an editor window and try to enter a type annotation using | for sum types, eg x:int|float, pylance highlights the | and says "alternative syntax for unions requires python 3.10 or newer."
Any thoughts?
Thanks.
Solution 1:[1]
VS Code may be using a different version of python. Make sure that the default python interpreter (under settings, search for python) is python3.10 (if you are using linux, /usr/bin/python3.10 will probably work)
Solution 2:[2]
The "dmypy" is the daemon handles all the type checking process. As you type the commad "ps ax | grep dmypy" to the console, you'll see which version of python is executing it.
The "mypy.runUsingActiveInterpreter" is the setting to use the active Python interpreter or not. After enabling the "mypy.runUsingActiveInterpreter", it starts by the Python Interpreter accordingly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | William |
| Solution 2 | Ike Tien |
