diff --git a/puzzle_generator/create_puzzle.py b/puzzle_generator/create_puzzle.py index 386e023..6f4c83b 100644 --- a/puzzle_generator/create_puzzle.py +++ b/puzzle_generator/create_puzzle.py @@ -1,6 +1,8 @@ import inspect import typing +import black + from .puzzle_data_encryption import encrypt_data from .configurators import configurators from . import bytestr_utils @@ -53,4 +55,5 @@ def create(qa_list: typing.List[str], **kwargs) -> str: puzzle = question_answer_list_to_dict(qa_list) configurator = configurators.get_configurator(**kwargs) encrypted_puzzle = encrypt_data(puzzle, configurator.get_encrypt()) - return _create_str(encrypted_puzzle, configurator) + res = _create_str(encrypted_puzzle, configurator) + return black.format_str(res, mode=black.FileMode()) diff --git a/pyproject.toml b/pyproject.toml index 913aa24..8b2ab20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "puzzle-generator" -version = "0.7.1" +version = "0.8.0" description = "Generates python code representing a puzzle" authors = ["piotr.idzik "] readme = "./puzzle_generator/README.md" @@ -11,6 +11,7 @@ keywords = ["puzzle-generation", "quiz-generation", "code-generation"] [tool.poetry.dependencies] python = ">=3.10,<4.0.0" +black = "24.4.2" [tool.poetry.group.dev] optional = true @@ -22,7 +23,6 @@ flake8 = "7.1.0" flake8-pytest-style = "2.0.0" ruff = "0.5.5" coverage = "7.6.0" -black = "24.4.2" mypy = "1.11.0" [build-system] diff --git a/tests/test_create_puzzle.py b/tests/test_create_puzzle.py index f33c0d5..9a3bf6a 100644 --- a/tests/test_create_puzzle.py +++ b/tests/test_create_puzzle.py @@ -4,6 +4,7 @@ import typing import itertools import collections +import black import pytest import puzzle_generator.create_puzzle as cp @@ -76,6 +77,7 @@ def _run_puzzle_file( def _run_puzzle_str( in_puzzle: str, answers: list[str], in_puzzle_path: pathlib.Path ) -> subprocess.CompletedProcess[str]: + assert in_puzzle == black.format_str(in_puzzle, mode=black.FileMode()) with open(in_puzzle_path, "w", encoding="utf-8") as puzzle_file: puzzle_file.write(in_puzzle) return _run_puzzle_file(in_puzzle_path, answers)