-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Wrap long lines to comply with flake8 E501 #4985
Conversation
Hello @stinodego, thanks a lot for the work you've already done 👍 It took a while but I've found out what's going on with To fix it we can put this in the isort config section in the namespace_packages = ["poetry"] Regarding the string wrappings:
Because fin swimmer |
Hi @finswimmer ! Thanks for your feedback, I will implement the changes you requested. And kudos for finding out what caused that Will redo this PR this weekend. |
0585767
to
8fa7926
Compare
PR has been re-done! Looking forward to your feedback. PS: I see one CI check failing; I don't believe this is something I can fix? |
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.
Looks quite good to me. Thanks a lot 👍
Can you please add the --experimental-string-processing
flag to the list of args for black
in the .pre-commit-config.yaml
?
Done! Had to exclude the There's a few places where the EDIT: Actually, would it not be better to include this setting in the |
This is a very good idea 👍
Hm, I don't see any reasons why we should exclude them. What problems have you faced? |
These scripts do not follow the experimental string formatting rules of I don't mind formatting these scripts too, but I understood that these scripts were 'frozen' and not allowed to be changed. So we should exclude them either in |
It's fine to change these scripts if needed. Here we have just changes of the format. We should not exclude these scripts from We have fixed the failing check in the meantime (Well, actually we drop it). You will need to rebase your branch onto master to pass all checks. |
ea06936
to
4861d42
Compare
All right, rebased and done! |
src/poetry/utils/env.py
Outdated
"\"import sys; print('.'.join([str(s) for s in" | ||
' sys.version_info[:3]]))"', |
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 wonder if we should keep the original format here for better readability. What do you think? (same for the lines 730 and 805, 859)
This can be achieved by #fmt: off/on
(https://stackoverflow.com/a/58584557/9750706)
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.
In this case, because the exact same string is repeated 4 times in this class, I'd suggest defining this as a string constant in the class (next to ENVS_FILE
) called something like VERSION_SCRIPT
.
Then we won't have to wrap it, and won't have to fiddle with black formatting.
(did this in the most recent commit, let me know what you think)
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.
Good idea 👍 I saw there is already a GET_PYTHON_VERSION
at the top of the file. I think we can use this one.
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.
Even better! Adjusted the last commit to use the existing constant.
...or now that I think about it; maybe there is a reason to use a 'one-liner' version here, because it looks like command line arguments? Tests still pass though.
EDIT: I tested some things in a Notebook and I don't think the multi-line version will work, but maybe I am mistaken. We could just add this constant below the GET_PYTHON_VERSION
constant as a GET_PYTHON_VERSION_ONELINER
and use that instead. Avoid the trouble :) (adjusted the commit to this idea)
4bcdee7
to
17c2b04
Compare
17c2b04
to
25a35ac
Compare
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.
Beautiful 👍 🥇 🚀
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Resolves: #4776
Hi! This is my first PR for
poetry
; please let me know how I can improve my work.Because of the nature of the issue being fixed (linting rules), this PR touches a lot of files. There are no functional changes, however, so I figured it would be OK for a single PR. Let me know if you would like me to break it up into smaller PRs (an option would be
tests
first, thensrc
, for example).Changes
(updated 2020-01-08)
.flake8
to remove theE501
error (line too long) from the list of ignored warnings.Addedpoetry
toisort
namespace packages - see discussion below for the reason why.E501
error for some long test function names and the occasional URL/path/hash.black --experimental-string-processing
to handle long strings. Added this functionality topre-commit
.black
did not format (notably strings without spaces).src/poetry/console/commands/source/add.py
: "already exits" -> "already exists"String wrapping approach
(updated 2020-01-07)
I try to be consistent with the formatting guidelines of
black
, and the style of the rest of the code base.For long regular strings that are not handled by
black
, I wrap them using implicit string concatenation, with leading space and if it's an f-string, an 'f' only at the lines where it's required:For multi-line strings, I use backslash breaks with leading space: