cattrs icon indicating copy to clipboard operation
cattrs copied to clipboard

Pass type information to `format_exception` from `transform_errors` for primitive types

Open PIG208 opened this issue 11 months ago • 0 comments

  • cattrs version: v23.1.2
  • Python version: Python 3.8
  • Operating System: Ubuntu 20.04

Description

In #258, __notes__ were added to support passing AttributeValidationNote and IterableValidationNote around. transform_errors uses these notes to pass the target type when calling format_exception. This works well in most cases, except for primitive types.

Feature Request

I want to be able to customize my format_exception function so that I know the exact target type of the exception without needing to inspect the error message. If I understand it correctly, in the current design, __notes__ is only set on exceptions that are raised when structuring an iterable or class, but is not for types like int, float and etc.

PIG208 avatar Jul 29 '23 02:07 PIG208