From 7a42fb71e2eaf65c69f44d519c79e448aae3816c Mon Sep 17 00:00:00 2001 From: Michael Morehouse <640167+yawpitch@users.noreply.github.com> Date: Wed, 25 Dec 2019 02:28:38 +0000 Subject: [PATCH] various: comma fixes (#2150) * forth: reinstate seperate classes The template removed seperate classes per major case, resulting in several tests with duplicate names and therefore an incomplete test suite. This reinstates the distinct classes. Fixes #2148 * forth: minor black issue Was accidentally running on a later version of Black than the one specified in our requirements-generator.txt. * various: fixes trailing comma issues An upcoming change in Black revealed that we were adding unnecessary trailing commas. These will _not_ be trimmed by Black in future builds. Co-authored-by: Corey McCandless --- .gitignore | 1 + exercises/all-your-base/.meta/template.j2 | 2 +- exercises/complex-numbers/.meta/template.j2 | 2 +- exercises/dominoes/.meta/template.j2 | 2 +- exercises/etl/.meta/template.j2 | 2 +- exercises/go-counting/.meta/template.j2 | 2 +- exercises/hamming/.meta/template.j2 | 2 +- exercises/isogram/.meta/template.j2 | 2 +- exercises/kindergarten-garden/.meta/template.j2 | 2 +- exercises/pov/.meta/template.j2 | 2 +- exercises/raindrops/.meta/template.j2 | 2 +- exercises/rest-api/.meta/template.j2 | 4 ++-- exercises/two-bucket/.meta/template.j2 | 4 ++-- exercises/variable-length-quantity/.meta/template.j2 | 2 +- 14 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index d2ab8303..86cb73d2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ bin/configlet.exe .cache .pytest_cache __pycache__ +.venv diff --git a/exercises/all-your-base/.meta/template.j2 b/exercises/all-your-base/.meta/template.j2 index 05a08eb4..b1384233 100644 --- a/exercises/all-your-base/.meta/template.j2 +++ b/exercises/all-your-base/.meta/template.j2 @@ -3,7 +3,7 @@ {%- macro func_call(case) -%} {{ case["property"] }}( {% for arg in case["input"].values() %} - {{ arg }}, + {{ arg }}{{- "," if not loop.last }} {% endfor %} ) {%- endmacro -%} diff --git a/exercises/complex-numbers/.meta/template.j2 b/exercises/complex-numbers/.meta/template.j2 index b71165f8..a5b9db25 100644 --- a/exercises/complex-numbers/.meta/template.j2 +++ b/exercises/complex-numbers/.meta/template.j2 @@ -10,7 +10,7 @@ import math {%- macro formatValue(val) -%} {% if val is iterable and val is not string -%} - ComplexNumber({% for part in val %}{{ translate_math(part) }},{% endfor %}) + ComplexNumber({% for part in val %}{{ translate_math(part) }}{{ "," if not loop.last }}{% endfor %}) {%- else -%} {{ translate_math(val) }} {%- endif -%} diff --git a/exercises/dominoes/.meta/template.j2 b/exercises/dominoes/.meta/template.j2 index 3de6ded8..e75094e9 100644 --- a/exercises/dominoes/.meta/template.j2 +++ b/exercises/dominoes/.meta/template.j2 @@ -4,7 +4,7 @@ {% macro tuplify(dominoes_list) -%} [ {%- for v in dominoes_list %} - ({{ v | join(', ') }}), + ({{ v | join(', ') }}){{- "," if not loop.last }} {%- endfor %} ] {%- endmacro %} diff --git a/exercises/etl/.meta/template.j2 b/exercises/etl/.meta/template.j2 index 8e550e13..126435f4 100644 --- a/exercises/etl/.meta/template.j2 +++ b/exercises/etl/.meta/template.j2 @@ -3,7 +3,7 @@ {%- set input = case["input"] -%} def test_{{ case["description"] | to_snake }}(self): legacy_data = { {% for key, value in case["input"]["legacy"].items() %} - {{key}}: {{value}},{% endfor %} } + {{key}}: {{value}}{{ "," if not loop.last }}{% endfor %} } data = {{case["expected"]}} self.assertEqual( {{ case["property"] | to_snake }}(legacy_data), data diff --git a/exercises/go-counting/.meta/template.j2 b/exercises/go-counting/.meta/template.j2 index 1fee8483..bb383040 100644 --- a/exercises/go-counting/.meta/template.j2 +++ b/exercises/go-counting/.meta/template.j2 @@ -5,7 +5,7 @@ {%- if territory_list %} { {%- for v in territory_list %} - ({{ v | join(', ') }}), + ({{ v | join(', ') }}){{ "," if not loop.last }} {%- endfor %} } {%- else %} diff --git a/exercises/hamming/.meta/template.j2 b/exercises/hamming/.meta/template.j2 index 407ba4ae..a569f406 100644 --- a/exercises/hamming/.meta/template.j2 +++ b/exercises/hamming/.meta/template.j2 @@ -2,7 +2,7 @@ {%- macro test_call(case) %} {{ case["property"] }}( {% for arg in case["input"].values() -%} - "{{ arg }}", + "{{ arg }}"{{ "," if not loop.last }} {% endfor %} ) {% endmacro -%} diff --git a/exercises/isogram/.meta/template.j2 b/exercises/isogram/.meta/template.j2 index eb7d916d..7b7d6afd 100644 --- a/exercises/isogram/.meta/template.j2 +++ b/exercises/isogram/.meta/template.j2 @@ -2,7 +2,7 @@ {%- macro test_call(case) %} {{ case["property"] | to_snake }}( {% for arg in case["input"].values() -%} - "{{ arg }}", + "{{ arg }}"{{ "," if not loop.last }} {% endfor %} ) {% endmacro -%} diff --git a/exercises/kindergarten-garden/.meta/template.j2 b/exercises/kindergarten-garden/.meta/template.j2 index 89204dad..9b7afbbe 100644 --- a/exercises/kindergarten-garden/.meta/template.j2 +++ b/exercises/kindergarten-garden/.meta/template.j2 @@ -13,7 +13,7 @@ garden.{{- case["property"] | to_snake -}} ("{{ input["student"] }}"), [{% for val in case["expected"] -%} - "{{ val | camel_case }}", + "{{ val | camel_case }}"{{- "," if not loop.last }} {% endfor %}] ) {% endmacro -%} diff --git a/exercises/pov/.meta/template.j2 b/exercises/pov/.meta/template.j2 index 2c850e4a..8669f460 100644 --- a/exercises/pov/.meta/template.j2 +++ b/exercises/pov/.meta/template.j2 @@ -34,7 +34,7 @@ Tree("{{ tree["label"] }}" {%- if tree["children"] %}, [ {%- for child_tree in tree["children"] %} - {{ write_tree(child_tree) | indent(4,True,True) }}, + {{ write_tree(child_tree) | indent(4,True,True) }}{{- "," if not loop.last }} {%- endfor %} ]{% endif %}) {%- endmacro -%} diff --git a/exercises/raindrops/.meta/template.j2 b/exercises/raindrops/.meta/template.j2 index 06071898..d1b0d2f8 100644 --- a/exercises/raindrops/.meta/template.j2 +++ b/exercises/raindrops/.meta/template.j2 @@ -2,7 +2,7 @@ {%- macro test_call(case) %} {{ case["property"] | to_snake }}( {% for arg in case["input"].values() -%} - {{ arg }}, + {{ arg }}{{- "," if not loop.last }} {% endfor %} ) {% endmacro -%} diff --git a/exercises/rest-api/.meta/template.j2 b/exercises/rest-api/.meta/template.j2 index 69500fb9..9bd4e751 100644 --- a/exercises/rest-api/.meta/template.j2 +++ b/exercises/rest-api/.meta/template.j2 @@ -12,9 +12,9 @@ class {{ exercise | camel_case }}Test(unittest.TestCase): payload = json.dumps({{ input["payload"] }}) {%- endif %} response = api.{{ case["property"] }}( - "{{ input["url"] }}", + "{{ input["url"] }}" {%- if "payload" in input %} - payload, + , payload {%- endif %} ) expected = {{ case["expected"] }} diff --git a/exercises/two-bucket/.meta/template.j2 b/exercises/two-bucket/.meta/template.j2 index 7f469792..e83c4275 100644 --- a/exercises/two-bucket/.meta/template.j2 +++ b/exercises/two-bucket/.meta/template.j2 @@ -12,9 +12,9 @@ class {{ exercise | camel_case }}Test(unittest.TestCase): ( {{ case["expected"]["moves"] }}, "{{ case["expected"]["goalBucket"] }}", - {{ case["expected"]["otherBucket"] }}, + {{ case["expected"]["otherBucket"] }} )) {% endfor %} -{{ macros.footer() }} \ No newline at end of file +{{ macros.footer() }} diff --git a/exercises/variable-length-quantity/.meta/template.j2 b/exercises/variable-length-quantity/.meta/template.j2 index 9e23bfa7..c557aa15 100644 --- a/exercises/variable-length-quantity/.meta/template.j2 +++ b/exercises/variable-length-quantity/.meta/template.j2 @@ -3,7 +3,7 @@ {%- macro list_int_to_hex(integers) %} [ {% for integer in integers -%} - {{ "0x{:x}".format(integer) }}, + {{ "0x{:x}".format(integer) }}{{- "," if not loop.last }} {% endfor %} ] {% endmacro -%}