-
Notifications
You must be signed in to change notification settings - Fork 251
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
Improve PEP-440 support for versions #140
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.
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) |
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.
We need this class to lazily load grammars, otherwise the performance of Poetry will be severely degraded.
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.
Can you make the changes to add it back?
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.
Also, I don't think this is the right place to instantiate the parsers.
@abn Is there a way to make This change broke my release process. |
PEP 440 mandates alpha is normalized to |
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 ofpoetry.core.version.pep440.PEP440Version
implementation.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