* use `ffi::MemberGef` for `#[pyo3(get)]` fields of `Py<T>`
* tidy up implementation
* make it work on MSRV :(
* fix docs and newsfragment
* clippy
* internal docs and coverage
* review: mejrs
* Improve the span and message for return types of pymethod/functions
* Don't pass the span
* fixup trybuild output
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* feat: Add 'ord' option for PyClass and corresponding tests
Updated the macros back-end to include 'ord' as an option for PyClass allowing for Python-style ordering comparison of enum variants. Additionally, test cases to verify the proper functioning of this new feature have been introduced.
* update: fix formatting with cargo fmt
* update: documented added feature in newsfragments
* update: updated saved errors for comparison test for invalid pyclass args
* update: removed nested match arms and extended cases for ordering instead
* update: alphabetically ordered entries
* update: added section to class documentation with example for using ord argument.
* refactor: reduced duplication of code using closure to process tokens.
* update: used ensure_spanned macro to emit compile time errors for uses of ord on complex enums or structs, updated test errors for bad compile cases
* fix: remove errant character
* update: added note about PartialOrd being required.
* feat: implemented ordering for structs and complex enums. Retained the equality logic for simple enums until PartialEq is deprecated.
* update: adjusted compile time error checks for missing PartialOrd implementations. Refactored growing set of comparison tests for simple and complex enums and structs into separate test file.
* fix: updated with clippy findings
* update: added not to pyclass parameters on ord (assumes that eq will be implemented and merged first)
* update: rebased on main after merging of `eq` feature
* update: format update
* update: update all test output and doc tests
* Update guide/src/class.md
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Update pyo3-macros-backend/src/pyclass.rs
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Update newsfragments/4202.added.md
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Update guide/pyclass-parameters.md
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* update: added note about `ord` implementation with example.
* fix doc formatting
---------
Co-authored-by: Michael Gilbert <git.3mc1o@aleeas.com>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Declarative modules: make sure to emmit doc comments and other attributes
* Adds a test
* Apply suggestions from code review
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* fix incorrect `__richcmp__` for `eq_int` only simple enums
* add tests for deprecated simple enum eq behavior
* only emit deprecation warning if neither `eq` nor `eq_int` were given
* require `eq` for `eq_int`
* feat: support pyclass on tuple enums
* cargo fmt
* changelog
* ruff format
* rebase with adaptation for FnArg refactor
* fix class.md from pr comments
* add enum tuple variant getitem implementation
* fmt
* progress toward getitem and len impl on derive pyclass for complex enum tuple
* working getitem and len slots for complex tuple enum pyclass derivation
* refactor code generation
* address PR concerns
- take py from function argument on get_item
- make more general slot def implementation
- remove unnecessary function arguments
- add testcases for uncovered cases including future feature match_args
* add tracking issue
* fmt
* ruff
* remove me
* support match_args for tuple enum
* integrate FnArg now takes Cow
* fix empty and single element tuples
* use impl_py_slot_def for cimplex tuple enum slots
* reverse erroneous doc change
* Address latest comments
* formatting suggestion
* fix :
- clippy beta
- better compile error (+related doc and test)
---------
Co-authored-by: Chris Arderne <chris@translucent.app>
* deprecate GIL Refs in function arguments
* fix deprecated gil refs in function arguments
* add notes on deprecations limitations to migration guide
* Apply suggestions from code review
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* review: Icxolu
* fix proto method extract failure for option
* fix gil refs in examples
---------
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* deprecate `wrap_pyfunction` with `py` argument
The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.
* merge `Extractor`s
* add deprecation ui test, revert closure variant due to test failure
* fix nightly
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs
* review: alex, Icxolu feedback
* add newsfragment
* add newsfragment for `FromPyObject` trait change
* make some examples compatible with abi3 < 3.10
* seal `FromPyObjectBound`
* fixup chrono_tz conversion
* deprecate `&PyModule` as `#[pymodule]` argument type
* cleanup
* add ui tests
* fix deprecations in tests
* fix maturin and setuptools-rust starters
* run `deprecated` ui test only when `gil-refs` as disabled
* deprecate the use of `PyCell` in favor of `Bound` and `Py`
* update `FromPyObject` for `T: PyClass + Clone` impl
* move `PyCell` deprecation to the `gil-refs` feature gate and add a migration note
* Use single-arg form for `#[pymodule]` functions in docs and tests
* Update guide/src/function.md
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* Add test of two-argument module function
* Fix new test
---------
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* #[pymodule] mod some_module { ... } v3
Based on #2367 and #3294
Allows to export classes, native classes, functions and submodules and provide an init function
See test/test_module.rs for an example
Future work:
- update examples, README and guide
- investigate having #[pyclass] and #[pyfunction] directly in the #[pymodule]
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
* tests: group exported imports
* Consolidate pymodule macro code to avoid duplicates
* Makes pymodule_init take Bound<'_, PyModule>
* Renames #[pyo3] to #[pymodule_export]
* Gates #[pymodule] mod behind the experimental-declarative-modules feature
* Properly fails on functions inside of declarative modules
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>