Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meadsteve/pyper
https://github.com/meadsteve/pyper
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/meadsteve/pyper
- Owner: meadsteve
- Created: 2020-07-22T13:16:51.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-22T18:34:07.000Z (over 3 years ago)
- Last Synced: 2024-10-11T03:11:13.383Z (about 1 month ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pyper
A pure functional wrapper on top of Typer## Usage
Usage is almost identical to typer (which is used internally)
except instead of calling `typer.echo` which has a side-effect the
functions should yield `pyper.echo` which is a value object.
```python
import pyperdef main(name: str):
yield pyper.Echo(f"Hello")
yield pyper.Echo(f"I will call you {name}")
yield pyper.Echo(f"Bye")if __name__ == "__main__":
pyper.run(main)
```
## Why?
Having the functions yield makes them much easier to test with little
or no mocking:
```python
assert list(main("steve")) == [
pyper.Echo("Hello"),
pyper.Echo("I will call you steve"),
pyper.Echo("Bye"),
]
```