Erratum
code |
|
|---|---|
pypi |
Erratum is a python package that aims to make it easy to build in user friendly error messages into your project. Let’s look at the following example:
>>> my_square_root(-1)
<ipython-input-3-a8d1f1b285c7> in my_square_root(n)
5
6 if n < 0:
----> 7 raise ValueError("You can only take the square root of a positive number")
8
9 return math.sqrt(n)
ValueError: You can only take the square root of a positive number
More info --> https://github.com/alcarney/erratum
As you can see we get the error message as passed to the exception but we also get a link to a webpage where we can find more information about the error and what we need to do to fix it.
How? Well let’s look at the implementation of my_square_root
import math
from erratum import Error
class SqrtError(Error):
url = "https://github.com/alcarney/erratum"
@SqrtError
def my_square_root(n):
if n < 0:
raise ValueError("You can only take the square root of a positive number")
return math.sqrt(n)
Here we declare our error SqrtError by subclassing the Error class
which allows us to set the url the user gets sent to find out more about the error.
Then it is simply of decorating any function we want the function to apply to with
the annotate method. This will cause any exception that is thrown from within
the function to be tagged with the more info link.
Metadata
Release files for erratum 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| erratum-0.1.1.tar.gz | 5.2 kB | Without provenance | Details for erratum-0.1.1.tar.gz |
Release files / erratum-0.1.1.tar.gz
| Download URL | erratum-0.1.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff01185b565557d1c9a4a27036cd528178873c4ad7ee7c5532aaceb9cfd88bf3
|
|
BLAKE2b-256 checksum How to use checksums |
6b8088482789be505975c585ea1f48f30a4a40ef6c812b11ad31a23b4ae0bfa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for erratum 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.