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
David Hewitt
76d1b34cd5
Revert "Merge pull request #3578 from davidhewitt/typed-helpers"
...
This reverts commit 7b07d6d21b
, reversing
changes made to 99858236bd
.
2024-02-03 20:56:23 +00:00
Mate Kovacs
3ed5ddb0ec
feat: support pyclass on complex enums
2024-01-18 22:04:42 +09:00
David Hewitt
4504a7c96e
fix some nightly lints 2024-01-12
2024-01-12 13:34:17 +00:00
David Hewitt
46c3190a17
clean up remnants of deprecated & removed features
2023-12-29 13:36:46 +00:00
Adam Reichold
83697f0c62
Also replace IterANextOutput by autoref-based specialization to allow returning arbitrary values
2023-12-20 09:56:16 +01:00
Adam Reichold
ca7d90dcf3
Replace IterNextOutput by autoref-based specialization to allow returning arbitrary values
2023-12-20 09:56:16 +01:00
Adam Reichold
d75d4bdf81
Fix some holdouts from using argument holders for lifetime extensions.
2023-12-20 09:56:16 +01:00
Adam Reichold
f03ccf204c
Also apply holder lifetime extension to slot implementations.
2023-12-19 16:29:43 +01:00
Adam Reichold
27019b5523
Use local variables to extend lifetime of holder references.
2023-12-19 16:21:18 +01:00
David Hewitt
07726aefc4
Merge pull request #3609 from wyfo/async_receiver
...
feat: allow async methods to accept `&self`/`&mut self`
2023-12-07 07:38:25 +00:00
Joseph Perez
f34c70c2da
feat: allow async methods to accept &self
/&mut self
2023-12-07 07:42:10 +01:00
David Hewitt
ed87637ebb
replace PyTryFrom
by splitting PyTypeInfo
2023-12-05 08:01:30 +03:00
Joseph Perez
8a674c2bd3
feat: add coroutine::CancelHandle
2023-12-04 07:46:51 +01:00
David Hewitt
e62e6cad5d
Merge pull request #3603 from davidhewitt/0.19-deprecations
...
remove all functionality deprecated in 0.19
2023-11-28 06:47:30 +00:00
David Hewitt
53311a90eb
Merge pull request #3602 from davidhewitt/dead-kws
...
remove some unused keyword declarations
2023-11-28 06:45:43 +00:00
Alex Gaynor
fae209419c
fixes #3561 -- silence new clippy warning
2023-11-27 17:06:59 -05:00
David Hewitt
5c6d49084f
remove all functionality deprecated in 0.19
2023-11-27 22:02:19 +00:00
David Hewitt
e76797a1d6
remove some unused keyword declarations
2023-11-27 21:32:01 +00:00
Joseph Perez
781b9e3983
feat: add coroutine __name__
/__qualname__
and not-awaited warning
2023-11-25 21:51:20 +01:00
David Hewitt
9f66846238
Merge pull request #3595 from davidhewitt/ok-wrap
...
refactor `OkWrap` to not call `.into_py(py)`
2023-11-25 05:43:54 +00:00
David Hewitt
c814078866
refactor OkWrap
to not call .into_py(py)
2023-11-24 10:41:08 +00:00
David Hewitt
5ac56b8eb0
improve error for invalid #[classmethod]
receivers
2023-11-24 03:24:46 +00:00
David Hewitt
aba3a3552d
remove type_is_pymodule
2023-11-22 21:30:10 +00:00
David Hewitt
69870d2298
Merge pull request #3540 from wyfo/coroutine
...
feat: support `async fn` in macros with coroutine implementation
2023-11-22 19:52:15 +00:00
David Hewitt
3f0dfa9698
Merge pull request #3587 from wyfo/classmethod_into
...
feat: allow classmethods to receive `Py<PyType>`
2023-11-22 19:34:19 +00:00
Joseph Perez
627841f1e2
feat: support async fn
in macros with coroutine implementation
2023-11-22 20:25:36 +01:00
Joseph Perez
744de3a142
feat: allow classmethod
/pass_module
to receive owned types
...
This is necessary for async functions
2023-11-22 07:45:59 +01:00
David Hewitt
abe518d164
Merge pull request #3586 from davidhewitt/semver-checks-v2
...
enable cargo-semver-checks, try 2
2023-11-20 07:07:44 +00:00
David Hewitt
7b07d6d21b
Merge pull request #3578 from davidhewitt/typed-helpers
...
Change return types of `py.None()`, `py.NotImplemented()` and `py.Ellipsis()` to typed singletons
2023-11-20 07:07:12 +00:00
David Hewitt
4a43b2f454
bump version to 0.21.0-dev
2023-11-19 06:41:10 +00:00
David Hewitt
bd0174aa5d
Change return types of py.None()
, py.NotImplemented()
and py.Ellipsis()
to typed singletons
2023-11-17 16:16:19 +00:00
David Hewitt
a9305ab389
ci: move lints to new 1.74 cargo.toml tables
2023-11-17 15:41:52 +00:00