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

Update handling of breaking around binary operators: W503 vs W504 #498

Closed
IanLee1521 opened this issue Apr 15, 2016 · 14 comments
Closed

Update handling of breaking around binary operators: W503 vs W504 #498

IanLee1521 opened this issue Apr 15, 2016 · 14 comments

Comments

@IanLee1521
Copy link
Member

Based on the discussion that started on python-dev [1] and ended with an update to PEP-8 [2][3], the logic for allowing (preferring really) breaks to occur before rather than after binary operators.

[1] https://mail.python.org/pipermail/python-ideas/2016-April/039774.html
[2] http://bugs.python.org/issue26763
[3] https://hg.python.org/peps/rev/3857909d7956

unixsurfer pushed a commit to unixsurfer/haproxystats that referenced this issue Apr 19, 2016
An recent update[1] on PEP8 allows to break a line before a
binary operator, until pep8 is updated[2] to reflect to that change,
let's ignore it.

[1] https://hg.python.org/peps/rev/3857909d7956
[2] PyCQA/pycodestyle#498
@hai-ld
Copy link

hai-ld commented Apr 20, 2016

How should we implement this patch, interface-wise? There are two options off the top of my head:

  • provide an option to choose the preferred breaking style, with the new style as default
  • or warning when inspected files containing both styles

@methane
Copy link
Contributor

methane commented Apr 20, 2016

My opinion is just stop warning and more permissive about continuation line.
Current pydocstyle is stricter than Guido. There are many cases "this is more readable, but pep8.py doesn't accept it."

See discussion in http://bugs.python.org/issue26763

@warsaw
Copy link

warsaw commented Apr 20, 2016

I also lean toward not warning about it. It seems like it might be good to warn about mixed styles, but I think ultimately that will be more annoying than helpful.

sigmavirus24 added a commit to sigmavirus24/pep8 that referenced this issue Apr 20, 2016
@sigmavirus24
Copy link
Member

#499 is the most straight forward way of solving this. This also allows others who like this rule to re-enable it by selecting it.

@hai-ld
Copy link

hai-ld commented Apr 21, 2016

@sigmavirus24 If I understand it correctly, that means there is no way to:

  • ensure consistent breaking
  • enforce breaking before binary operator

Is it PyCQA's opinion that above points should be pylint's responsibilities?

@sigmavirus24
Copy link
Member

@hai-ld please don't put words in my mouth. The immediate need is to turn this off. In my opinion a new check should be added which is also in the default ignore, otherwise we will cause a lot of problems. This means people will need to enable it by hand. (That said, if we wanted to add the new check in pycodestyle 2.0 we could break it very easily.)

@hai-ld
Copy link

hai-ld commented Apr 21, 2016

@sigmavirus24 I'm sorry if there's any negative connotation in my comments, be assured that it's not intentional (I'm just not a native English speaker). Since you said "#499 is the most straight forward way of solving this", I thought that was the final solution and asked for confirmation.

@sigmavirus24
Copy link
Member

The two comments after yours advocated for not warning about this particular style notion from PEP-0008. In that case, the most straight-forward way to solving the problem of warning about this is to disable it. It's not the end of all discussion though.

sigmavirus24 added a commit to sigmavirus24/pep8 that referenced this issue Apr 23, 2016
sigmavirus24 added a commit to sigmavirus24/pep8 that referenced this issue Apr 30, 2016
This flips the W503 rule to enforce line breaks before binary operators.

Related PyCQA#498
sigmavirus24 added a commit to sigmavirus24/pep8 that referenced this issue May 21, 2016
This flips the W503 rule to enforce line breaks before binary operators.

Related PyCQA#498
@IanLee1521
Copy link
Member Author

Re-opening to allow discovery of this issue instead of new issues being opened.

@IanLee1521 IanLee1521 reopened this May 31, 2016
@IanLee1521 IanLee1521 changed the title Update handling of breaking around binary operators Update handling of breaking around binary operators: W503 vs W504 May 31, 2016
IanLee1521 pushed a commit that referenced this issue Jun 26, 2016
This flips the W503 rule to enforce line breaks before binary operators.

Related #498
IanLee1521 pushed a commit that referenced this issue Jun 26, 2016
This flips the W503 rule to enforce line breaks before binary operators.

Related #498
wmfgerrit pushed a commit to wikimedia/operations-puppet that referenced this issue Nov 29, 2016
Our old version of pep8 produces a warning that goes against
the actual pep8 style guide:
https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator
PyCQA/pycodestyle#498

Change-Id: Iea4612a6608f9de25a1a85c201e5ccc936ec35b7
pointlessone added a commit to pointlessone/pep8 that referenced this issue Dec 29, 2016
2.2.0 (2016-11-14)
------------------

Bugs:

* Fixed E305 regression caused by PyCQA#400;
  PyCQA#593

2.1.0 (2016-11-04)
------------------

Changes:

* Report E302 for blank lines before an "async def";
  PyCQA#556
* Update our list of tested and supported Python versions which are 2.6,
  2.7, 3.2, 3.3, 3.4 and 3.5 as well as the nightly Python build and
  PyPy.
* Report E742 and E743 for functions and classes badly named 'l', 'O',
  or 'I'.
* Report E741 on 'global' and 'nonlocal' statements, as well as
  prohibited single-letter variables.
* Deprecated use of `[pep8]` section name in favor of `[pycodestyle]`;
  PyCQA#591

Bugs:

* Fix opt_type AssertionError when using Flake8 2.6.2 and pycodestyle;
  PyCQA#561
* Require two blank lines after toplevel def, class;
  PyCQA#536
* Remove accidentally quadratic computation based on the number of
  colons. This will make pycodestyle faster in some cases;
  PyCQA#314

2.0.0 (2016-05-31)
------------------

Changes:

* Added tox test support for Python 3.5 and pypy3
* Added check E275 for whitespace on `from ... import ...` lines;
  PyCQA#489 / PyCQA#491
* Added W503 to the list of codes ignored by default ignore list;
  PyCQA#498
* Removed use of project level `.pep8` configuration file;
  PyCQA#364

Bugs:

* Fixed bug with treating `~` operator as binary; PyCQA#383
  / PyCQA#384
* Identify binary operators as unary; PyCQA#484 /
  PyCQA#485

1.7.0 (2016-01-12)
------------------

Changes:

* Reverted the fix in PyCQA#368, "options passed on command
  line are only ones accepted" feature. This has many unintended
  consequences in pep8 and flake8 and needs to be reworked when I have
  more time.
* Added support for Python 3.5. (Issue PyCQA#420 &
  PyCQA#459)
* Added support for multi-line config_file option parsing. (Issue
  PyCQA#429)
* Improved parameter parsing. (Issues PyCQA#420 &
  PyCQA#456)

Bugs:

* Fixed BytesWarning on Python 3. (Issue PyCQA#459)
dblenkus added a commit to dblenkus/resolwe that referenced this issue Jun 6, 2018
Breaks are prefered to occure before rather than after binary operators:
PyCQA/pycodestyle#498

W503 has been added to the default ignore list in the latest version,
but has to be explicitely specified as we override the default option.
dblenkus added a commit to dblenkus/resolwe that referenced this issue Jun 7, 2018
Breaks are prefered to occure before rather than after binary operators:
PyCQA/pycodestyle#498

W503 has been added to the default ignore list in the latest version,
but has to be explicitely specified as we override the default option.
dblenkus added a commit to dblenkus/resolwe that referenced this issue Jun 7, 2018
Breaks are prefered to occure before rather than after binary operators:
PyCQA/pycodestyle#498

W503 has been added to the default ignore list in the latest version,
but has to be explicitely specified as we override the default option.
dblenkus added a commit to dblenkus/resolwe that referenced this issue Jun 26, 2018
Breaks are prefered to occure before rather than after binary operators:
PyCQA/pycodestyle#498

W503 has been added to the default ignore list in the latest version,
but has to be explicitely specified as we override the default option.
nmarley added a commit to nmarley/sentinel that referenced this issue Aug 2, 2018
This commit disables warnings W503 and W504. One of these was added to the
default ignore list because it wasn't clear, and line breaks conflict with
another rule which doesn't allow lines greater than 80 chars. I believe that
disabling these rules (W503 + W504) is the cleaner solution.

See also discussion here: PyCQA/pycodestyle#498
yangle added a commit to yangle/dotfiles that referenced this issue Sep 4, 2018
sampsyo added a commit to beetbox/confuse that referenced this issue Oct 24, 2018
johnduarte pushed a commit to rcbops/molecule-rpc-openstack-post-deploy that referenced this issue Oct 24, 2018
This commit updates code that was styled to comply with [flake8 rule
W503](https://lintlyci.github.io/Flake8Rules/rules/W503.html) to comply
with [W504](PyCQA/pycodestyle#498) instead.
micahjsmith added a commit to MLBazaar/BTB that referenced this issue Nov 1, 2018
We removed all default disabled warnings, but then should add back in W503
and W504 (split after binary operator).

See PyCQA/pycodestyle#498
nmarley added a commit to dashpay/sentinel that referenced this issue Nov 16, 2018
* update pycodestyle to fix broken validation

* use raw strings for regexp input to satisfy linter

The new version of pycodestyle (2.4.0) requires a few more rules to be
satisfied, one of which is Python raw strings for regexp's (which is a good
idea IMO). This commit updates the regular expressions that were previously not
using raw strings, to use them.

* disable line break warnings in pycodestyle

This commit disables warnings W503 and W504. One of these was added to the
default ignore list because it wasn't clear, and line breaks conflict with
another rule which doesn't allow lines greater than 80 chars. I believe that
disabling these rules (W503 + W504) is the cleaner solution.

See also discussion here: PyCQA/pycodestyle#498

* add test to cover DashConfig.slurp_config_file

This ensures the method still works as expected after the raw string change in
comment filter regex.

* submit new simpler format Trigger objects (#43)

* removes remaining SHIM_serialise_for_dashd method (not used any longer)

* changes serialization format of triggers submitted to the new format, which changed serialized trigger size in a test and uncovered a bug in the size check

* fixes a bug in govobj size limit check in superblock creation (use a temp list to check payments, and only add a proposal to the confirmed payments list after size is checked)

* calculate reasonable mock gobject size limit in test

This removes the hard-coded max size in the test. Due to the proposal serialization format changing, this hard-coded limit won't work now, and the test should be more robust anyway.

* remove trigger size limit

* update readme, align w/std-README format (#56)

Also remove specific versions to align w/new versioning strategy.

* bump version for release (#57)
pbabinca added a commit to pbabinca/dockpulp that referenced this issue Dec 6, 2018
PEP 8 recommends to break a long line after a binary operator. That's
used in the current code.

In the past PEP 8 wasn't so specific and W504 appeared in flake8. This
one makes flake8 ignore W504.

For details see PyCQA/pycodestyle#498
DStape added a commit to DStape/flask-apispec that referenced this issue Feb 11, 2019
Add upper version constraint to apispec and ignore flake8 warning.

PyCQA/pycodestyle#498
DStape added a commit to DStape/flask-apispec that referenced this issue Feb 11, 2019
Add upper version constraint to apispec and ignore flake8 warning.

PyCQA/pycodestyle#498
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants