Skip to content

Commit a37563c

Browse files
committed
apply dataclass_transform to Error
1 parent 517e2bd commit a37563c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

taskiq/error.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
"""Minimal exception templating used by taskiq exceptions."""
22

3+
import sys
34
from string import Formatter
45

6+
if sys.version_info >= (3, 11):
7+
from typing import dataclass_transform
8+
else:
9+
from typing_extensions import dataclass_transform
510

11+
12+
@dataclass_transform(
13+
eq_default=False,
14+
order_default=False,
15+
kw_only_default=True,
16+
frozen_default=False,
17+
)
618
class Error(Exception):
719
"""Base templated exception compatible with taskiq needs."""
820

tests/test_error.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def test_template_with_required_value() -> None:
5151

5252
def test_missing_argument_raises_type_error() -> None:
5353
with pytest.raises(TypeError, match="Missing arguments: 'value'"):
54-
ValueTemplateError()
54+
ValueTemplateError() # type: ignore[call-arg]
5555

5656

5757
def test_undeclared_argument_raises_type_error() -> None:
5858
with pytest.raises(TypeError, match="Undeclared arguments: 'extra'"):
59-
ValueTemplateError(value=1, extra=2)
59+
ValueTemplateError(value=1, extra=2) # type: ignore[call-arg]
6060

6161

6262
def test_default_value_is_used_without_kwargs() -> None:

0 commit comments

Comments
 (0)