If at some point we reach a majority of the codebase using 4-space/80-col, revisit this to see if we want to just move everything over.
--Thoughts?-- Dirk
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAEoffTARK-kx25HCU8dc1GSb-trGiWEqkaL%2BvuCo7zuywTPRCA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAMGbLiE%2BdR-E3qiRnt0_Xh5n6h3P5RUCE4b1QmG%2BtECJMje%2BMQ%40mail.gmail.com.
Generally seems fine to me, some questions/comments below.On Thu, Mar 21, 2019 at 10:29 PM 'Dirk Pranke' via Chromium-dev <chromi...@chromium.org> wrote:Last fall, agrieve@ started a thread about wanting to use YAPF to auto-format Python code, but we kinda deadlocked debating whether to use 2-space or 4-space indentation (and to a lesser extent whether to enforce 80-cols).(for reference: https://groups.google.com/a/chromium.org/d/topic/chromium-dev/ZnjbblW-vEY/discussion ).Current practice in chromium src is supposed to be 2-space indentation, but there is plenty of code that uses 4-space indentation.PEP-8 style recommends 4-space, as does the current Google external style guide, as does ChromeOS. There is a desire by infra/ops folks to use the same style across both ChromeOS and Chrome.We will also be doing a large-scale pass over all of the Python code as we migrate to Python 3, too.Ideally, I (and some others) would like to reformat all of the code to be auto-formatted, and switch to PEP-8 compliance as part of it.However, some are resistant to changing from 2-space to 4-space just for that reason (feeling that this is needless churn). Some also feel that consistency with internal Google style (which I think still recommend 2-space for legacy reasons) is useful.There is also a related debate over using lower_with_underscore_names_for_methods (PEP-8) instead of MethodsAsCamelCase (legacy internal Google), but I think there is more agreement that using the former in new code is fine.I suggest that deadlocking on this isn't a desireable end state, and I'd really like to get agreement (a) enable auto-formatting,and (b) move forward somehow.We hit similar roadblocks when adopting clang-format, and I suggest we adopt a similar approach here as a result:Proposal:First, consistency with surrounding code is the most important thing.Second, allow various projects to do either 2-space/80 col or 4-space 80 col, and support project-level/directory-level settings for enabling autoformatting and which level of indentation to use.Third, allow projects to bulk-reformat to 4-space if the OWNERS agree that that is desirable (and to mandate lower_with_underscore).Fourth, recommend 4-space/80 col/lower_with_underscore for new projects (matching ChromeOS).What's "project" here? A git repo? A directory in a git repo?
If at some point we reach a majority of the codebase using 4-space/80-col, revisit this to see if we want to just move everything over.Unless there's a concerted effort to make this happen, it won't happen. If there's a concerted effort, it'll likely take a few months.
Thanks for bumping this!We've been running with a //build/android/.style.yapf for a while now, with settings that I think are pretty minimal. I hope to update YAPF's style=chromium to match what's in there (except with 4 space indent).Drawbacks that I've noticed so far:* It doesn't check for quotes (filed a crbug)* It doesn't enforce any naming rules (although looks like pylint can be configured for this)* It sometimes produces questionably formatted code* In this case, the answer is generally to rewrite the code to use more statements, or inject parenthesis.On the whole though, it's been working very well.What you suggest sounds good to me. I'm not sure that we should enable YAPF globally by default (e.g. putting a .style.yapf at the root of the repository), as doing so would enforce that style everywhere that didn't override it with another .style.yapf file. Instead, maybe we should just add it to a few high-traffic places (e.g. //build), and document that it's encouraged via the style guide?
Proposal:First, consistency with surrounding code is the most important thing.Second, allow various projects to do either 2-space/80 col or 4-space 80 col, and support project-level/directory-level settings for enabling autoformatting and which level of indentation to use.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/a75cfab9-ec23-4571-9045-dc4fc60d7d13%40chromium.org.