Skip to main content

An attempt at simplifying Python error propagation.

Project description

PiError

PiError is an attempt at simplifying Python error propagation. This Python package follows the "Errors as Values" principle giving the user control of how errors are stored, used, and raised without worrying about immediate runtime crashes. It takes a very simple approach, which may already be boilerplate for some but may aide in simplifying ones code base. The best part about it, is that there are no dependencies.


Installation

Pip
# Create a virtual environment
python3 -m venv ~/venv-name

# Activate the virtual environment
source "~/venv-name/bin/activate"

# Upgrade pip
~/venv-name/bin/pip install --upgrade pip

# Install PiError package
~/venv-name/bin/pip install PiError
Uv (Recommended)
# Create virtual environment
uv venv ~/venv-name

# Activate virtual environment
source ~/venv-name/bin/activate

# Upgrade pip
uv pip install --upgrade pip

# Install PiError
uv pip install PiError

Copy the following code below into your text editor to see how it works:

from PiError import PiError

@PiError({0: {int}, 1: {int}}, TypeError, "'x' and 'y' should be of type 'int'")
def addition(x: int, y: int) -> PiError | int:
    return x + y

result = addition('a', 1)
if type(result) is PiError:
    raise result.error(result.cause)
else:
    print(result)

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

pierror-0.0.1a0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

pierror-0.0.1a0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pierror-0.0.1a0.tar.gz.

File metadata

  • Download URL: pierror-0.0.1a0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for pierror-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 acf1cd2d2f3407bc96e5e598cadbc3b5a740b30f06a51961d03befd1874e47cd
MD5 05de9999e1f485ea21492bcbd77ee355
BLAKE2b-256 909393c005f5aa0b274a9124ff53fa77a2a55efec4af1ee61bf4bc89ac7c7eaf

See more details on using hashes here.

File details

Details for the file pierror-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: pierror-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.9

File hashes

Hashes for pierror-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 59b1bf0a10c5d9f6362cf5d1b60ebd3de61ca143001c6e4f82b37d84c9d019b9
MD5 419fda1c3ad1a55b4de6ddec3402138b
BLAKE2b-256 41da33fb8b7bdfd9ac790c7d4755623eef9002298afddbceb89ba9a39eee1cea

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