Open FooBarQuaxx opened 7 years ago
The code is in the Google Python style, which is basically pep8 with 2 space indents and CapWords for function and method names. All the contributions will have to be in that style going forward, at least until the point where there's a significant amount of code not coming from me.
I changed this bug to be to set up auto-formatting. I have experimented with yapf but didn't apply it to all the code yet. I do want there to be a consistent style and for contributors to not have to worry about reformatting their code.
When the C++ code lands it will use clang-format as well.
Now running flake8, thanks @cclauss. It doesn't auto-format but it catches significant errors.
I'm still somewhat interested in yapf, but it's not a big priority.
@andychu Hiya, I looked around for an Emacs mode for Google's python style, and couldn't find one anywhere. This seems to be the canonical source: https://github.com/google/styleguide
Based on that, it looks like Google doesn't use 2-space indentation for python anymore -- so they recommend using the default Emacs python mode style now. I don't know if that's enough reason to change the oilshell project style.
Assuming it's not, are you aware offhand of any Emacs mode files floating around for Google's old python style?
Sorry I'm not sure, I'm a vim user :-)
I will say that I accept any PR that passes tests :) The functionality is the more important part.
I may go back and update the style with subsequent commits. Or if there are consistent contributors then we can automate things more.
Right now flake8 runs in Travis, and I keep it green. It could be made more strict in the future.
Also this issue keeps getting closed because I type #1
in other contexts!
I'm reopening it although there a lot of other things that I think would benefit contributors more, e.g.
https://oilshell.zulipchat.com/#narrow/stream/121539-oil-dev/topic/Dev.20Dependencies.20Problem
Ok, thanks, no worries. I just didn't want to make a mess once I figure out a good way to contribute, but I'm sure I'll manage.
The Python Software Foundation is proposing the canonical way to format Python code and it is called black. It has integrations to Emacs, Vim, other editors. pre-commit hooks, and CI systems. Let's follow Google's lead for the formatting of Go code with gofmt but let's follow the PSF's lead for the formatting of Python code.
test/lint.sh format-oil
does this for C++
Oil bundles legacy Python which went end-of-life on 1/1/2020. The black formatting tool for Python code will not run on Python 2.
Black can be installed by running pip install black. It requires Python 3.6.0+ to run but you can reformat Python 2 code with it, too.
https://pypi.org/project/black/
In any case this is a moot point until people who have contributed patches want it . It could be black or something else they prefer
While exploring the code, I couldn't help but notice that the code style is not pep8 compliant. Following the standard way of writing code is very advantageous as it allow for gentle learning curve for someone how wants to contribute to the project.