Skip to content

Commit 209a115

Browse files
committed
workaround for type narrowing with raise_exc
return a value so the type can be narrowed to Success when using `a = a.raise_exc()`. a.raise_exc() would not do any type narrowing currently.
1 parent 355c54c commit 209a115

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mahou/templates/aiohttp_client.py.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from collections.abc import Callable, Sequence
22
from dataclasses import dataclass
33
from datetime import date, datetime, time
44
from enum import Enum
5-
from typing import {{need_typing | map('capitalize') | join(', ')}}{% if need_typing %}, {% endif %}Any, NoReturn, Literal, TypeIs
5+
from typing import {{need_typing | map('capitalize') | join(', ')}}{% if need_typing %}, {% endif %}Any, Literal, NoReturn, Self, TypeIs
66
from uuid import UUID
77

88
import dataclasses
@@ -35,8 +35,8 @@ class Success[TCode, TSuccess]:
3535
code: TCode
3636
result: TSuccess
3737

38-
def raise_exc(self) -> None:
39-
pass
38+
def raise_exc(self) -> Self:
39+
return self
4040

4141

4242
@dataclass(slots=True)

0 commit comments

Comments
 (0)