Skip to content

Commit

Permalink
[readme] explain the typing
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Nov 12, 2023
1 parent 34e4cbb commit 1ffdddc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,20 @@ At any rate, **Late** is so simple and so small that you can apply any changes y

### How does it work?

For values of immutable types, `__()` will return the same value. For all other types `__()`
For values of immutable types, ``__()`` will return the same value. For all other types ``__()``
will wrap the value in a special ``namedtuple(actual=value)``. At function invocation time, this it what happens:

* if the argument name is already in ``kwargs``, nothing is done
* if the wrapped value is a generator, then ``next(actual)`` is used
* if the wrapped value is a function, then ``actual()`` is used
* in all other cases ``copy.deepcopy(actual)`` is used

For convenient type checking, ``__()`` is declared so its type will be the desired one depending
on the argument:

```python
def late(o: _T | Iterator[_V] | Callable[[], _R]) -> _T | _V | _R:
```

## Installation

Expand Down

0 comments on commit 1ffdddc

Please sign in to comment.