From 506a49fd49e028055378af2e35d6022e6bb99b9c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 26 Oct 2020 10:35:50 +0100 Subject: blacken code; do not run lint check on external Python libraries --- .gitlab-ci.yml | 2 +- lib/functions.py | 2 +- lib/parameters.py | 7 ++++++- lib/protocol_benchmarks.py | 30 ++++++++++++++++++++---------- lib/sly/docparse.py | 4 ++-- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d1eae2c..498f371 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ lint_python: script: - apt-get update -qy - apt-get install -y black - - black --check --diff bin/*.py lib/*.py + - find bin lib -type f -name '*.py' | xargs black --check --diff rules: - if: '$CI_COMMIT_BRANCH == "master"' diff --git a/lib/functions.py b/lib/functions.py index 94b1aaf..9d799c7 100644 --- a/lib/functions.py +++ b/lib/functions.py @@ -394,7 +394,7 @@ class analytic: :param safe_functions_enabled: Include "safe" variants of functions with limited argument range, e.g. a safe inverse which returns 1 when dividing by 0. - + Returns a dict of functions which are typical for energy/timing behaviour of embedded hardware, e.g. linear, exponential or inverse dependency on a configuration setting/runtime variable. diff --git a/lib/parameters.py b/lib/parameters.py index 5c6b978..fa966a3 100644 --- a/lib/parameters.py +++ b/lib/parameters.py @@ -434,7 +434,12 @@ class ParamStats: """ def __init__( - self, by_name, by_param, parameter_names, arg_count, use_corrcoef=False, + self, + by_name, + by_param, + parameter_names, + arg_count, + use_corrcoef=False, ): """ Compute standard deviation and correlation coefficient on parameterized data partitions. diff --git a/lib/protocol_benchmarks.py b/lib/protocol_benchmarks.py index d41979f..7f3e2f2 100755 --- a/lib/protocol_benchmarks.py +++ b/lib/protocol_benchmarks.py @@ -328,8 +328,10 @@ class ArduinoJSON(DummyProtocol): child = enc_node + "l" while child in self.children: child += "_" - self.enc_buf += "ArduinoJson::JsonArray& {} = {}.createNestedArray();\n".format( - child, enc_node + self.enc_buf += ( + "ArduinoJson::JsonArray& {} = {}.createNestedArray();\n".format( + child, enc_node + ) ) self.children.add(child) self.from_json(value, child) @@ -338,8 +340,10 @@ class ArduinoJSON(DummyProtocol): child = enc_node + "o" while child in self.children: child += "_" - self.enc_buf += "ArduinoJson::JsonObject& {} = {}.createNestedObject();\n".format( - child, enc_node + self.enc_buf += ( + "ArduinoJson::JsonObject& {} = {}.createNestedObject();\n".format( + child, enc_node + ) ) self.children.add(child) self.from_json(value, child) @@ -616,11 +620,15 @@ class CapnProtoC(DummyProtocol): [len(value)], ) for i, elem in enumerate(value): - self.enc_buf += "capn_set{:d}({}.{}, {:d}, capn_from_f{:d}({:f}));\n".format( - self.float_bits, self.name, key, i, self.float_bits, elem + self.enc_buf += ( + "capn_set{:d}({}.{}, {:d}, capn_from_f{:d}({:f}));\n".format( + self.float_bits, self.name, key, i, self.float_bits, elem + ) ) - self.dec_buf += "kout << capn_to_f{:d}(capn_get{:d}({}.{}, {:d}));\n".format( - self.float_bits, self.float_bits, self.name, key, i + self.dec_buf += ( + "kout << capn_to_f{:d}(capn_get{:d}({}.{}, {:d}));\n".format( + self.float_bits, self.float_bits, self.name, key, i + ) ) self.assign_and_kout( self.float_type, @@ -1196,8 +1204,10 @@ class NanoPB(DummyProtocol): self.cc_encoders += ( "if (!pb_encode_tag_for_field(stream, field)) return false;\n" ) - self.cc_encoders += 'return pb_encode_string(stream, (uint8_t*)"{}", {:d});\n'.format( - value, len(value) + self.cc_encoders += ( + 'return pb_encode_string(stream, (uint8_t*)"{}", {:d});\n'.format( + value, len(value) + ) ) self.cc_encoders += "}\n" self.enc_buf += "msg.{}{}.funcs.encode = encode_{};\n".format( diff --git a/lib/sly/docparse.py b/lib/sly/docparse.py index 0f35c97..6a60eaf 100644 --- a/lib/sly/docparse.py +++ b/lib/sly/docparse.py @@ -9,7 +9,7 @@ class DocParseMeta(type): ''' Metaclass that processes the class docstring through a parser and incorporates the result into the resulting class definition. This - allows Python classes to be defined with alternative syntax. + allows Python classes to be defined with alternative syntax. To use this class, you first need to define a lexer and parser: from sly import Lexer, Parser @@ -39,7 +39,7 @@ class DocParseMeta(type): ... """ - It is expected that the MyParser() class would return a dictionary. + It is expected that the MyParser() class would return a dictionary. This dictionary is used to create the final class Spam in this example. ''' -- cgit v1.2.3