patina
This is an implementation of Rust's Result and Option types in Python. Most methods have been implemented, and the (very good) original documentation has been adapted into docstrings.
The documentation for this package can be read here. All doctests are run and type-checked as part of the CI pipeline as unit tests. The tests are direct ports of those in the Rust documentation.
Why?
2 reasons:
- Python (in 3.10) now has pattern matching, wouldn't it be cool if we could make the most of that?
- Sometimes it's nice to have types for your errors.
- Being able to
mapover possible failure can be very powerful.
Check this out:
from patina import Some, None_
# This value is an Option[str]
maybe_value = api_call_that_might_produce_a_value()
match maybe_value.map(str.upper): # Make it uppercase if it exists
case Some(val):
print("We got a val:", val)
case None_(): # Don't forget the parentheses (otherwise it's binding a name)
print("There was no val :(")
A similar thing can be done with the Result type (matching on Ok or Err).
This can be handy if you want to be more explicit about the fact that a function
might fail. If the function returns a Result, we can explicitly type the
possible error values.
If this all sounds good, I recommend looking into functional programming, particularly of the ML variety (e.g. Haskell, OCaml, SML) or Rust.
Metadata
Release files for patina 0.5.0
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 |
|---|---|---|---|---|
| patina-0.5.0.tar.gz | 16.8 kB | Without provenance | Details for patina-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| patina-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for patina-0.5.0-py3-none-any.whl |
Total release size: 35.1 kB
Release files / patina-0.5.0.tar.gz
| Download URL | patina-0.5.0.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
567924ed41492941b603aa23079a320a9b569fd283efa3e1b691e851175a989b
|
|
BLAKE2b-256 checksum How to use checksums |
35a147d96367925c74f0379a69fad33314ef8feafefa2420a430f23705b14404
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.0 Darwin/20.5.0
|
Release files / patina-0.5.0-py3-none-any.whl
| Download URL | patina-0.5.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2996598d41b1c85ff8c27598ef7227f11e33ec4f6927de33df3cf40d9197d96a
|
|
BLAKE2b-256 checksum How to use checksums |
75414da899901f19aa8800dab4c1326774309e764647a36770edc47943652d67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.4 CPython/3.9.0 Darwin/20.5.0
|
Security for patina 0.5.0
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.