From 50445dbe3f83551244d858e5d2a0a0e1a90adf75 Mon Sep 17 00:00:00 2001 From: Peter Pentchev Date: Sat, 7 Sep 2024 13:23:38 +0300 Subject: Add Peter Pentchev's Python solution to 285. --- .../ppentchev/python/src/perl_weekly_285/defs.py | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 challenge-285/ppentchev/python/src/perl_weekly_285/defs.py (limited to 'challenge-285/ppentchev/python/src/perl_weekly_285/defs.py') diff --git a/challenge-285/ppentchev/python/src/perl_weekly_285/defs.py b/challenge-285/ppentchev/python/src/perl_weekly_285/defs.py new file mode 100644 index 0000000000..26d7ea59c6 --- /dev/null +++ b/challenge-285/ppentchev/python/src/perl_weekly_285/defs.py @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause +"""Common definitions for the perl-weekly-285 library.""" + +from __future__ import annotations + +import dataclasses +import typing + + +if typing.TYPE_CHECKING: + from typing import Final + + +VERSION: Final = "0.1.0" +"""The perl-weekly-285 library version, semver-like.""" + + +@dataclasses.dataclass +class Error(Exception): + """An error that occurred during the processing.""" + + def __str__(self) -> str: + """Provide a human-readable error message.""" + return f"{type(self).__str__} must be overridden for {self!r}" + + +@dataclasses.dataclass +class NoSolutionError(Error): + """No solution could be found.""" + + def __str__(self) -> str: + """Provide a human-readable error message.""" + return f"Could not find a solution: {self!r}" -- cgit