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

Add linter and code formatter #88

Closed
Ttayu opened this issue Feb 10, 2019 · 3 comments
Closed

Add linter and code formatter #88

Ttayu opened this issue Feb 10, 2019 · 3 comments

Comments

@Ttayu
Copy link
Contributor

Ttayu commented Feb 10, 2019

Hi, thanks for sharing your code.
Why not use linter and formatter for keeping code format?
I think it is just personal preference on which configuration to take or which formatter to choose.
For example, as a formatter I recommend yapf.
Please by all means take advantage :)

@glenn-jocher
Copy link
Member

glenn-jocher commented Feb 10, 2019

Ok, I got Atom's YAPF plugin working, and was surprised to see all the lines wrapped to 80 characters. For some reason I thought PEP8 was 120 character-line compliant, since PyCharm defaults to this line wrap length when running their default reformatter. It turns out PyCharm does not enforce PEP8 line length by default though.
https://www.jetbrains.com/help/pycharm/reformatting-source-code.html

Unfortunately I wrote the whole repo with 120 character lines in mind, so the YAPF reformat really destroys much of the carefully crafted code I had written over the last year.

If YAPF is really industry standard then logically I should adopt it as well for maximal readability and commonality. Perhaps there is some manual reformatting I can do to reduce the impact of the change prior to the switchover.

@Ttayu
Copy link
Contributor Author

Ttayu commented Feb 11, 2019

Thanks with comments.
It may be good to choose a plug-in that is easy to install.
maybe, the following procedure gives one idea of how to install formatter.
https://blog.godatadriven.com/black-formatting-selection

pycharm settings for example
(this is japanese page...https://qiita.com/Chanmoro/items/3f20a1adf260c5ddf7dd)
(https://mail.python.org/pipermail/ncr-python.in/2015-December/001278.html)
[Settings]->[Tools]->[File Watchers]->[+(left below)]
File Type -> Python
Program -> eg. /path/to/bin/yapf
Arguments -> --style='{ based_on_style: google, column_limit: 120 }'
but I recommend that you put configuration file in your project home directory.

yapf(google) vs yapf(facebook) vs black
https://blog.godatadriven.com/black-formatting-selection

@glenn-jocher
Copy link
Member

@Ttayu thanks for the suggestions and resources. I appreciate the insight into different formatting options. I'll consider your recommendations and evaluate the best fit for the project. It's important to maintain code readability whilst adhering to industry standards, and your input is valuable for this decision-making process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants