Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@ runs:
- name: run tests
shell: bash
run: poetry run just test
- name: generate report
if: failure()
shell: bash
run: poetry run coverage html
- name: upload report
if: failure()
uses: actions/upload-artifact@v4
with:
name: py-${{ inputs.python-version }}-${{ github.sha }}-coverage-report
path: htmlcov/
701 changes: 252 additions & 449 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{
devShells.default = pkgs.mkShell {
packages = [
pkgs.python312
pkgs.python313
pkgs.just
pkgs.poetry
];
Expand Down
3 changes: 2 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
test:
coverage run --source=src -m pytest tests
coverage run -m pytest tests
coverage combine
coverage report --fail-under=100

lint:
Expand Down
134 changes: 68 additions & 66 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 18 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ipython = "^8.17.2"
pytest = "^7.4.3"
pyright = "^1.1.336"
pre-commit = "^3.5.0"
ruff = "^0.1.6"
ruff = "^0.14.2"
coverage = "^7.3.2"
toml = "^0.10.2"

Expand All @@ -34,13 +34,28 @@ warn_return_any = true
strict_equality = true
disallow_any_generics = true

[tool.ruff]
[[tool.mypy.overrides]]
module = [
"cloudpickle",
]
ignore_missing_imports = true

[tool.ruff.lint]
select = ["I", "F", "N", "RUF", "D"]
ignore = ["D107", "D213", "D203", "D202", "D212"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/**/*" = ["D100", "D101", "D102", "D103", "D104", "D105", "D107"]

[tool.coverage.report]
exclude_also = [
"@overload"
]

[tool.coverage.run]
concurrency = ["multiprocessing", "thread"]
source = ["src/"]


[build-system]
requires = ["poetry-core"]
Expand Down
10 changes: 6 additions & 4 deletions src/stateless/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@

# ruff: noqa: F401

from stateless.abilities import Abilities
from stateless.ability import Ability
from stateless.async_ import Async, Task, fork, wait
from stateless.effect import (
Depend,
Effect,
Success,
Try,
catch,
depend,
memoize,
run,
run_async,
success,
throw,
throws,
)
from stateless.functions import repeat, retry
from stateless.parallel import parallel, process
from stateless.functions import as_type, repeat, retry
from stateless.handler import Handler, handle
from stateless.need import Need, need, supply
from stateless.schedule import Schedule
199 changes: 0 additions & 199 deletions src/stateless/abilities.py

This file was deleted.

21 changes: 21 additions & 0 deletions src/stateless/ability.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Module containing the base ability type."""

from typing import Generator, Generic, TypeVar

from typing_extensions import Self

from stateless.errors import MissingAbilityError

T = TypeVar("T", covariant=True)


class Ability(Generic[T]):
"""The base ability type."""

def __iter__(self: Self) -> Generator[Self, T, T]:
"""Depend on `self` and return the value of handling `self`."""
try:
v = yield self
except MissingAbilityError:
raise MissingAbilityError(self) from None
return v
Loading
Loading