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

Avoid AND-ing multi-term specifiers in marker normalization #4911

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

charliermarsh
Copy link
Member

Summary

Given python_version != '3.8' and python_version < '3.10', the first term was expanded to python_version < '3.8' and python_version > '3.8'. We then AND'd all three terms together. We don't seem to have a way to differentiate between the terms to AND and the terms to OR in the normalization code (it all gets flattened together), so instead this PR expands the expressions at the leaf level and then flattens them at the level above when appropriate.

Closes #4910.

@charliermarsh charliermarsh requested a review from ibraheemdev July 9, 2024 04:42
@charliermarsh charliermarsh added the bug Something isn't working label Jul 9, 2024
@charliermarsh charliermarsh requested a review from BurntSushi July 9, 2024 04:42
// expression.
let mut iter = range.iter().flat_map(VersionSpecifier::from_bounds);
let first = iter.next().unwrap();
if let Some(second) = iter.next() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Painful attempt to avoid allocating a vector in the common case (a single term).

@charliermarsh charliermarsh enabled auto-merge (squash) July 9, 2024 15:55
@charliermarsh charliermarsh merged commit a046d23 into main Jul 9, 2024
49 checks passed
@charliermarsh charliermarsh deleted the charlie/term branch July 9, 2024 16:04
// Look one level deeper for expressions to simplify, as
// `normalize_all` can return `MarkerTree::Or` for some expressions.
MarkerTree::Expression(ref expr) => {
if let Some((key, range)) = keyed_range(expr) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is one level deeper enough? Or do we have to recurse?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python_version != is incorrectly normalized
3 participants