Skip to content

Commit

Permalink
feat: make classes and funcs accessible from root package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan-Kowal committed Oct 25, 2024
1 parent 9af61e9 commit bd1949d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Code Quality

on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main']

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Tests

on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main']

Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

## Next - TBD

- 🔧 Fixed [README.md](README.md) GitHub action badges to use the **release** events
- ✨ Classes and functions can now be imported directly, without going through submodules
- 🔧 Fixed [README.md](README.md) "Build" badge to use the **release** events

## 1.0.1 - 2024-10-25

Expand Down
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ✨ Pipe Operator ✨

![Code quality](https://github.com/Jordan-Kowal/pipe-operator/actions/workflows/code_quality.yml/badge.svg?event=release)
![Tests](https://github.com/Jordan-Kowal/pipe-operator/actions/workflows/tests.yml/badge.svg?event=release)
![Code quality](https://github.com/Jordan-Kowal/pipe-operator/actions/workflows/code_quality.yml/badge.svg?branch=main)
![Tests](https://github.com/Jordan-Kowal/pipe-operator/actions/workflows/tests.yml/badge.svg?branch=main)
![Build](https://github.com/Jordan-Kowal/pipe-operator/actions/workflows/publish_package.yml/badge.svg?event=release)
![Coverage](https://badgen.net/badge/coverage/%3E90%25/pink)
![Tag](https://badgen.net/badge/tag/1.0.1/orange)
Expand All @@ -10,6 +10,7 @@

- [✨ Pipe Operator ✨](#-pipe-operator-)
- [⚡ Quick start](#-quick-start)
- [📕 Overview](#-overview)
- [🐍 Pythonic implementation](#-pythonic-implementation)
- [Available classes](#available-classes)
- [Limitations](#limitations)
Expand All @@ -26,18 +27,22 @@ This module provides 2 vastly different implementations, each with its own pros
## ⚡ Quick start

As simple as `pip install pipe_operator`.
Then either import the 🐍 **pythonic** or the 🍹 **elixir** implementations
Then either import the 🐍 **pythonic classes** or the 🍹 **elixir functions**

```python
from pipe_operator.elixir_flow import elixir_pipe, tap, then
from pipe_operator.python_flow import Pipe, PipeArgs, PipeEnd, PipeStart, Tap, Then
# Pythonic classes
from pipe_operator import Pipe, PipeArgs, PipeEnd, PipeStart, Tap, Then
# Elixir functions
from pipe_operator import elixir_pipe, tap, then
```

## 📕 Overview

You can use the 🐍 **pythonic** implementation, which is **entirely compatible with linters and type-checkers**,
but a bit more verbose than the original pipe operator:

```python
from pipe_operator.python_flow import Pipe, PipeArgs, PipeEnd, PipeStart, Tap, Then
from pipe_operator import Pipe, PipeArgs, PipeEnd, PipeStart, Tap, Then

result = (
PipeStart("3") # starts the pipe
Expand All @@ -59,7 +64,7 @@ Or the 🍹 **elixir-like** implementation, whose syntax greatly resembles the o
but has major issues with linters and type-checkers.

```python
from pipe_operator.elixir_flow import elixir_pipe, tap, then
from pipe_operator import elixir_pipe, tap, then

@elixir_pipe
def workflow(value):
Expand Down Expand Up @@ -88,7 +93,7 @@ workflow(3)

### Available classes

In the `python_flow` submodule, we expose the following classes:
In the 🐍 **pythonic implementation**, we expose the following classes:

| Class | Description | Examples |
| ----------- | --------------------------------------------------------------------- | ----------------------------------------- |
Expand Down Expand Up @@ -116,7 +121,7 @@ we advise you set `reportOperatorIssue = "none"` in your `pyright` config.

### Overview

In the `elixir_flow` submodule, we expose 3 items:
In the 🍹 **elixir-like implementation**, we expose 3 functions:

- `elixir_pipe`: a decorator that enables the use of "pipe" in our function
- `tap`: a function to trigger a side-effect and return the original value
Expand Down
14 changes: 11 additions & 3 deletions pipe_operator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
from . import elixir_flow, python_flow
from .elixir_flow import elixir_pipe, tap, then
from .python_flow import Pipe, PipeArgs, PipeEnd, PipeStart, Tap, Then

__all__ = [
"elixir_flow",
"python_flow",
"Pipe",
"PipeArgs",
"PipeEnd",
"PipeStart",
"Tap",
"Then",
"elixir_pipe",
"tap",
"then",
]

0 comments on commit bd1949d

Please sign in to comment.