From 725a8cf5af52b38c015a4868504bdcdd9d74e614 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 25 Apr 2018 01:22:59 +0200 Subject: [PATCH 1/3] Add W504 to flake8 ignores By having any ignore on setup.cfg both style rules were activated so we need to choose one. We go with the operator before the newline. --- setup.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index dc0db6993e..58e0300a1c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,10 +1,10 @@ [flake8] -ignore = E731, E402 +ignore = E731, E402, W504 max-line-length = 99 exclude = raiden/ui/web/node_modules/ [pep8] -ignore = E731, E402 +ignore = E731, E402, W504 max-line-length = 99 [coverage:run] From 75efed2a7ebf0a29d8471ce60d32b69d54bc7a4d Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 25 Apr 2018 01:28:55 +0200 Subject: [PATCH 2/3] Specify line break after operators in the style guide --- CONTRIBUTING.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 10d4dd55af..db5a16d354 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -148,6 +148,34 @@ Thus we setup the following rules: ### Coding Style +#### General Style + +In this section we are going to see style rules that should be followed across all languages. + +**Line breaks after operators** + +For long expressions where we break the expression at the operators the line break should come **after** the operator and not before. + +The following should be avoided: + +```python + participant1_amount = ( + participant1_state.deposit + + participant2_state.transferred_amount + - participant1_state.transferred_amount + ); +``` + +instead it should be: + +```python + participant1_amount = ( + participant1_state.deposit + + participant2_state.transferred_amount - + participant1_state.transferred_amount + ); +``` + #### Python Raiden is written in Python and we follow the official Python style guide From 45fe431dba51df1bb9774d3f397f67acf96060f9 Mon Sep 17 00:00:00 2001 From: Lefteris Karapetsas Date: Wed, 25 Apr 2018 01:30:05 +0200 Subject: [PATCH 3/3] flake8 fix --- raiden/network/blockchain_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raiden/network/blockchain_service.py b/raiden/network/blockchain_service.py index 4cd8d3b0ee..9bab67f3fb 100644 --- a/raiden/network/blockchain_service.py +++ b/raiden/network/blockchain_service.py @@ -63,7 +63,7 @@ def is_synced(self) -> bool: return True - def estimate_blocktime(self, oldest: int=256) -> float: + def estimate_blocktime(self, oldest: int = 256) -> float: """Calculate a blocktime estimate based on some past blocks. Args: oldest: delta in block numbers to go back.