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

Open
#401 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by locating transform_errors and format_exception, then inspect how notes carries target types for iterable and class structuring failures. The work is complete when format_exception can receive the exact target type for primitive types such as int and float without inspecting the error message.

Written by the indexing model from the issue text.

Description

  • 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.

Dominant language
Python
Stars
1.1k
Forks
159
Avg merge
12h 21m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-attrs/cattrs

All issues in python-attrs/cattrs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.