Icxolu
e835ff0ec3
handle `#[pyo3(from_py_with = ...)]` on dunder (`__magic__`) methods ( #4117 )
...
* handle `#[pyo3(from_py_with = ...)]` on dunder (__magic__) methods
* add newsfragment
2024-05-04 07:39:40 +00:00
Bruno Kolenbrander
f5fee94afc
Scope macro imports more tightly ( #4088 )
2024-04-23 18:01:41 +00:00
dependabot[bot]
b11174e96d
Update heck requirement from 0.4 to 0.5 ( #3966 )
...
* Update heck requirement from 0.4 to 0.5
---
updated-dependencies:
- dependency-name: heck
dependency-type: direct:production
...
Signed-off-by: dependabot[bot] <support@github.com>
* newsfragment
---------
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-04-18 10:22:34 +00:00
David Hewitt
2c205d4586
release notes for 0.21.2 ( #4091 )
2024-04-18 08:59:02 +00:00
Icxolu
cc7e16f4d6
Refactoring of `FnArg` ( #4033 )
...
* refactor `FnArg`
* add UI tests
* use enum variant types
* add comment
* remove dead code
* remove last FIXME
* review feedback davidhewitt
2024-04-14 14:19:57 +00:00
Adam Reichold
721100a9e9
Suppress non_local_definitions lint as we often want the non-local effects in macro code ( #4074 )
...
* 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
2024-04-13 12:59:44 +00:00
Icxolu
ee5216f406
fix declarative-modules compile error ( #4054 )
...
* fix declarative-modules compile error
* add newsfragment
2024-04-12 06:34:27 +00:00
Icxolu
c8b59d7117
add `#[doc(hidden)]` to the Rust module created by `#[pymodule]` ( #4067 )
...
* add `#[doc(hidden)]` to the Rust module created by `#[pymodule]`
* add newsfragment
2024-04-12 06:34:08 +00:00
Icxolu
7a00b4d357
add descriptive error msg for `__traverse__` receivers other than `&self` ( #4045 )
...
* add descriptive error msg for `__traverse__` receivers other than `self`
* add newsfragment
* improve error message
2024-04-04 19:08:51 +00:00
David Hewitt
a4aea230ed
fix compile error for multiple async method arguments ( #4035 )
2024-04-02 17:43:51 +00:00
David Hewitt
c1f11fb4bd
release: 0.21.1 ( #4032 )
2024-04-01 18:51:58 +00:00
Icxolu
8f87b8636d
refactor `#[setter]` argument extraction ( #4002 )
2024-04-01 12:10:18 +00:00
Weijie Guo
74d9d23ba0
async method should allow args not only receiver ( #4015 )
...
* async method should allow args not only receiver
* add changelog md
2024-03-30 08:48:19 +00:00
Alex Gaynor
de03ca270a
Remove dead code in macros backend ( #4011 )
2024-03-29 21:28:08 +00:00
David Hewitt
cf74624de9
refactor to remove add_to_module functions from generated code ( #4009 )
...
* refactor to remove add_to_module functions from generated code
* mrsv, newsfragment
* clippy
2024-03-29 11:54:33 +00:00
Icxolu
dd1710256d
use `extract_argument` for `#[setter]` extraction ( #3998 )
...
* use `extract_argument` for `#[setter]` extraction
* add newsfragment
2024-03-27 15:41:04 +00:00
Icxolu
35faeff6f1
handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods ( #3995 )
...
* handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods
* add newsfragment
2024-03-26 18:53:11 +00:00
David Hewitt
1be2fad9bf
release: 0.21.0 ( #3983 )
2024-03-25 23:36:08 +00:00
David Hewitt
870a4bb20d
deprecate GIL refs in function argument ( #3847 )
...
* 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>
2024-03-20 22:35:08 +00:00
Icxolu
2736cf670c
deprecate gil-refs in `from_py_with` (Part 2) ( #3972 )
...
* deprecate `from_py_with` in `#[derive(FromPyObject)]` (NewType)
* deprecate `from_py_with` in `#[derive(FromPyObject)]` (Enum, Struct)
2024-03-20 09:27:38 +00:00
David Hewitt
02e188e4b4
adjust path for GIL Refs deprecation warnings ( #3968 )
2024-03-19 21:08:20 +00:00
Icxolu
b06e95727b
deprecate gil-refs in `from_py_with` ( #3967 )
...
* deprecate gil-refs in `from_py_with`
* review feedback davidhewitt
2024-03-19 08:58:41 +00:00
Bruno Kolenbrander
989d2c53ab
Fix non_local_definitions lint triggers ( #3955 )
2024-03-12 22:59:33 +00:00
David Hewitt
67b1b35013
release: 0.21.0-beta.0 ( #3944 )
2024-03-10 22:16:18 +00:00
Icxolu
908e661237
deprecate gil-refs in "self" position ( #3943 )
...
* deprecate gil-refs in "self" position
* feature gate explicit gil-ref tests
* fix MSRV
* adjust bracketing
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-09 09:52:12 +00:00
Icxolu
31c4820010
deprecate `&PyModule` as `#[pymodule]` argument type ( #3936 )
...
* 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
2024-03-08 00:28:11 +00:00
Thomas Tanon
fbd531195a
PyAddToModule: Properly propagate initialization error ( #3919 )
...
Better than panics
2024-03-06 18:20:02 +00:00
David Hewitt
57bbc32e7c
add `experimental-async` feature ( #3931 )
...
* add `experimental-async` feature
* gate async doctests on feature
2024-03-06 00:54:45 +00:00
Thomas Tanon
fe84fed966
Allow inline struct, enum, fn and mod inside of declarative modules ( #3902 )
...
* Inline struct, enum, fn and mod inside of declarative modules
* remove news fragment
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-06 00:31:56 +00:00
Bruno Kolenbrander
4114dcb1a0
Thread pyo3's path through the builder functions ( #3907 )
...
* Thread pyo3's path through the builder functions
* preserve span of pyo3_path
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-04 07:54:04 +00:00
Icxolu
70a7aa808d
deprecate the use of `PyCell` in favor of `Bound` and `Py` ( #3916 )
...
* 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
2024-03-03 14:47:25 +00:00
David Hewitt
2e56f659ed
split `PyCell` and `PyClassObject` concepts ( #3917 )
...
* add test for refguard ref counting
* split `PyCell` and `PyClassObject` concepts
* rework `create_cell` to `create_class_object`
* Apply suggestions from code review
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
* review: Icxolu feedback
---------
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-03 07:00:59 +00:00
Icxolu
1c5265e1c2
deprecate `from_borrowed_ptr` methods ( #3915 )
...
* 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
2024-03-01 20:51:53 +00:00
David Hewitt
8a12970c96
update `extract_argument` to use Bound APIs ( #3708 )
...
* update `extract_argument` to use `Bound` APIs
* tidy up borrow in macros expression
* update `trybuild` output
* more concise form for `DowncastError::new`
Co-authored-by: Lily Foote <code@lilyf.org>
* use `Borrowed` instead of newtype
* use `Borrowed::from_ptr` methods in extract_argument
* update UI tests
* avoid double-negative `#[cfg]` clauses
Co-authored-by: Lily Foote <code@lilyf.org>
* review: LilyFoote, Icxolu feedback
---------
Co-authored-by: Lily Foote <code@lilyf.org>
2024-02-28 19:36:20 +00:00
Matthew Neeley
a15e4b1a11
Allow pymodule functions to take a single Bound<'_, PyModule> arg ( #3905 )
2024-02-27 22:24:14 +00:00
Icxolu
6f03a5464f
cleans up `PyCFunction::internal_new` ( #3910 )
...
This deduplicates some code around `PyCFunction::internal_new`
2024-02-27 22:15:35 +00:00
Lily Foote
a3ad28b70c
Pymodule bound ( #3897 )
...
* 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>
2024-02-27 19:19:52 +00:00
David Hewitt
8e2219b0d9
silence non-local-definitions nightly lint ( #3901 )
...
* silence non-local-definitions nightly lint
* add newsfragment
* add FIXMEs for `non_local_definitions`
* also allow `non_local_definitions` in doctests
2024-02-26 20:28:04 +00:00
Icxolu
7c10ff4327
allow `Bound<'_, T>` in #[pymethods] `self` position ( #3896 )
...
* allow `Bound<'_, T>` in #[pymethods] `self` position
* rename `TryFromPyCell` -> `TryFromBoundRef`
* remove unneccessary unsafe
2024-02-25 07:13:36 +00:00
Thomas Tanon
e0e3981e17
#[pymodule] mod some_module { ... } v3 ( #3815 )
...
* #[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>
2024-02-24 13:50:18 +00:00
David Hewitt
fbf2e91914
macros: exact dependency on `pyo3-build-config` ( #3889 )
2024-02-23 12:30:46 +00:00
Lily Foote
22a23ffb31
Tidy some usage of `py.from_borrowed_ptr` and `py.from_borrowed_ptr_or_opt` ( #3877 )
...
* Tidy some usage of py.from_borrowed_ptr
* Add BoundRef::ref_from_ptr_or_opt
2024-02-22 23:06:55 +00:00
Icxolu
4f8ee96881
fix `AsRef` and `Deref` impls on `Bound<T>` ( #3879 )
...
* fix `AsRef` and `Deref` of `Bound<T>` to `Bound<PyAny>`
* cleanup unnessesary `.as_any()` calls
* remove trait bound on `AsRef` impl
* add comment for `Deref` trait bound
* rename marker trait
2024-02-22 22:38:42 +00:00
Lily Foote
b4dc854585
Convert LazyTypeObject to use the Bound API ( #3855 )
2024-02-18 22:01:50 +00:00
Icxolu
4ce9c35983
port `Python::get_type` to `Bound` API ( #3846 )
...
* port `Python::get_type` to `Bound` API
* fix `is_subclass_and_is_instance` FIXME
2024-02-18 18:27:19 +00:00
David Hewitt
ec6d587218
support `Bound` for `classmethod` and `pass_module` ( #3831 )
...
* support `Bound` for `classmethod` and `pass_module`
* `from_ref_to_ptr` -> `ref_from_ptr`
* add detailed docs to `ref_from_ptr`
2024-02-16 00:36:11 +00:00
Icxolu
9902633116
allow `from_py_with` on function args to take a `fn(&Bound) -> PyResult` ( #3837 )
2024-02-14 22:03:04 +00:00
David Hewitt
f5eafe23f2
add maximum Python version check ( #3821 )
...
* add maximum Python version check
* restore dependency of `pyo3-macros-backend` on `pyo3-build-config`
* fix clippy-all noxfile job
2024-02-13 21:52:53 +00:00
Icxolu
fbfeb2ff03
update `#[derive(FromPyObject)]` to use `extract_bound` ( #3828 )
...
* update `#[derive(FromPyObject)]` to use `extract_bound`
* type inference for `from_py_with` using function pointers
2024-02-13 00:09:41 +00:00
David Hewitt
0d4df9c19d
adjust `FromPyObject` implementations to always use `'py` lifetime
2024-02-04 14:22:03 +00:00