Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,28 @@ If you want to become familiar with the codebase, see

Please join in with any part of PyO3 which interests you. We use GitHub issues to record all bugs and ideas. Feel free to request an issue to be assigned to you if you want to work on it.

You can browse the API of the non-public parts of PyO3 [here](https://pyo3.netlify.app/internal/doc/pyo3/index.html).
You can browse the API of the non-public parts of PyO3 [here](https://pyo3.rs/internal/doc/pyo3/index.html).

The following sections also contain specific ideas on where to start contributing to PyO3.

## AI Contributions

We expect contributors using AI to respect the human effort required to handle contributions.
This includes pull requests, issues, comments, discussions, and any other interaction with the PyO3 community.
See other projects such as FastAPI which describes "Human Effort Denial of Service" and LLVM's discussion of "Extractive Contributions".

In general, we expect contributions to be submitted by a human author.
The author is responsible for the quality of anything produced with the assistance of their AI, and must be able to assert full copyright over any contributed code in accordance with our MIT and Apache licensing.
As an example, AI-generated code is typically highly verbose (as of mid 2026), so after generating code with AI please consider simplifying comments and code to aid with future readability and maintainability.
We prefer that authors disclose if code is generated by AI so we can take that into account in review without guesswork.

Any contribution which looks like it was produced by AI without sufficient human effort to ensure its quality may be closed at the PyO3 maintainers' discretion.
We will take into consideration (non-exhaustively) factors such as the size of the contribution and whether the GitHub account looks like it is engaging in widespread automated contributions.

We note that many have strong opinions on the use of AI, and the technical and social landscape is changing rapidly.
As a project PyO3 does not take a position on AI and its merits or issues; we accept that AI is a reality of current software development and wish to prioritise here the best outcomes for the PyO3 community.
This policy may be updated in the future to reflect coventions in the open source ecosystem as they evolve.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This policy may be updated in the future to reflect coventions in the open source ecosystem as they evolve.
This policy may be updated in the future to reflect conventions in the open source ecosystem as they evolve.


## Setting up a development environment

To work and develop PyO3, you need Python & Rust installed on your system.
Expand All @@ -32,8 +50,8 @@ The main nox commands we have implemented are:

* `nox -s test` will run the full suite of recommended rust and python tests (>10 minutes)
* `nox -s test-rust -- skip-full` will run a short suite of rust tests (2-3 minutes)
* `nox -s ruff` will check python linting and apply standard formatting rules
* `nox -s rustfmt` will check basic rust linting and apply standard formatting rules
* `nox -s ruff` will check python linting and formatting
* `nox -s rustfmt` will check rust formatting
* `nox -s rumdl` will check the markdown in the guide
* `nox -s clippy` will run clippy to make recommendations on rust style
* `nox -s bench` will benchmark your rust code
Expand Down Expand Up @@ -130,7 +148,7 @@ PRs are blocked from merging if CI is not successful.
Formatting, linting and tests are checked for all Rust and Python code (the pipeline will abort early if formatting fails to save resources).
In addition, all warnings in Rust code are disallowed (using `RUSTFLAGS="-D warnings"`).

Tests run with all supported Python versions with the latest stable Rust compiler, as well as for Python 3.9 with the minimum supported Rust version.
Tests run with all supported Python versions with the latest stable Rust compiler, as well as for the latest Python version with the minimum supported Rust version.

If you are adding a new feature, you should add it to the `full` feature in our *Cargo.toml** so that it is tested in CI.

Expand Down Expand Up @@ -164,17 +182,17 @@ PyO3 makes a lot of FFI calls to Python's C API using raw pointers. Where possib

```rust
// dangerous
pyo3::ffi::Something(name.to_object(py).as_ptr());
pyo3::ffi::Something(name.into_pyobject(py).as_ptr());

// because the following refactoring is a use-after-free error:
let name = name.to_object(py).as_ptr();
let name = name.into_pyobject(py).as_ptr();
pyo3::ffi::Something(name)
```

Instead, prefer to bind the safe owned `PyObject` wrapper before passing to ffi functions:
Instead, prefer to bind the safe owned smart pointer before passing to ffi functions:

```rust
let name: PyObject = name.to_object(py);
let name = name.into_pyobject(py);
pyo3::ffi::Something(name.as_ptr())
// name will automatically be freed when it falls out of scope
```
Expand All @@ -189,7 +207,7 @@ Below are guidelines on what compatibility all PRs are expected to deliver for e

### Python

PyO3 supports all officially supported Python versions, as well as the latest PyPy3 release. All of these versions are tested in CI.
PyO3 supports all officially supported Python versions, as well as the latest PyPy3 and GraalPy releases. All of these versions are tested in CI.

#### Adding support for new CPython versions

Expand Down
Loading