-
Notifications
You must be signed in to change notification settings - Fork 46
Distinguish between direct and transitive packages #1530
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
base: main
Are you sure you want to change the base?
Changes from all commits
89ffbb3
24ed99d
b61b806
6afd2b1
d9f989d
3f579f5
a47a33d
ab8468b
efcbdb7
6392a2e
8a0e3a8
8283e81
2ddfad4
4632547
21be3e2
ea8bbce
e3a4199
6f35266
b6cec0d
6c9a7e2
1b4483e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -578,6 +578,11 @@ export interface PackageInfo { | |
| * The URIs associated with the package. | ||
| */ | ||
| readonly uris?: readonly Uri[]; | ||
|
|
||
| /** | ||
| * Whether the package is a transitive dependency. | ||
| */ | ||
| readonly isTransitive?: boolean; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -670,9 +675,9 @@ export interface PackageManager { | |
| /** | ||
| * Refreshes the package list for the specified Python environment. | ||
| * @param environment - The Python environment for which to refresh the package list. | ||
| * @returns A promise that resolves when the refresh is complete. | ||
| * @returns A promise that resolves with the refreshed list of packages, or undefined. | ||
| */ | ||
| refresh(environment: PythonEnvironment): Promise<void>; | ||
| refresh(environment: PythonEnvironment): Promise<Package[] | undefined>; | ||
|
|
||
| /** | ||
| * Retrieves the list of packages for the specified Python environment. | ||
|
|
@@ -687,6 +692,20 @@ export interface PackageManager { | |
| */ | ||
| onDidChangePackages?: Event<DidChangePackagesEventArgs>; | ||
|
|
||
| /** | ||
| * Fetches the names of direct (non-transitive) packages for the specified Python environment. | ||
| * | ||
| * **Caveat:** Most package managers cannot track user install intent. For pip, this uses | ||
| * `pip list --not-required` which returns packages with no installed dependents (leaf packages), | ||
| * not necessarily packages the user explicitly installed. For example, if a user runs | ||
| * `pip install flask werkzeug`, werkzeug will still be reported as transitive because flask | ||
| * depends on it. This is a best-effort approximation. | ||
| * | ||
| * @param environment - The Python environment for which to fetch direct package names. | ||
| * @returns A promise that resolves to a set of package name strings, or undefined if not supported. | ||
| */ | ||
| getDirectPackageNames?(environment: PythonEnvironment): Promise<Set<string> | undefined>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it implemented for conda? Seems not covered
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Conda doesn't have a direct mechanism for getting direct packages, only |
||
|
|
||
| /** | ||
| * Clears the package manager's cache. | ||
| * @returns A promise that resolves when the cache is cleared. | ||
|
|
@@ -1029,9 +1048,9 @@ export interface PythonPackageGetterApi { | |
| * Refresh the list of packages in a Python Environment. | ||
| * | ||
| * @param environment The Python Environment for which the list of packages is to be refreshed. | ||
| * @returns A promise that resolves when the list of packages has been refreshed. | ||
| * @returns A promise that resolves with the refreshed list of packages, or undefined. | ||
| */ | ||
| refreshPackages(environment: PythonEnvironment): Promise<void>; | ||
| refreshPackages(environment: PythonEnvironment): Promise<Package[] | undefined>; | ||
|
|
||
| /** | ||
| * Get the list of packages in a Python Environment. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot generated: Two questions on this signature:
Set<string>is unusual on our public API surface;readonly string[]would be more consistent with the rest ofPackageManagerand easier for consumers to serialize/transport.undefined, method returns an emptySet— all need documented semantics. The current consumer treats empty-set as "no info" (via asize > 0guard), which silently drops legitimately-empty results. Likewise, consumers ofPackageInfo.isTransitivecan't distinguishundefinedfromfalse; please document thatundefinedmeans "unknown".