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

Fix: allow whitespace in list of extras for a package #2985

Merged
merged 3 commits into from Sep 28, 2020

Conversation

finswimmer
Copy link
Member

@finswimmer finswimmer commented Sep 27, 2020

This fix allows having whitespaces in the list of extras during poetry add, e.g. poetry add databases[postgresql, sqlite].

Pull Request Check List

Resolves: #2980

  • Added tests for changed code.
  • Updated documentation for changed code.

@finswimmer finswimmer requested a review from a team Sep 27, 2020
def test_add_package_with_extras_and_whitespace(app):
command = app.find("init")
result = command._parse_requirements(["databases[postgresql, sqlite]"])
Copy link
Member

@abn abn Sep 27, 2020

Choose a reason for hiding this comment

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

Suggested change
def test_add_package_with_extras_and_whitespace(app):
command = app.find("init")
result = command._parse_requirements(["databases[postgresql, sqlite]"])
def test_add_package_with_extras_and_whitespace(tester):
result = tester._parse_requirements(["databases[postgresql, sqlite]"])

Copy link
Member Author

@finswimmer finswimmer Sep 28, 2020

Choose a reason for hiding this comment

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

It look like it must be test._command._parse_requirements ...

@@ -373,7 +373,7 @@ def _parse_requirements(
for requirement in requirements:
requirement = requirement.strip()
extras = []
extras_m = re.search(r"\[([\w\d,-_]+)\]$", requirement)
extras_m = re.search(r"\[([\w\d,-_ ]+)\]$", requirement)
Copy link
Member

@abn abn Sep 27, 2020

Choose a reason for hiding this comment

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

Shoud we just use \s here?

Copy link
Member Author

@finswimmer finswimmer Sep 28, 2020

Choose a reason for hiding this comment

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

The range of \s is to wide. I don't think supporting e.g. tab characters here.

Copy link
Member

@abn abn Sep 28, 2020

Choose a reason for hiding this comment

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

Hmm, I guess for this case it is fine (ish). For PEP 508, whitespace typically refers to "non-line breaking whitespace". That is narrowier than \s and but wider than . I doubt anyone is going to type in foo[a, \t b] 😏

@finswimmer finswimmer force-pushed the issue-2980-whitspace-extra-list branch from 56bc7f5 to cddbcad Compare Sep 28, 2020
@finswimmer finswimmer requested a review from abn Sep 28, 2020
abn
abn approved these changes Sep 28, 2020
Copy link
Member

@abn abn left a comment

Issue talks about add command but the fix is in init command?

abn
abn approved these changes Sep 28, 2020
@abn abn merged commit 5b94aa8 into python-poetry:master Sep 28, 2020
@abn abn added the kind/bug Something isn't working as expected label Sep 28, 2020
@abn abn added this to the 1.1 milestone Sep 28, 2020
@abn abn added this to In progress in 1.1 via automation Sep 28, 2020
@abn abn moved this from In progress to Done in 1.1 Sep 28, 2020
@sdispater sdispater mentioned this pull request Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working as expected
Projects
No open projects
1.1
  
Done
Development

Successfully merging this pull request may close these issues.

parsing issue when we have extras with poetry add
2 participants