mentortools/libs/: exception-tools-abm-1.0.79347 metadata and description

Simple index Newer version available

Tools and components to work with exceptions

author mike
author_email m.orlov@technokert.ru
classifiers
  • License :: Other/Proprietary License
  • Programming Language :: Python :: 3
  • Programming Language :: Python :: 3.11
  • Programming Language :: Python :: 3.12
  • Programming Language :: Python :: 3.13
description_content_type text/markdown
license Proprietary. All rights reserved. Confidential and belonging to ABM.
requires_dist
  • taskipy (>=1.14.1,<2.0.0)
requires_python >=3.11,<4.0
File Tox results History
exception_tools_abm-1.0.79347-py3-none-any.whl
Size
3 KB
Type
Python Wheel
Python
3
exception_tools_abm-1.0.79347.tar.gz
Size
1 KB
Type
Source

Exception tools

Tools and components to work with exceptions

Examples:

from typing import Any
from exception_tools import raise_if, raise_if_not, repr_exception

def do_the_thing(val: int | Any) -> None:
    raise_if_not(isinstance(val, int), TypeError(f'Required type int, got {type(val).__qualname__}'))
    raise_if(val <= 0, ValueError, 'Only positive values allowed, got', val)
    # actual work

try:
    do_the_thing(None)
except TypeError as e:
    assert repr_exception(e) == "TypeError: Required type int, got NoneType"
    
try:
    do_the_thing(0)
except ValueError as e:
    assert repr_exception(e) == "ValueError: ('Only positive values allowed, got', 0)"