-
-
Notifications
You must be signed in to change notification settings - Fork 268
flake8 max line length #46
Comments
I think 80 should be a target to try for, but I don't think a longer line should cause errors. |
The question is that we are doing PEP8 compliance for all repositories now, so we can set the max line as we want, because we are the ones we are going to deal with it. Then, respect this max line length is easier for future contributions. Dont you think? |
Citing PEP8 :
And is also states:
It has been discussed in the ML, and the opinions were very divided. Then, the status quo is pure PEP8 79 chars. |
But it was rarely enforced. As someone who has ported a lot of our code to pep8, I guarantee it. I started travis scripts with line-length of 120 so there would be less resistance to adopting the tests, while still pointing out ridiculously horizontal code. We, however kept it as a variable with the intention of changing it when such a agreement of line length could be met. The main problem in our case is column declaration, especially the help texts and most of our function signatures. The rest of the code is easy to keep under 80. Here is a typical function signature in odoo: def onchange_currency_amount(self, cr, uid, ids, currency_amount, currency_id, context=None): The line is 98 characters long. The variable names are not exceedingly long, but you can see how a well-styled function could still surpass this easily. The question is, which is better style? That line or the broken up version: def onchange_currency_amount(
self, cr, uid, ids, currency_amount, currency_id, context=None): |
I did my share of fixes in Launchpad for reviewers requiring PEP8, so my personal experience is that under OCA taht was expected. In fact, when migrating to v8 my post-OCA modules barely need any PEP8 fixing. The 80 char limit may look aggressive when you're not used to it, but you quickly get to know how to handle it. And, IMO, in the end it does helps you to write better code. |
Also, the new API does help with the long lines problem |
@pedrobaeza would you mind making a table in the original post so we can know who votes for which length |
Done. May I put in it mail list votes? |
Maybe, they should get notified if you tag them, so if they change their minds they should chime in here. |
Updated, but I think it's very clear, don't you? |
The PEP8 line length limit should be imposed only for 8.0 branches. |
OCB is a different monster, because we have no control over the style of odoo and OCB tries not to steer away from it. I don't think we should ever check code on diffs in OCA, it would put too much responsibility on devs trying to fix small things. We can create an environment where the style is uniform, we should do this. |
I agree with @bwrsandman. Regards. |
There's space for discussion there, but personally I don't see the point for accepting new v7 modules not PEP8 compliant, now that we have the tooling to manage that. And I can't see the trouble about adding a few extra breaklines on the lines you edit in smaller contributions. |
We don't* accept modules non compliant o.O * With the exception in line lengths and a few other Odoo specific exceptions and repo not yet set-up with travis We fix pep8 with the addition of travis files or a commit after, whether the limit is 80 or 120, we just make sure the tests are green so subsequent PRs follow the same style rules. |
@bwrsandman Not sure if I'm following you: you mean you agree checking PEP8 on diffs for pre-v8 branches? |
according to OCA#46
@dreispt I don't understand your last comment. I don't agree on checking PEP8 diffs in any case where we have the power to fix pep8 on the entire projects. What we have been doing on each project and on each branch is setup automated tests, then fix the style. Any PR is then tested as a whole. If PEP8 errors are in the PR, they are raised because you go from having 0 pep8 errors to having some. No diff required. There is nothing different with the pre-v8 stuff. What I am saying is, on repositories which are set up, we do not accept PRs which do not follow OCA pep8 (which, for now has a relaxed line length rule). |
My proposal:
|
@eLBati Why would we ever accept red PRs? All subsequent PRs will be red. Also what you propose makes no sense: As someone who has spent a great deal of time fixing pep8 on 7.0 and 6.1 branches, I find it quite outrageous to relax the code style practice on v7. Pep8 diffs will only show errors on the modified lines, it will not report side effects on later lines, say if you change a variable name and forget to change it later in a function. The same is true about unused imports. People will find a way arond the tests. Not to mention, how are going to test the overall health of the projects (travis builds on branches, not on PRs). Let it be known I am completely against using diff pep8 on OCA module, and accepting red PRs. |
Because of old (already present) non-PEP8 modules. I someone makes a PR in order to fix a v7 module or to add a module to a v7 branch, I would not force them/us to fix all that non-PEP8 code before merging that PR. |
Why don't you fix the pep8 on l10n-italy instead of messing with the dynamic of the entire OCA umbrella? Seriously, it's one PR that will have all the problems of a non-stable check. This is what has been done to l10n-canada, server-tools, program, travel-mgmt, management-system, etc. Non-PEP8 code should not be in OCA branches, the move to travis is to fix it across the board. What you're proposing makes it (arguably) more conveinant for repos which aren't PEP8 compliant and less conveinant for repos which already are. It is not sustainable and fixes a short term problem. Just fix your v7 branches, you can take those modifications and put them to your v8 branches. If you need help fixing pep8 in l10n-italy, I can do it for you, I've already fixed a couple dozen branches. |
I agree: why accept red PRs. So let me improve on @eLBati 's proposal:
The third point can be achieved by checking PEP8 only for diff "+" lines:
|
My argument is: don't make that standard for v7 branches. |
On 07/25/2014 02:55 PM, Sandy wrote:
Actually, the majority of OCA v7 (and previous) branches contains With my proposal, I intended to unload the work of contributors in order But, if we have enough contributors (or few contributors very active
You would be very kind 🙏 |
On 07/25/2014 03:28 PM, Daniel Reis wrote:
That's what I meant too. Sorry if I was not clear |
I understood what you meant, that's what I just don't feel like the benefits outweigh the issues. Converting to pep8 should be our (maintainers) top priority after adding travis tests, it's part of the process. Those less used repos don't have travis set up, therefore there are no problems with failing tests. To add travis and not fix pep8 (and tests, for that matter) is, and should be seen as a job half done. To implement this would hurt us in the long run when diff related issues start popping up. |
That's at the heart of the issue: it's not. |
What about failing tests, then? Should we abandon that? Because for as many module that are not pep8 compliant, there are almost as many which fail their own yml test, unittests and installs. |
Module tests are not affected - they keep being checked in any of the above scenarios. |
They have the same problem. When you add travis tests, you will have modules failing pep8 and modules failing tests. When adding .travis.yml you have to fix failing tests, why not pep8? |
Because failing tests mean code errors, PEP8 means not meeting a style guide. In principle you're right: everything should be made PEP8 compliant. |
You can see the build details. There are three sections: Style, Install and Tests. As a reviewer, you should look at the details even when the tests are green, due to the abundance of false positives and false negatives. It is clearly shown in the log if the style is causing the error. Some people do spend time fixing the style, and for us, this is the best way to tell. Instead of arguing about this, why don't we just fix what is broken, so we can at least say we follow our own guidelines? |
Hello, I think it's cool to be green on PEP-8 in v8 and also be very strict with the extra modules we will accept. As for 7.0, I think we should not blind ourselves wasting to much resource on PEP-8 (except may be for the core modules) as it's better to focus on v8 and conceptual things when we still have a few weeks to decide bckaward incompatible changes for the next 18 months. |
@rvalyi How do you vote? line length = 80, 100, 120 or other? |
In all the time you have passed discussing about this, you may convert a couple of repositories to full PEP8 compliant ;) For my part, I consider v7 branches for being full PEP8 as a requirement, and I compromise to convert a lot of them. It's not too much work, so I think we can stop already this debate. Regards. |
@bwrsandman I vote 80 at least for v8 (new API helps) but I'm not bigot about it, so I don't want to annoy people with my preference here. |
Please, let's make the merge #47 so that I can start making PEP8 some branches this weekend. |
I agree. Eric Caudal On 07/25/2014 08:55 PM, Sandy wrote:
|
for the record, the reason I originally set the line length limit in the code was to ease having green builds. I'm in favor of 80char for v8. And to be pragmatic, I'm ready to accept a slightly relaxed rule for v7 (say 100), if there is a consensus that it is not realistic to require maintainers to do the work. I myself am in favor of doing that work (as a maintainer), because a clean code base and green builds is worth it. |
100% with you on this. It's good style and it doesn't really impact performance |
The issue is solved, I am closing this. |
I'm a bit late on the debate, but I noticed that the line length configured in the script is 80 but it should be 79 actually: https://github.com/OCA/maintainer-quality-tools/blob/master/travis/travis_run_flake8#L5 My personal opinion: I do support the 79 chars limit. But in some (rare) cases, I still think that a line a bit more long could be more readable, this is subjective and left to human judgment though. Tools such as flake8 will always rise the red flag when I would accept a line a bit longer if I find it more readable. |
Would it be any good to be able to set the line limit in the |
On 12/08/2014 11:54, Daniel Reis wrote:
Eg, I'd be in favor of raising the line length for version 6.1, because Alexandre Fayolle Camptocamp France SAS |
I second @gurneyalex |
As seen here (https://github.com/OCA/carrier-delivery/pull/19/files#r15347475), we are discussing maximum line length to check by flake8.
(with votes from mailing list: http://openerp-community.2306076.n4.nabble.com/Openerp-community-Coding-Guidlines-long-lines-td4643741.html)
The text was updated successfully, but these errors were encountered: