PyO3 / PyO3/pyo3

Add macro for importing a type (ala import_exception)

Open
#3,428 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
16.2k
Forks
1k
Avg merge
2d 6h
Merged PRs (30d)
66

Description

Currently import_exception makes it easy to import and use an exception type defined in Python from Rust. It'd be useful to have a generalized version of this that gave you a type.

Right now it can be accomplished by writing imperative py.import().getattr() statements, but these are quite verbose.

It'd be a big ergonomics win to have a builtin way to do this.

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.

Research direction

Start by examining the existing import_exception macro and the imperative py.import().getattr() pattern described in the issue. Define the generalized builtin macro's expected type-import behavior, then confirm it can replace the verbose sequence while yielding the requested Python type.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
api, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.