Skip to content

Commit

Permalink
make 包 an alias for latst __
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Nov 14, 2023
1 parent 3c8216d commit 9e7204e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,14 @@ $ pip install Late

**Late** is licensed as reads in
[LICENSE](https://github.com/neogeny/late/blob/master/LICENSE).


## And now,... this!

You can use ````, the Kanji for _"wrap"_, instead of ``__`` to late-bind
an argument.

```python
@latebinding
def f(x: list[Any] = 包([])) -> list[Any]:
```
4 changes: 1 addition & 3 deletions late/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ def late(o: _T | Iterator[_V] | Callable[[], _R]) -> _T | _V | _R:


__ = late


__ = late
= late


def _lateargs(func: Callable, **kwargs) -> dict[str, Any]:
Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ignore = [
'TRY003', 'TRY300',
'PGH003',
'PLW1514', 'PLR6301',
'PLC0415',
'PLC0415', 'PLC2401', 'PLC2403',
'PLR0913', 'PLR2004', 'PLR0904', 'PLR0915',
'PLW0603', 'PLW2901', 'PLW3201',
'RET505',
Expand Down
12 changes: 11 additions & 1 deletion test/simple_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inspect
from typing import Any

from late import __, _LateBound, latebinding
from late import __, _LateBound, latebinding,


def test_with_list():
Expand All @@ -25,3 +25,13 @@ def f(x: frozenset[Any] = __(frozenset()), y: set = __(set())):
assert type(param.default) is frozenset
param = inspect.signature(f).parameters['y']
assert type(param.default) is _LateBound


def test_kanji():
@latebinding
def f(x: list[Any] = ([])) -> list[Any]:
x.append(1)
return x

assert f() == [1]
assert f() == [1]

0 comments on commit 9e7204e

Please sign in to comment.