#294 FIX W504 warning: Line break occurred after a binary operator
Merged 5 years ago by gnaponie. Opened 5 years ago by rayson.
rayson/waiverdb fix-w504  into  master

file modified
+8 -8
@@ -13,11 +13,11 @@ 

  

      assert r.status_code == 200

      assert len([l for l in r.get_data(as_text=True).splitlines()

-                 if l.startswith('# TYPE messaging_') and

-                 l.endswith(' counter')]) == 4

+                 if l.startswith('# TYPE messaging_')

+                 and l.endswith(' counter')]) == 4

      assert len([l for l in r.get_data(as_text=True).splitlines()

-                 if l.startswith('# TYPE db_') and

-                 l.endswith(' counter')]) == 4

+                 if l.startswith('# TYPE db_')

+                 and l.endswith(' counter')]) == 4

  

  

  def test_standalone_metrics_server_disabled_by_default():
@@ -32,8 +32,8 @@ 

      r = requests.get('http://127.0.0.1:10040/metrics')

  

      assert len([l for l in r.text.splitlines()

-                 if l.startswith('# TYPE messaging_') and

-                 l.endswith(' counter')]) == 4

+                 if l.startswith('# TYPE messaging_')

+                 and l.endswith(' counter')]) == 4

      assert len([l for l in r.text.splitlines()

-                 if l.startswith('# TYPE db_') and

-                 l.endswith(' counter')]) == 4

+                 if l.startswith('# TYPE db_')

+                 and l.endswith(' counter')]) == 4

file modified
+2 -1
@@ -45,4 +45,5 @@ 

  exclude = .git,.tox,dist,*egg,env_waiverdb,*fedmsg.d,docs,conf,waiverdb/migrations

  

  # E124: closing bracket does not match visual indentation

- ignore = E124

+ # W503 line break before binary operator

+ ignore = E124, W503

file modified
+3 -3
@@ -12,9 +12,9 @@ 

      This maps from the old style to the new, for backwards compatibility.

      """

      # handling the special cases...

-     if (subject.get('type') in ['koji_build', 'brew-build'] and

-             'item' in subject and

-             isinstance(subject['item'], str)):

+     if (subject.get('type') in ['koji_build', 'brew-build']

+             and 'item' in subject

+             and isinstance(subject['item'], str)):

          return ('koji_build', subject['item'])

      elif 'original_spec_nvr' in subject and isinstance(subject['original_spec_nvr'], str):

          return ('koji_build', subject['original_spec_nvr'])

After upgrading C3I Jenkins slave pod from Fedora 28 to 29,
C3I pipeline builds for waiverdb fails with a Flake8 warning:
W504 line break after binary operator.

This happens because of a updated PEP 8 rule, which
recommends that line breaks should occur before the binary operator
because it keeps all operators aligned.
However both W503 and W504 are enforced when all warnings are configured.

This pull-request eliminates the warning by following the new rule and ignoring W503.

+1 I don't have strong feelings on this style one way or another, and flake8 was ridiculous to try to enforce both. This solution looks reasonable.

Commit 234455f fixes this pull-request

Pull-Request has been merged by gnaponie

5 years ago

Pull-Request has been merged by gnaponie

5 years ago