Skip to content

Commit

Permalink
Merge branch 'main' into fix/keyword-only-non-default-argument
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanArhancet committed May 14, 2024
2 parents 8106d0a + aed6844 commit 0ace46a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
7 changes: 2 additions & 5 deletions src/errors/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ fn field_from_context<'py, T: FromPyObject<'py>>(
.map_err(|_| py_error_type!(PyTypeError; "{}: '{}' context value must be a {}", enum_name, field_name, type_name_fn()))
}

fn cow_field_from_context<'py, T: FromPyObject<'py>, B: ?Sized + 'static>(
fn cow_field_from_context<'py, T: FromPyObject<'py>, B: ToOwned<Owned = T> + ?Sized + 'static>(
context: Option<&Bound<'py, PyDict>>,
field_name: &str,
enum_name: &str,
_type_name_fn: fn() -> &'static str,
) -> PyResult<Cow<'static, B>>
where
B: ToOwned<Owned = T>,
{
) -> PyResult<Cow<'static, B>> {
let res: T = field_from_context(context, field_name, enum_name, || {
type_name::<T>().split("::").last().unwrap()
})?;
Expand Down
12 changes: 3 additions & 9 deletions src/serializers/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,17 @@ where
self.serialize_str(variant)
}

fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> Result<Self::Ok>
where
T: Serialize,
{
fn serialize_newtype_struct<T: Serialize + ?Sized>(self, _name: &'static str, value: &T) -> Result<Self::Ok> {
value.serialize(self)
}

fn serialize_newtype_variant<T: ?Sized>(
fn serialize_newtype_variant<T: Serialize + ?Sized>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T,
) -> Result<Self::Ok>
where
T: Serialize,
{
) -> Result<Self::Ok> {
tri!(self
.formatter
.begin_object(&mut self.writer)
Expand Down
1 change: 0 additions & 1 deletion src/validators/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl BuildValidator for ArgumentsValidator {
.map(|py_str| py_str.to_str())
.transpose()?
.unwrap_or("positional_or_keyword");

let positional = mode == "positional_only" || mode == "positional_or_keyword";
if positional {
positional_params_count = arg_index + 1;
Expand Down

0 comments on commit 0ace46a

Please sign in to comment.