refined: refinement type hints in Python
refined is a Python 3 library that leverages the gradual type system in Python to constrain types by one or multiple
predicates. In short, you can ensure that the following script won't raise an IndexError:
from refined import refined, NonEmptyList
from typing import Generator
@refined
def head_with_tail_generator(ls: NonEmptyList[int]) -> (int, Generator[int]):
return ls[0], (_ for _ in ls[1:])
if __name__ == '__main__':
head, tail = head_with_tail_generator([]) # this call raises a RefinementTypeException
print(head)
[print(_) for _ in tail]
Help
See documentation for more details.
Installation
refined is available for Python 3.7+:
pip install -U refined
Contributing
For guidance on setting up a development environment and how to make a contribution to refined, see
Contributing to refined.
Acknowledgements
This library is a port of fthomas' refined Scala library, which, in turn, is a port of
Nikita Volkov's refined Haskell library.
Metadata
Release files for refined 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| refined-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for refined-0.0.1-py3-none-any.whl |
Release files / refined-0.0.1-py3-none-any.whl
| Download URL | refined-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
041a70eaed411000a0e0eacfe5dbd454c81b311fdfe2e63b7f7d4378bed3810b
|
|
BLAKE2b-256 checksum How to use checksums |
5781e780fd7ff1cbd016bf7899ce033806d3c5fac7f9ac9a6cfcc47880957353
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.10
|
Security for refined 0.0.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.