Skip to content

API for Python Projects/Workspaces #23156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karthiknadig opened this issue Apr 1, 2024 · 1 comment
Closed

API for Python Projects/Workspaces #23156

karthiknadig opened this issue Apr 1, 2024 · 1 comment
Assignees
Labels
area-api API related issues area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality needs proposal Need to make some design decisions verified Verification succeeded
Milestone

Comments

@karthiknadig
Copy link
Member

karthiknadig commented Apr 1, 2024

import { Uri, Event, WorkspaceFolder } from 'vscode';
/**
 * A python workspace is similar to a VS Code workspace. All workspaces are equal with no notion of
 * active or primary workspace. The main difference from VS Code {@link WorkspaceFolder workspace folder}
 * is that a file can treated like a workspace (see PEP-723 https://peps.python.org/pep-0723/).
 */
export interface PythonWorkspace {
    /**
     * The name of the python workspace. Defaults to the basename of its {@link Uri.path uri-path}
     * if not provided. Typically name of the file or folder.
     */
    readonly name: string;

    /**
     * The associated uri of the python workspace.
     */
    readonly uri: Uri;
}

/**
 * An event that is emitted when {@link PythonWorkspace python workspaces} are added or removed.
 */
export interface PythonWorkspacesChangedEvent {
    /**
     * The python workspaces that have been added.
     */
    readonly added: readonly PythonWorkspace[];

    /**
     * The python workspaces that have been removed.
     */
    readonly removed: readonly PythonWorkspace[];
}

export interface PythonWorkspaces {
    /**
     * [internal] Add python workspaces to the collection.
     *
     * @param pyWorkspace The python workspaces to add.
     *
     */
    addPythonWorkspace(...pyWorkspace: PythonWorkspace[]): void;

    /**
     * [internal] Remove python workspaces from the collection.
     *
     * @param pyWorkspace The python workspaces to remove.
     */
    removePythonWorkspace(...pyWorkspace: PythonWorkspace[]): boolean;

    /**
     * [internal] Create {@link PythonWorkspace python workspace} object for the given uri.
     * * will return the existing workspace if one already exists for the given uri
     *
     * @param uri The uri for which to create the python workspace.
     * @param name The name of the python workspace. Defaults to the basename of the file or folder.
     * @returns The a python workspace.
     */
    createPythonWorkspace(uri: Uri, name?: string): PythonWorkspace;

    /**
     * An event that is emitted when python workspaces are added or removed.
     *
     * **Note:** This event is not fired when workspaces as available in VS Code
     * are loaded for the first time.
     */
    onDidChangePythonWorkspaces: Event<PythonWorkspacesChangedEvent>;

    /**
     * List of {@link PythonWorkspace python workspaces}. Empty if no python workspaces are available.
     */
    readonly workspaces: readonly PythonWorkspace[];

    /**
     * Get the {@link PythonWorkspace python workspace} that contains the given uri.
     * * returns `undefined` when the given uri doesn't match any workspace
     *
     * @param uri An uri.
     * @returns The python workspace or `undefined`.
     */
    getPythonWorkspace(uri: Uri): PythonWorkspace | undefined;
}
@karthiknadig karthiknadig added feature-request Request for new features or functionality area-environments Features relating to handling interpreter environments needs PR Ready to be worked on labels Apr 1, 2024
@karthiknadig karthiknadig added this to the April 2024 milestone Apr 1, 2024
@karthiknadig karthiknadig self-assigned this Apr 1, 2024
@karthiknadig karthiknadig changed the title API review for Python Projects/Workspaces API for Python Projects/Workspaces Apr 1, 2024
@karthiknadig karthiknadig added area-api API related issues needs proposal Need to make some design decisions and removed needs PR Ready to be worked on labels Apr 8, 2024
@karthiknadig
Copy link
Member Author

This is an API proposal. There is nothing to verify here.

@karthiknadig karthiknadig added the verified Verification succeeded label Apr 17, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-api API related issues area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality needs proposal Need to make some design decisions verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

1 participant