* 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>
This allow also storing idents that were generated
as part of the macro instead of only ones the were
present in the source code. This is needed for
example in complex enum tuple variants.
* Resolve references to legacy numerical constants and use the associated constants instead
* Suppress non_local_definitions lint as we often want the non-local effects in macro code
* 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 `&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
* deprecate `from_borrowed_ptr` methods
This deprecates the methods on the `Python`
marker, aswell as `FromPyPointer`
* use `BoundRef` to defer ref cnt inc until after the error case
* Support Bound in pymodule and pyfunction macros
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* Remove spurious $ character
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
* Rework PyCFunction::new_bound signatures
This allows us to remove the awkward `PyFunctionArgumentsBound` enum.
* Use BoundRef instead of BoundModule
* support argument deduction for `wrap_pyfunction_bound!`
* support `wrap_pyfunction!` with `Bound` input/output
* Fix docs link to `wrap_pyfunction_bound!`
* Revert back to wrap_pyfunction!
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Matthew Neeley <mneeley@gmail.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>