Skip to content

Comments

Add a lowered representation for markers#9341

Merged
charliermarsh merged 1 commit intocharlie/evalfrom
charlie/lower
Nov 25, 2024
Merged

Add a lowered representation for markers#9341
charliermarsh merged 1 commit intocharlie/evalfrom
charlie/lower

Conversation

@charliermarsh
Copy link
Member

Summary

This PR introduces a set of parallel structs to MarkerValueString, MarkerValueExtra, and MarkerValueVersion that remove various pieces of information and representations that shouldn't be available in the marker algebra. To start, I've just removed the invalid extra component from MarkerValueExtra -- there are no other changes to the representation. So, throughout the marker algebra, we can't represent and thus don't have to worry about clauses with invalid extras.

The subsequent changes I plan to make are:

  1. Removing python_version, since we exclusively use python_version_full in the algebra.
  2. Removing the deprecated aliases, such that we re-map to the correct marker value.
  3. Consolidating sys_platform and platform_release (the original motivation).

@charliermarsh
Copy link
Member Author

This does mean that we'll "drop" invalid extras, like extra == "1abc" (not a valid package name), rather than retaining them in the output representation.

.name()
.as_extra()
.is_some_and(|extra| extras.contains(extra)),
)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just an example of the simplification that we get in return. This specific case is obviously not a big win, but changing the representation (such that we have an internal representation that's separate from the exact grammar and how they're parsed) is the crucial piece.

@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Nov 22, 2024
@charliermarsh charliermarsh merged commit 3602e09 into charlie/eval Nov 25, 2024
@charliermarsh charliermarsh deleted the charlie/lower branch November 25, 2024 03:41
@charliermarsh charliermarsh restored the charlie/lower branch November 25, 2024 03:42
charliermarsh added a commit that referenced this pull request Nov 25, 2024
## Summary

This PR introduces a set of parallel structs to `MarkerValueString`,
`MarkerValueExtra`, and `MarkerValueVersion` that remove various pieces
of information and representations that shouldn't be available in the
marker algebra. To start, I've _just_ removed the invalid extra
component from `MarkerValueExtra` -- there are no other changes to the
representation. So, throughout the marker algebra, we can't represent
and thus don't have to worry about clauses with invalid extras.

The subsequent changes I plan to make are:

1. Removing `python_version`, since we exclusively use
`python_version_full` in the algebra.
2. Removing the deprecated aliases, such that we re-map to the correct
marker value.
3. Consolidating `sys_platform` and `platform_release` (the original
motivation).
Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

nit: Maybe ParsedMarker<...> vs CanonicalMarlker<...>?

Code looks good

charliermarsh added a commit that referenced this pull request Nov 26, 2024
## Summary

This PR introduces a set of parallel structs to `MarkerValueString`,
`MarkerValueExtra`, and `MarkerValueVersion` that remove various pieces
of information and representations that shouldn't be available in the
marker algebra. To start, I've _just_ removed the invalid extra
component from `MarkerValueExtra` -- there are no other changes to the
representation. So, throughout the marker algebra, we can't represent
and thus don't have to worry about clauses with invalid extras.

The subsequent changes I plan to make are:

1. Removing `python_version`, since we exclusively use
`python_version_full` in the algebra.
2. Removing the deprecated aliases, such that we re-map to the correct
marker value.
3. Consolidating `sys_platform` and `platform_release` (the original
motivation).
charliermarsh added a commit that referenced this pull request Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants