Skip to content

Commit 116d25b

Browse files
authored
Fix type checker error (#378)
* Fix type checker error Pyright expects `typing.Type` to be parameterised and reports that the function's type is unknown. * Add changelog entry
1 parent dedd72d commit 116d25b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

HISTORY.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- _cattrs_ is now linted with [Ruff](https://beta.ruff.rs/docs/).
77
- Fix TypedDicts with periods in their field names.
88
([#376](https://github.com/python-attrs/cattrs/issues/376) [#377](https://github.com/python-attrs/cattrs/pull/377))
9+
- Fix `format_exception` and `transform_error` type annotations.
910

1011
## 23.1.2 (2023-06-02)
1112

src/cattrs/v.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Cattrs validation."""
2-
from typing import Callable, List, Type, Union
2+
from typing import Callable, List, Union
33

44
from .errors import (
55
ClassValidationError,
@@ -10,7 +10,7 @@
1010
__all__ = ["format_exception", "transform_error"]
1111

1212

13-
def format_exception(exc: BaseException, type: Union[Type, None]) -> str:
13+
def format_exception(exc: BaseException, type: Union[type, None]) -> str:
1414
"""The default exception formatter, handling the most common exceptions.
1515
1616
The following exceptions are handled specially:
@@ -61,7 +61,7 @@ def transform_error(
6161
exc: Union[ClassValidationError, IterableValidationError, BaseException],
6262
path: str = "$",
6363
format_exception: Callable[
64-
[BaseException, Union[Type, None]], str
64+
[BaseException, Union[type, None]], str
6565
] = format_exception,
6666
) -> List[str]:
6767
"""Transform an exception into a list of error messages.

0 commit comments

Comments
 (0)