-
Notifications
You must be signed in to change notification settings - Fork 615
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
Implement --emit-index-annotation
to annotate source index for each package
#2926
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a068b5f
add index in pip compile output
ChannyClaus 296000f
clippy
ChannyClaus d7ef99b
index annotation gated behind a flag
ChannyClaus da4fa22
ignore clippy
ChannyClaus 94b87b3
add the simplest test case
ChannyClaus f528f61
cleanup + fix index annotation for top level requirement
ChannyClaus dc0ecc9
clippy
ChannyClaus da83f30
add another test with multiple indices
ChannyClaus 2c50f89
indices -> indexes
ChannyClaus 5c02973
Use IndexUrl
charliermarsh 6305a76
Rename flag, add more tests
charliermarsh aa1c841
Add test
charliermarsh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -493,6 +493,7 @@ impl ResolutionGraph { | |
|
||
/// A [`std::fmt::Display`] implementation for the resolution graph. | ||
#[derive(Debug)] | ||
#[allow(clippy::struct_excessive_bools)] | ||
pub struct DisplayResolutionGraph<'a> { | ||
/// The underlying graph. | ||
resolution: &'a ResolutionGraph, | ||
|
@@ -505,6 +506,8 @@ pub struct DisplayResolutionGraph<'a> { | |
/// Whether to include annotations in the output, to indicate which dependency or dependencies | ||
/// requested each package. | ||
include_annotations: bool, | ||
/// Whether to include indices in the output, to indicate which index was used for each package. | ||
include_indices: bool, | ||
/// The style of annotation comments, used to indicate the dependencies that requested each | ||
/// package. | ||
annotation_style: AnnotationStyle, | ||
|
@@ -518,19 +521,22 @@ impl<'a> From<&'a ResolutionGraph> for DisplayResolutionGraph<'a> { | |
false, | ||
false, | ||
true, | ||
false, | ||
AnnotationStyle::default(), | ||
) | ||
} | ||
} | ||
|
||
impl<'a> DisplayResolutionGraph<'a> { | ||
/// Create a new [`DisplayResolutionGraph`] for the given graph. | ||
#[allow(clippy::fn_params_excessive_bools)] | ||
pub fn new( | ||
underlying: &'a ResolutionGraph, | ||
no_emit_packages: &'a [PackageName], | ||
show_hashes: bool, | ||
include_extras: bool, | ||
include_annotations: bool, | ||
include_indices: bool, | ||
annotation_style: AnnotationStyle, | ||
) -> DisplayResolutionGraph<'a> { | ||
Self { | ||
|
@@ -539,6 +545,7 @@ impl<'a> DisplayResolutionGraph<'a> { | |
show_hashes, | ||
include_extras, | ||
include_annotations, | ||
include_indices, | ||
annotation_style, | ||
} | ||
} | ||
|
@@ -576,6 +583,13 @@ impl<'a> Node<'a> { | |
Node::Distribution(name, _, _) => NodeKey::Distribution(name), | ||
} | ||
} | ||
|
||
fn index(&self) -> Option<String> { | ||
match self { | ||
Node::Editable(_, _) => None, | ||
Node::Distribution(_, dist, _) => dist.index(), | ||
} | ||
} | ||
} | ||
|
||
impl Verbatim for Node<'_> { | ||
|
@@ -714,6 +728,14 @@ impl std::fmt::Display for DisplayResolutionGraph<'_> { | |
// Write the line as is. | ||
writeln!(f, "{line}")?; | ||
} | ||
|
||
if self.include_indices && node.index().is_some() { | ||
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. should this conditional include 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. I think it's okay as-is. |
||
writeln!( | ||
f, | ||
"{}", | ||
format!(" # from {}", node.index().unwrap()).green() | ||
)?; | ||
} | ||
} | ||
|
||
Ok(()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I know it's tedious but I'm going to change this to
indexes
to match the terminology that pip uses in its documentation.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.
/shrug i can run through these real quick
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.
Thanks!