Improve PEP-440 support for versions#140
Merged
abn merged 6 commits intopython-poetry:masterfrom Mar 27, 2021
Merged
Conversation
8da58ad to
4c3e46b
Compare
This is a broad change aligning `poetry.core.semver.version.Version` implementation to be closer to PEP-440 that to semver. This adds the foundation for improved dev and local tag support in poetry managed version as well as fix ordering bugs that existed due to the differences between semantic versioning specification and PEP-440. Further, previously used inline copy of `packaging.version.Version` implementation has now been removed in favour of `poetry.core.version.pep440.PEP440Version` implementation.
kasteph
previously approved these changes
Mar 26, 2021
kasteph
approved these changes
Mar 27, 2021
sdispater
reviewed
Mar 29, 2021
Comment on lines
-12
to
-26
| class Parser: | ||
| def __init__(self, grammar: str) -> None: | ||
| self._grammar = grammar | ||
| self._parser: Optional["Lark"] = None | ||
| # Parser: PEP 508 Constraints | ||
| PARSER_PEP_508_CONSTRAINTS = Lark.open( | ||
| GRAMMAR_DIR / "pep508.lark", parser="lalr", debug=False | ||
| ) | ||
|
|
||
| def parse(self, string: str) -> "Tree": | ||
| from lark import Lark | ||
|
|
||
| if self._parser is None: | ||
| self._parser = Lark.open( | ||
| os.path.join(os.path.dirname(__file__), f"{self._grammar}.lark"), | ||
| parser="lalr", | ||
| ) | ||
|
|
||
| return self._parser.parse(string) |
Member
There was a problem hiding this comment.
We need this class to lazily load grammars, otherwise the performance of Poetry will be severely degraded.
Member
There was a problem hiding this comment.
Can you make the changes to add it back?
Member
There was a problem hiding this comment.
Also, I don't think this is the right place to instantiate the parsers.
Merged
3 tasks
|
@abn Is there a way to make This change broke my release process. |
Member
|
PEP 440 mandates alpha is normalized to |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a broad change aligning
poetry.core.semver.version.Versionimplementation to be closer to PEP-440 that to semver. This adds the foundation for improved dev and local tag support in poetry managed version as well as fix ordering bugs that existed due to the differences between semantic versioning specification and PEP-440.Further, previously used inline copy of
packaging.version.Versionimplementation has now been removed in favour ofpoetry.core.version.pep440.PEP440Versionimplementation.Note: This change contains minor breaking changes that will require minimal changes downstream in
poetry. (see python-poetry/poetry#3831)References:
Relates-to: python-poetry/poetry#2543
Relates-to: python-poetry/poetry#1151
Relates-to: python-poetry/poetry#892