-
Notifications
You must be signed in to change notification settings - Fork 91
Refactor watermark #65
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
Conversation
* sort imported modules * use dedent to indent multi-line string
* get information from each function separately * Combine different information in one function instead of all over the object * Sort imports and other part
.pep8speaks.yml
Outdated
@@ -0,0 +1,2 @@ | |||
pycodestyle: | |||
max-line-length: 88 # To be compatible with black |
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.
curious: why particularly 88, and what's black?
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.
Well, generally the community answer to make the PEP8 code style was to use a lint tool like flake8
or pycodestyle
and etc. These tools only report the problem, do not fix them. On the other hand, black
is an auto-code-formatter (as they say).
You just run it and it automatically fixes the problem. There are also some Jupyter extensions, such as this one, that run black
inside Jupyter notebook.
And by the way, black
uses 88, by default, characters per line.
You can read more about it on their documentation site. It's a great tool and I hope you’ll check it out!
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.
black is awesome. Look at https://www.thoughtworks.com/radar/techniques/opinionated-and-automated-code-formatting and https://www.youtube.com/watch?v=esZLCuWs_2Y
Also isort
Hello @GreatBahram! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2020-11-19 16:01:15 UTC |
Nice work, I agree that the restructuring (and use of lists) will make everything a bit more manageable. |
If the official code style is now "black", can you update the Readme to include this? e.g. there's a developer guidelines section now. |
Thanks for the clarification @GreatBahram . The tool (black) looks really nice. I would prefer to stick with the PEP8 80-char though. Personally, I also have a slight preference for the "# Aligned with opening delimiter" style in PEP8. I.e., I find more readable than Both are good styles, and I also sometimes use the latter, but in this case, I really think the upper one is a tad more readable. No worries, I can make these little changes (just personal preferences) to this otherwise awesome PR. |
Just going through code again, I really like this refactoring. Also, thanks for improving the output style (capitalization etc.)! Awesome PR! |
Thank you so much for your compliment! |
Hi there, @rasbt
I refactored the watermark module:
watermark
method as it was._generate_formatted_text
, which is fine in my opinion, even if someone wants to elaborate it to produce much fancy string it is easier than before.PS: I added a
.pep8speaks
file to increase the line length to 88. I hope you find this pull request useful.Thanks