Skip to content

Commit

Permalink
Small fixes (#4567)
Browse files Browse the repository at this point in the history
* Fix misprint in PyClassArgs::parse_struct_args method name

* Fix non snake case complains for __pymethod_*

* add CHANGELOG

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
  • Loading branch information
ahlinc and davidhewitt authored Oct 1, 2024
1 parent faed5e2 commit caa3c51
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/4567.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix compiler warning about non snake case method names inside `#[pymethods]` generated code.
2 changes: 1 addition & 1 deletion pyo3-macros-backend/src/pyclass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl PyClassArgs {
})
}

pub fn parse_stuct_args(input: ParseStream<'_>) -> syn::Result<Self> {
pub fn parse_struct_args(input: ParseStream<'_>) -> syn::Result<Self> {
Self::parse(input, PyClassKind::Struct)
}

Expand Down
2 changes: 2 additions & 0 deletions pyo3-macros-backend/src/pymethod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,7 @@ impl SlotDef {
let name = spec.name;
let holders = holders.init_holders(ctx);
let associated_method = quote! {
#[allow(non_snake_case)]
unsafe fn #wrapper_ident(
py: #pyo3_path::Python<'_>,
_raw_slf: *mut #pyo3_path::ffi::PyObject,
Expand Down Expand Up @@ -1421,6 +1422,7 @@ impl SlotFragmentDef {
let holders = holders.init_holders(ctx);
Ok(quote! {
impl #cls {
#[allow(non_snake_case)]
unsafe fn #wrapper_ident(
py: #pyo3_path::Python,
_raw_slf: *mut #pyo3_path::ffi::PyObject,
Expand Down
2 changes: 1 addition & 1 deletion pyo3-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ fn pyclass_impl(
mut ast: syn::ItemStruct,
methods_type: PyClassMethodsType,
) -> TokenStream {
let args = parse_macro_input!(attrs with PyClassArgs::parse_stuct_args);
let args = parse_macro_input!(attrs with PyClassArgs::parse_struct_args);
let expanded = build_py_class(&mut ast, args, methods_type).unwrap_or_compile_error();

quote!(
Expand Down

0 comments on commit caa3c51

Please sign in to comment.