-
Notifications
You must be signed in to change notification settings - Fork 250
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
Handwritten parser for parsing requirements #484
Conversation
Two quick things (I haven't really reviewed any of the code). One, looks like there are some CI failures. Two, do we want |
+1 to both the things that Brett said. |
That CI failures seem to be because of the use of |
All that said, this is super cool and I'm very excited to see this progressing! Thanks for picking this up @hrnciar! ^>^ |
fe754f3
to
3062470
Compare
Pulling this out of draft status, given there is a review request. |
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.
This is pretty much a desk review -- I haven't cloned and poked at this yet; I'll do that once the linters are happy with this PR.
I don't think I have anything to say about the parsing logic other than that it looks correct, and that CI being happy is a good sign. :)
I think we can/should bundle this change with the legacy version removal, which... I'll pick back up once this lands.
A gentle ping. |
packaging/_parser.py
Outdated
MarkerType = Tuple[Union[Variable, Value], Op, Union[Variable, Value]] | ||
# MarkerAtom = Union[MarkerType, List["MarkerAtom"]] |
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.
These names are a bit confusing. Perhaps use MarkerAtom
, MarkerItem
, MarkerVar
and MarkerList
, corresponding with their parse rules?
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 realized that I forget to rename the names just after I pushed it. I took into account your latest comment and pushed a new change, PTAL.
(FYI: The CI isn't running due to merge conflicts with |
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.
One of the few things that Black can't check syntactically, the docstrings unfortunately don't match the style in the rest of the project (both the newline structure and the sentences need to end with proper punctuation).
5a961ae
to
4f52bac
Compare
I've addressed some remarks, but there is still some stuff to do. I am heading to EuroPython tomorrow so I will continue next week when I am back. If anyone would like to meet in Dublin and have a chat IRL feel free to ping me :). |
packaging/_parser.py
Outdated
|
||
def parse_named_requirement(requirement: str) -> Requirement: | ||
""" | ||
named_requirement: IDENTIFIER extras (URL_SPEC | specifier) (END | SEMICOLON marker_expr END)? |
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.
named_requirement: IDENTIFIER extras (URL_SPEC | specifier) (END | SEMICOLON marker_expr END)? | |
named_requirement: IDENTIFIER extras (URL_SPEC | specifier) (SEMICOLON marker_expr )? END |
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.
LGTM, assuming @encukou's suggestion is applied!
And... you pacify flake8 -- in whatever manner you deem appropriate.
6c8ed42
to
a29816f
Compare
Tokenizer uses _version_regex_str to detect 'VERSION' token.
I've improved the docstrings and fixed a couple of nitpicks. Unless there is something else to improve, I think, we are done. |
@brettcannon could you please do a review? Is there something specific I should improve? I'd like to finish this PR. Thank you. |
@hrnciar it's in my review queue, but if @pradyunsg wants to merge w/o a review for me then I am totally fine with that. |
Changelog entry: #581 |
This is great for CLIs too 🙂 pypa/hatch#449 (comment) |
Hello,
I wrote a parser for packaging that should allow us to remove the dependency on pyparsing.
I am opening this as a draft as this is my first PR into packaging and I would love to hear feedback from you on what to improve in my PR.
Thank you.
Fixes: #468