Skip to content

Commit fbc125c

Browse files
[mq] working branch - merge 177f38f on top of main at 5027515
{"baseBranch":"main","baseCommit":"502751505782f8ae8f1446d3f4c19ed1b344bae9","createdAt":"2025-12-22T14:12:24.591442Z","headSha":"177f38f55ec93b4d0a3ea584aaa43b56b03e4ea6","id":"da3cbdd9-4f4a-4a98-9c37-c082af9077c8","priority":"200","pullRequestNumber":"1420","queuedAt":"2025-12-22T14:12:24.589890Z","status":"STATUS_QUEUED"}
2 parents d4164ee + 177f38f commit fbc125c

File tree

5 files changed

+32
-26
lines changed

5 files changed

+32
-26
lines changed

Cargo.lock

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datadog-ffe/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ serde-bool = { version = "0.1.3", default-features = false }
2323
serde_with = { version = "3.11.0", default-features = false, features = ["base64", "hex", "macros"] }
2424
thiserror = { version = "2.0.3", default-features = false }
2525
url = { version = "2.5.0", default-features = false, features = ["std"] }
26-
pyo3 = { version = "0.25", optional = true, default-features = false, features = ["macros"] }
26+
pyo3 = { version = "0.27.2", optional = true, default-features = false, features = ["macros"] }
2727

2828
[dev-dependencies]
2929
env_logger = "0.10"

datadog-ffe/src/rules_based/attributes.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ mod pyo3_impl {
6969
exceptions::PyTypeError,
7070
prelude::*,
7171
types::{PyBool, PyFloat, PyInt, PyString},
72+
Borrowed,
7273
};
7374

7475
/// Convert Python value to Attribute.
@@ -81,20 +82,22 @@ mod pyo3_impl {
8182
/// - `NoneType`
8283
///
8384
/// Note that nesting is not currently supported and will throw an error.
84-
impl<'py> FromPyObject<'py> for Attribute {
85+
impl<'a, 'py> FromPyObject<'a, 'py> for Attribute {
86+
type Error = PyErr;
87+
8588
#[inline]
86-
fn extract_bound(value: &Bound<'py, PyAny>) -> PyResult<Self> {
87-
if let Ok(s) = value.downcast::<PyString>() {
89+
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
90+
if let Ok(s) = value.cast::<PyString>() {
8891
return Ok(Attribute(AttributeImpl::String(s.to_cow()?.into())));
8992
}
9093
// In Python, Bool inherits from Int, so it must be checked first here.
91-
if let Ok(s) = value.downcast::<PyBool>() {
94+
if let Ok(s) = value.cast::<PyBool>() {
9295
return Ok(Attribute(AttributeImpl::Boolean(s.is_true())));
9396
}
94-
if let Ok(s) = value.downcast::<PyFloat>() {
97+
if let Ok(s) = value.cast::<PyFloat>() {
9598
return Ok(Attribute(AttributeImpl::Number(s.value())));
9699
}
97-
if let Ok(s) = value.downcast::<PyInt>() {
100+
if let Ok(s) = value.cast::<PyInt>() {
98101
return Ok(Attribute(AttributeImpl::Number(s.extract::<f64>()?)));
99102
}
100103
if value.is_none() {

datadog-ffe/src/rules_based/eval/evaluation_context.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl EvaluationContext {
5151
mod pyo3_impl {
5252
use super::*;
5353

54-
use pyo3::{intern, prelude::*, types::PyDict};
54+
use pyo3::{intern, prelude::*, types::PyDict, Borrowed};
5555

5656
/// Accepts either a dict with `"targeting_key"` and `"attributes"` items, or any object with
5757
/// `targeting_key` and `attributes` attributes.
@@ -70,12 +70,14 @@ mod pyo3_impl {
7070
///
7171
/// EvaluationContext(targeting_key="user1", attributes={"attr1": 42})
7272
/// ```
73-
impl<'py> FromPyObject<'py> for EvaluationContext {
73+
impl<'a, 'py> FromPyObject<'a, 'py> for EvaluationContext {
74+
type Error = PyErr;
75+
7476
#[inline]
75-
fn extract_bound(value: &Bound<'py, PyAny>) -> PyResult<Self> {
77+
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
7678
let py = value.py();
7779

78-
let (targeting_key, attributes) = if let Ok(dict) = value.downcast::<PyDict>() {
80+
let (targeting_key, attributes) = if let Ok(dict) = value.cast::<PyDict>() {
7981
(
8082
dict.get_item(intern!(py, "targeting_key"))?,
8183
dict.get_item(intern!(py, "attributes"))?,

datadog-ffe/src/rules_based/str.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ mod pyo3_impl {
118118

119119
use super::*;
120120

121-
use pyo3::{prelude::*, types::PyString};
121+
use pyo3::{prelude::*, types::PyString, Borrowed};
122+
123+
impl<'a, 'py> FromPyObject<'a, 'py> for Str {
124+
type Error = PyErr;
122125

123-
impl<'py> FromPyObject<'py> for Str {
124126
#[inline]
125-
fn extract_bound(value: &Bound<'py, PyAny>) -> PyResult<Self> {
126-
let s = value.downcast::<PyString>()?;
127+
fn extract(value: Borrowed<'a, 'py, PyAny>) -> PyResult<Self> {
128+
let s = value.cast::<PyString>()?;
127129
Ok(Str::from(s.to_cow()?))
128130
}
129131
}

0 commit comments

Comments
 (0)