Skip to content

Commit c770f24

Browse files
authored
Update version and packages for release (#362)
1 parent c2c8503 commit c770f24

File tree

7 files changed

+33
-235
lines changed

7 files changed

+33
-235
lines changed

.github/workflows/pr-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
os: [ubuntu-latest, windows-latest]
48-
python: ['3.8', '3.9', '3.10', '3.11-dev']
48+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
4949

5050
steps:
5151
- name: Checkout

.github/workflows/push-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
fail-fast: false
5151
matrix:
5252
os: [ubuntu-latest, windows-latest]
53-
python: ['3.8', '3.9', '3.10', '3.11']
53+
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
5454

5555
steps:
5656
- name: Checkout

package-lock.json

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "black-formatter",
33
"displayName": "Black Formatter",
44
"description": "%extension.description%",
5-
"version": "2023.5.0-dev",
5+
"version": "2023.6.0",
66
"preview": true,
77
"serverInfo": {
88
"name": "Black",
@@ -157,6 +157,7 @@
157157
]
158158
},
159159
"dependencies": {
160+
"@vscode/python-extension": "^1.0.5",
160161
"fs-extra": "^11.1.1",
161162
"vscode-languageclient": "^8.1.0"
162163
},

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extension.description": "Formatting support for Python files using `black`.",
2+
"extension.description": "Formatting support for Python files using Black formatter.",
33
"command.restartServer": "Restart Server",
44
"settings.args.description": "Arguments passed in. Each argument is a separate string in the array.",
55
"settings.path.description": "When set to a path to `black` binary, extension will use that for linting. NOTE: Using this option may slowdown formatting.",

src/common/python.ts

Lines changed: 9 additions & 220 deletions
Original file line numberDiff line numberDiff line change
@@ -2,214 +2,9 @@
22
// Licensed under the MIT License.
33

44
/* eslint-disable @typescript-eslint/naming-convention */
5-
import { commands, Disposable, Event, EventEmitter, extensions, Uri, WorkspaceFolder } from 'vscode';
5+
import { commands, Disposable, Event, EventEmitter, Uri } from 'vscode';
66
import { traceError, traceLog } from './logging';
7-
8-
type Environment = EnvironmentPath & {
9-
/**
10-
* Carries details about python executable.
11-
*/
12-
readonly executable: {
13-
/**
14-
* Uri of the python interpreter/executable. Carries `undefined` in case an executable does not belong to
15-
* the environment.
16-
*/
17-
readonly uri: Uri | undefined;
18-
/**
19-
* Bitness if known at this moment.
20-
*/
21-
readonly bitness: Bitness | undefined;
22-
/**
23-
* Value of `sys.prefix` in sys module if known at this moment.
24-
*/
25-
readonly sysPrefix: string | undefined;
26-
};
27-
/**
28-
* Carries details if it is an environment, otherwise `undefined` in case of global interpreters and others.
29-
*/
30-
readonly environment:
31-
| {
32-
/**
33-
* Type of the environment.
34-
*/
35-
readonly type: EnvironmentType;
36-
/**
37-
* Name to the environment if any.
38-
*/
39-
readonly name: string | undefined;
40-
/**
41-
* Uri of the environment folder.
42-
*/
43-
readonly folderUri: Uri;
44-
/**
45-
* Any specific workspace folder this environment is created for.
46-
*/
47-
readonly workspaceFolder: Uri | undefined;
48-
}
49-
| undefined;
50-
/**
51-
* Carries Python version information known at this moment.
52-
*/
53-
readonly version: VersionInfo & {
54-
/**
55-
* Value of `sys.version` in sys module if known at this moment.
56-
*/
57-
readonly sysVersion: string | undefined;
58-
};
59-
/**
60-
* Tools/plugins which created the environment or where it came from. First value in array corresponds
61-
* to the primary tool which manages the environment, which never changes over time.
62-
*
63-
* Array is empty if no tool is responsible for creating/managing the environment. Usually the case for
64-
* global interpreters.
65-
*/
66-
readonly tools: readonly EnvironmentTools[];
67-
};
68-
69-
/**
70-
* Derived form of {@link Environment} where certain properties can no longer be `undefined`. Meant to represent an
71-
* {@link Environment} with complete information.
72-
*/
73-
type ResolvedEnvironment = Environment & {
74-
/**
75-
* Carries complete details about python executable.
76-
*/
77-
readonly executable: {
78-
/**
79-
* Uri of the python interpreter/executable. Carries `undefined` in case an executable does not belong to
80-
* the environment.
81-
*/
82-
readonly uri: Uri | undefined;
83-
/**
84-
* Bitness of the environment.
85-
*/
86-
readonly bitness: Bitness;
87-
/**
88-
* Value of `sys.prefix` in sys module.
89-
*/
90-
readonly sysPrefix: string;
91-
};
92-
/**
93-
* Carries complete Python version information.
94-
*/
95-
readonly version: ResolvedVersionInfo & {
96-
/**
97-
* Value of `sys.version` in sys module if known at this moment.
98-
*/
99-
readonly sysVersion: string;
100-
};
101-
};
102-
103-
type EnvironmentsChangeEvent = {
104-
readonly env: Environment;
105-
/**
106-
* * "add": New environment is added.
107-
* * "remove": Existing environment in the list is removed.
108-
* * "update": New information found about existing environment.
109-
*/
110-
readonly type: 'add' | 'remove' | 'update';
111-
};
112-
113-
type ActiveEnvironmentPathChangeEvent = EnvironmentPath & {
114-
/**
115-
* Workspace folder the environment changed for.
116-
*/
117-
readonly resource: WorkspaceFolder | undefined;
118-
};
119-
120-
/**
121-
* Uri of a file inside a workspace or workspace folder itself.
122-
*/
123-
type Resource = Uri | WorkspaceFolder;
124-
125-
type EnvironmentPath = {
126-
/**
127-
* The ID of the environment.
128-
*/
129-
readonly id: string;
130-
/**
131-
* Path to environment folder or path to python executable that uniquely identifies an environment. Environments
132-
* lacking a python executable are identified by environment folder paths, whereas other envs can be identified
133-
* using python executable path.
134-
*/
135-
readonly path: string;
136-
};
137-
138-
/**
139-
* Tool/plugin where the environment came from. It can be {@link KnownEnvironmentTools} or custom string which
140-
* was contributed.
141-
*/
142-
type EnvironmentTools = KnownEnvironmentTools | string;
143-
/**
144-
* Tools or plugins the Python extension currently has built-in support for. Note this list is expected to shrink
145-
* once tools have their own separate extensions.
146-
*/
147-
type KnownEnvironmentTools =
148-
| 'Conda'
149-
| 'Pipenv'
150-
| 'Poetry'
151-
| 'VirtualEnv'
152-
| 'Venv'
153-
| 'VirtualEnvWrapper'
154-
| 'Pyenv'
155-
| 'Unknown';
156-
157-
/**
158-
* Type of the environment. It can be {@link KnownEnvironmentTypes} or custom string which was contributed.
159-
*/
160-
type EnvironmentType = KnownEnvironmentTypes | string;
161-
/**
162-
* Environment types the Python extension is aware of. Note this list is expected to shrink once tools have their
163-
* own separate extensions, in which case they're expected to provide the type themselves.
164-
*/
165-
type KnownEnvironmentTypes = 'VirtualEnvironment' | 'Conda' | 'Unknown';
166-
167-
/**
168-
* Carries bitness for an environment.
169-
*/
170-
type Bitness = '64-bit' | '32-bit' | 'Unknown';
171-
172-
/**
173-
* The possible Python release levels.
174-
*/
175-
type PythonReleaseLevel = 'alpha' | 'beta' | 'candidate' | 'final';
176-
177-
/**
178-
* Release information for a Python version.
179-
*/
180-
type PythonVersionRelease = {
181-
readonly level: PythonReleaseLevel;
182-
readonly serial: number;
183-
};
184-
185-
type VersionInfo = {
186-
readonly major: number | undefined;
187-
readonly minor: number | undefined;
188-
readonly micro: number | undefined;
189-
readonly release: PythonVersionRelease | undefined;
190-
};
191-
192-
type ResolvedVersionInfo = {
193-
readonly major: number;
194-
readonly minor: number;
195-
readonly micro: number;
196-
readonly release: PythonVersionRelease;
197-
};
198-
199-
interface IExtensionApi {
200-
ready: Promise<void>;
201-
debug: {
202-
getRemoteLauncherCommand(host: string, port: number, waitUntilDebuggerAttaches: boolean): Promise<string[]>;
203-
getDebuggerPackagePath(): Promise<string | undefined>;
204-
};
205-
environments: {
206-
getActiveEnvironmentPath(resource?: Resource): EnvironmentPath;
207-
resolveEnvironment(
208-
environment: Environment | EnvironmentPath | string,
209-
): Promise<ResolvedEnvironment | undefined>;
210-
readonly onDidChangeActiveEnvironmentPath: Event<ActiveEnvironmentPathChangeEvent>;
211-
};
212-
}
7+
import { PythonExtension, ResolvedEnvironment } from '@vscode/python-extension';
2138

2149
export interface IInterpreterDetails {
21510
path?: string[];
@@ -219,19 +14,13 @@ export interface IInterpreterDetails {
21914
const onDidChangePythonInterpreterEvent = new EventEmitter<IInterpreterDetails>();
22015
export const onDidChangePythonInterpreter: Event<IInterpreterDetails> = onDidChangePythonInterpreterEvent.event;
22116

222-
async function activateExtension() {
223-
const extension = extensions.getExtension('ms-python.python');
224-
if (extension) {
225-
if (!extension.isActive) {
226-
await extension.activate();
227-
}
17+
let _api: PythonExtension | undefined;
18+
async function getPythonExtensionAPI(): Promise<PythonExtension | undefined> {
19+
if (_api) {
20+
return _api;
22821
}
229-
return extension;
230-
}
231-
232-
async function getPythonExtensionAPI(): Promise<IExtensionApi | undefined> {
233-
const extension = await activateExtension();
234-
return extension?.exports as IExtensionApi;
22+
_api = await PythonExtension.api();
23+
return _api;
23524
}
23625

23726
export async function initializePython(disposables: Disposable[]): Promise<void> {
@@ -275,7 +64,7 @@ export async function getDebuggerPath(): Promise<string | undefined> {
27564
}
27665

27766
export async function runPythonExtensionCommand(command: string, ...rest: any[]) {
278-
await activateExtension();
67+
await getPythonExtensionAPI();
27968
return await commands.executeCommand(command, ...rest);
28069
}
28170

src/common/server.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { traceError, traceInfo, traceVerbose } from './logging';
1515
import { getDebuggerPath } from './python';
1616
import { getExtensionSettings, getGlobalSettings, ISettings } from './settings';
1717
import { getLSClientTraceLevel } from './utilities';
18-
import { isVirtualWorkspace } from './vscodeapi';
18+
import { getDocumentSelector } from './vscodeapi';
1919
import { updateStatus } from './status';
2020
import { unregisterEmptyFormatter } from './nullFormatter';
2121

@@ -62,14 +62,7 @@ async function createServer(
6262
// Options to control the language client
6363
const clientOptions: LanguageClientOptions = {
6464
// Register the server for python documents
65-
documentSelector: isVirtualWorkspace()
66-
? [{ language: 'python' }]
67-
: [
68-
{ scheme: 'file', language: 'python' },
69-
{ scheme: 'untitled', language: 'python' },
70-
{ scheme: 'vscode-notebook', language: 'python' },
71-
{ scheme: 'vscode-notebook-cell', language: 'python' },
72-
],
65+
documentSelector: getDocumentSelector(),
7366
outputChannel: outputChannel,
7467
traceOutputChannel: outputChannel,
7568
revealOutputChannelOn: RevealOutputChannelOn.Never,

0 commit comments

Comments
 (0)