PyO3 / PyO3/pyo3

Documentation should specify the interaction of `#[staticmethod]` with magic methods

Open
#5,235 2 comments 0 reactions 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

Bug Description

https://pyo3.rs/main/class/protocols.html claims "All methods take a receiver as first argument, shown as .". This is contrary to @staticmethod magic methods defined in python classes. The documentation should either explicitly state that staticmethod magic methods are unsupported, that they don't match the python behavior, or that they are an exception to this bullet point.

Steps to Reproduce
Backtrace

Your operating system and version

MacOS

Your Python version (python --version)

Python 3.11.11

Your Rust version (rustc --version)

rustc 1.83.0 (90b35a623 2024-11-26)

Your PyO3 version

0.25.1

How did you install python? Did you use a virtualenv?

pyenv

Additional Info

No response

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 with the magic-method documentation at https://pyo3.rs/main/class/protocols.html and review the statement that all methods take a receiver. Check how the page describes staticmethod magic methods, then clarify whether they are unsupported, differ from Python behavior, or are an exception; done means the documentation explicitly explains this interaction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.