Skip to content

Commit

Permalink
Merge pull request #55 from vil02/format_output
Browse files Browse the repository at this point in the history
feat: format the output using black
  • Loading branch information
vil02 committed Jul 30, 2024
2 parents b634ab0 + 8b54212 commit 0707747
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion puzzle_generator/create_puzzle.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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())
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <vil02_puzzle_generator@10g.pl>"]
readme = "./puzzle_generator/README.md"
Expand All @@ -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
Expand All @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_create_puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import typing
import itertools
import collections
import black
import pytest

import puzzle_generator.create_puzzle as cp
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 0707747

Please sign in to comment.