Skip to content

Commit 5b0ceb3

Browse files
Merge pull request #7 from betterproto/fix-repeated
Use the repeated metadata
2 parents b3d11a2 + 05f50dd commit 5b0ceb3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/betterproto_interop/message_meta.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22

33
use pyo3::{
4-
types::{PyAnyMethods, PyDict, PyDictMethods, PyList, PyType},
4+
types::{PyAnyMethods, PyDict, PyDictMethods, PyType},
55
Bound, FromPyObject, PyAny,
66
};
77

@@ -22,11 +22,10 @@ pub struct BetterprotoMessageMeta<'py> {
2222

2323
impl<'py> BetterprotoMessageMeta<'py> {
2424
pub fn is_list_field(&self, field_name: &str) -> InteropResult<bool> {
25-
let cls = self
26-
.default_gen
27-
.get(field_name)
28-
.ok_or(InteropError::IncompleteMetadata)?;
29-
Ok(cls.is(&cls.py().get_type_bound::<PyList>()))
25+
let meta = self.meta_by_field_name.call_method1("get", (field_name,))?;
26+
let repeated = meta.getattr("repeated")?.extract::<bool>()?;
27+
28+
Ok(repeated)
3029
}
3130

3231
pub fn get_class(&self, field_name: &str) -> InteropResult<&Bound<'py, PyType>> {

0 commit comments

Comments
 (0)