pytoolz / pytoolz/toolz

Feature proposal: `raise`/`throws` function

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

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
280
Avg merge
6d 17h
Merged PRs (30d)
4

Description

Given lambda's lack of complexity, it may me surprising to learn that you can't raise an exception directly. However, it is possible to create a function that receives an exception and throws it, like so:

from toolz.functoolz import excepts

def throw(exception: Exception) -> Any:
    raise exception

validation_list = ['10', '20', '30', 'invalid']
validated_list = map(excepts(ValueError, int, lambda _: throw(ValidationError(...)), validation_list)

I believe this is a good candidate for inclusion on the functoolz module. What do you think?

Contributor guide

No contributing guide indexed for this repository

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.

Research direction

Start by inspecting the functoolz module and its existing exception-related helpers. Determine the intended public API and behavior for a raise/throws function, then add coverage for the agreed behavior; the issue does not name a source file or test location.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.