Skip to content

Commit c7f6801

Browse files
committed
⬆️ deprecated python 3.9
1 parent 55355a7 commit c7f6801

File tree

10 files changed

+27
-20
lines changed

10 files changed

+27
-20
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
py_ver: ['3.9', '3.10', '3.11', '3.12']
7+
py_ver: ['3.10', '3.11', '3.12', '3.13']
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4

arclet/letoderea/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
from .typing import EVENT as EVENT
4444
from .typing import Contexts as Contexts
4545
from .typing import Force as Force
46+
from .typing import Result as Result
4647

4748
from . import core as es # noqa: F401

arclet/letoderea/core.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from types import AsyncGeneratorType
99
from typing import Any, Callable, Coroutine, Literal, TypeVar, overload, cast
1010

11-
from tarina import generic_isinstance
1211
from typing_extensions import dataclass_transform
1312

1413
from .exceptions import ExitState, STOP, BLOCK
@@ -120,10 +119,8 @@ async def broadcast(event: Any, scope: str | Scope | None = None, slots: Iterabl
120119
async def dispatch(event: Any, scope: str | Scope | None = None, slots: Iterable[tuple[Subscriber, str]] | None = None, inherit_ctx: Contexts | None = None, *, return_result: bool = False, validate: bool = False):
121120
async for res in broadcast(event, scope, slots, inherit_ctx):
122121
if return_result:
123-
if validate and hasattr(event, "__result_type__"):
124-
value = res.value if isinstance(res, Result) else res
125-
if not generic_isinstance(value, event.__result_type__): # type: ignore
126-
continue
122+
if validate and hasattr(event, "check_result"):
123+
return cast(Resultable, event).check_result(res.value if isinstance(res, Result) else res)
127124
return res if isinstance(res, Result) else Result(res)
128125

129126

arclet/letoderea/typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ class Result(Generic[T]):
8383

8484

8585
class Resultable(Protocol[T]):
86-
__result_type__: type[T]
86+
def check_result(self, value: Any) -> Result[T] | None: ...

examples/communicate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import asyncio
22
from dataclasses import dataclass
33

4-
from arclet.letoderea import es, make_event, define
4+
from arclet.letoderea import Result, es, make_event, define
55

66

77
@make_event
@@ -13,7 +13,8 @@ class TestEvent:
1313
class Data:
1414
query: str
1515

16-
__result_type__ = str
16+
def check_result(self, value) -> Result[str] | None:
17+
...
1718

1819

1920
define(Data, name="pluginA")

pdm.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ authors = [
77
]
88
dependencies = [
99
"tarina<0.8.0,>=0.7.0",
10+
"typing-extensions>=4.12.0",
1011
]
1112
requires-python = ">=3.9"
1213
readme = "README.md"
@@ -47,7 +48,7 @@ dev = [
4748
]
4849
[tool.black]
4950
line-length = 120
50-
target-version = ["py39", "py310", "py311", "py312"]
51+
target-version = ["py310", "py311", "py312", "py313"]
5152
include = '\.pyi?$'
5253
extend-exclude = '''
5354
'''
@@ -60,12 +61,17 @@ extra_standard_library = ["typing_extensions"]
6061

6162
[tool.ruff]
6263
line-length = 120
63-
target-version = "py39"
64+
target-version = "py310"
6465

6566
[tool.ruff.lint]
6667
select = ["E", "W", "F", "UP", "C", "T", "Q"]
6768
ignore = ["E402", "F403", "F405", "C901", "UP037"]
6869

70+
[tool.pyright]
71+
pythonVersion = "3.10"
72+
pythonPlatform = "All"
73+
typeCheckingMode = "basic"
74+
6975
[tool.pytest.ini_options]
7076
asyncio_mode = "auto"
7177
asyncio_default_fixture_loop_scope = "session"

tests/test_chain_post.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
class BaseEvent:
77
foo: str
88

9-
__result_type__ = str
9+
def check_result(self, value) -> le.Result[str] | None:
10+
if isinstance(value, str):
11+
return le.Result(value)
1012

1113

1214
@le.make_event

tests/test_dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestEvent1:
2828
foo: str
2929
bar: str
3030

31-
__result_type__ = str
31+
def check_result(self, value) -> le.Result[str] | None: ...
3232

3333

3434
@pytest.mark.asyncio

tests/test_publisher_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class CallEvent:
1414
content: str
1515
params: dict
1616

17-
__result_type__ = str
17+
def check_result(self, value) -> le.Result[str] | None: ...
1818

1919

2020
pub = le.define(CallEvent, name="called_event")

0 commit comments

Comments
 (0)