Skip to main content

Human readable Python exceptions.

Project description

documented

Build Status Coverage Python Version wemake-python-styleguide

Templated docstrings for Python classes.

Features

  • Describe your business logic in docstrings of your classes and exceptions;
  • When printing an object or an exception, your code will explain to you what is going on.

Installation

pip install documented

Example

from dataclasses import dataclass
from documented import DocumentedError


@dataclass
class InsufficientWizardryLevel(DocumentedError):
    """
    🧙 Your level of wizardry is insufficient ☹

        Spell: {self.spell}
        Minimum level required: {self.required_level}
        Actual level: {self.actual_level} {self.comment}

    Unseen University will be happy to assist in your training! 🎓
    """

    spell: str
    required_level: int
    actual_level: int

    @property
    def comment(self) -> str:
        if self.actual_level <= 0:
            return '(You are Rincewind, right? Hi!)'
        else:
            return ''


raise InsufficientWizardryLevel(
    spell='Animal transformation',
    required_level=8,
    actual_level=0,
)

which prints:

---------------------------------------------------------------------
InsufficientWizardryLevel           Traceback (most recent call last)
<ipython-input-1-d8ccdb953cf6> in <module>
     27 
     28 
---> 29 raise InsufficientWizardryLevel(
     30     spell='Animal transformation',
     31     required_level=8,

InsufficientWizardryLevel: 
🧙 Your level of wizardry is insufficient ☹

    Spell: Animal transformation
    Minimum level required: 8
    Actual level: 0 (You are Rincewind, right? Hi!)

Unseen University will be happy to assist in your training! 🎓

License

MIT

Credits

This project was generated with wemake-python-package. Current template version is: 5840464a31423422d7523897d854e92408eee6b8. See what is updated since then.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

documented-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

documented-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file documented-0.1.0.tar.gz.

File metadata

  • Download URL: documented-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.3 Linux/5.4.0-47-generic

File hashes

Hashes for documented-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cca0d73c8f4c1c4741f493f8b3e020873122004db8607cf68ac5ca7d63ac1b53
MD5 bd0dd94e5ee872219f9b253a1fe9c69d
BLAKE2b-256 3bedbf056a81b20c00e6bf256375380723cb68e3f25d0032c58384fad718475d

See more details on using hashes here.

File details

Details for the file documented-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: documented-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.3 CPython/3.8.3 Linux/5.4.0-47-generic

File hashes

Hashes for documented-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a204fdfe9de4f3d83fa5c1fc2019abe35364ee3a5928dc0924988408fbd77ce9
MD5 a7ea93304f3150f3d4394801afea072c
BLAKE2b-256 68e5771a4169e8390eb577e5c21cd78da029408f8140bb3eaed602d0d26707f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page