Skip to content
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

feat(pip_requirements): Extract flags from package files with no deps #28961

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions lib/modules/manager/pip_requirements/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,43 @@ some-package==0.3.1`;
],
});
});

it('extracts a file with only --index-url flags', () => {
const res = extractPackageFile('--index-url https://example.com/pypi');
expect(res).toMatchObject({
deps: [],
registryUrls: ['https://example.com/pypi'],
});
});

it('extracts a file with only --extra-index-url flags', () => {
const res = extractPackageFile(
'--extra-index-url https://example.com/pypi',
);
expect(res).toMatchObject({
deps: [],
additionalRegistryUrls: ['https://example.com/pypi'],
});
});

it('extracts a file with only -r flags', () => {
const res = extractPackageFile('-r requirements-other.txt');
expect(res).toMatchObject({
deps: [],
managerData: {
requirementsFiles: ['requirements-other.txt'],
},
});
});

it('extracts a file with only -c flags', () => {
const res = extractPackageFile('-c constraints.txt');
expect(res).toMatchObject({
deps: [],
managerData: {
constraintsFiles: ['constraints.txt'],
},
});
});
});
});
8 changes: 7 additions & 1 deletion lib/modules/manager/pip_requirements/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ export function extractPackageFile(
return dep;
})
.filter(is.truthy);
if (!deps.length) {
if (
!deps.length &&
!registryUrls.length &&
!additionalRegistryUrls.length &&
!additionalRequirementsFiles.length &&
!additionalConstraintsFiles.length
) {
return null;
}
const res: PackageFileContent = { deps };
Expand Down