You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This section provides an overview of how the Python extension interacts with the Python Environments extension and other tool-specific extensions. The Python Environments extension allows users to create, manage, and remove Python environments and packages. It also provides an API that other extensions can use to support environment management or consume it for running Python tools or projects.
61
+
62
+
Tools that may rely on these APIs in their own extensions include:
63
+
-**Debuggers** (e.g., `debugpy`)
64
+
-**Linters** (e.g., Pylint, Flake8, Mypy)
65
+
-**Formatters** (e.g., Black, autopep8)
66
+
-**Language Server extensions** (e.g., Pylance, Jedi)
67
+
-**Environment and Package Manager extensions** (e.g., Pixi, Conda, Hatch)
68
+
69
+
### API Dependency
70
+
The relationship between these extensions can be represented as follows:
71
+
72
+
```mermaid
73
+
graph TD
74
+
subgraph Language Features
75
+
B[Python Extension]
76
+
E[Pylance]
77
+
end
78
+
79
+
subgraph Code Execution
80
+
A[Python Environments] <-. Optional .-> B
81
+
C["Linters, Formatters, Debugger"]
82
+
E -. Optional .-> B
83
+
A --> C
84
+
A <--> P
85
+
86
+
subgraph Environment Extensions
87
+
P["Pixi, Pyenv, etc"]
88
+
end
89
+
end
90
+
```
91
+
92
+
Users who do not need to execute code or work in **Virtual Workspaces** can use the Python extension to access language features like hover, completion, and go-to definition. However, executing code (e.g., running a debugger, linter, or formatter), creating/modifying environments, or managing packages requires the Python Environments extension to enable these functionalities.
93
+
94
+
### Trust Relationship Between Python and Python Environments Extensions
95
+
96
+
VS Code supports trust management, allowing extensions to function in either **trusted** or **untrusted** scenarios. Code execution and tools that can modify the user’s environment are typically unavailable in untrusted scenarios.
97
+
98
+
The relationship is illustrated below:
99
+
100
+
```mermaid
101
+
graph TD
102
+
103
+
subgraph Handles Untrusted Code
104
+
B[Python Extension]
105
+
E[Pylance] -. Optional .-> B
106
+
end
107
+
108
+
subgraph Only Trusted Code
109
+
A[Python Environments] <-. Optional .-> B
110
+
C["Linters, Formatters, Debugger"]
111
+
A --> C
112
+
A <--> P
113
+
subgraph Environment Extensions
114
+
P["Pixi, Pyenv, etc"]
115
+
end
116
+
end
117
+
```
118
+
119
+
In **trusted mode**, the Python Environments extension supports tasks like managing environments, installing/removing packages, and running tools. In **untrusted mode**, functionality is limited to language features, ensuring a secure and restricted environment.
120
+
57
121
## Contributing
58
122
59
123
This project welcomes contributions and suggestions. Most contributions require you to agree to a
0 commit comments