For some reason, if I have a variable inside my project, Vscode stopped suggesting imports when i press Ctrl + Space
.
For example, I have a class in types.py
:
class StepStatus(ExtendedEnum):
RUNNING = "RUNNING"
ERROR = "ERROR"
OK = "OK"
At the same level, another file called runner.py
, but if try to auto import this variable it raises no suggestions
:
But if I manually import the StepStatus
variable it exists:
There is my vscode settings.json
content:
{
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"isort.args": [
"--profile",
"black"
],
"python.analysis.extraPaths": [
"${workspaceFolder}"
],
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "Material Theme High Contrast",
"window.zoomLevel": 1,
"terminal.integrated.inheritEnv": false
}
I already tried to reinstall Vscode, reinstall Pylance extension, delete cache but nothing works. The auto import suggestions only works for the default libraries such as json, typing, datetime...
If there is no StepStatus
class in your script, how does IntelliSense prompt?
So I guess you have the following code under your types.py
script
class StepStatus(Enum):
EMPTY = "empty"
PARTLY_OK = "partly_ok"
OK = "ok"
ERROR = "error"
Then intellisense will be provided when you type StepStatus
in the runner.py
script in the same directory:
Enter or select, it will be imported automatically
Type .
and smart suggestions also work
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.