@@ -79,7 +79,7 @@ impl PyStruct {
79
79
|value| Ok ( self . type_collection . to_py_value ( value. clone ( ) ) ) ,
80
80
)
81
81
}
82
- fn __setattr__ ( & mut self , py : Python < ' _ > , key : String , value : PyObject ) -> PyResult < ( ) > {
82
+ fn __setattr__ ( & mut self , py : Python < ' _ > , key : String , value : Py < PyAny > ) -> PyResult < ( ) > {
83
83
let pv =
84
84
TypeCollection :: slint_value_from_py_value ( py, & value, Some ( & self . type_collection ) ) ?;
85
85
self . data . set_field ( key, pv) ;
@@ -123,12 +123,12 @@ impl PyStructFieldIterator {
123
123
}
124
124
125
125
thread_local ! {
126
- static ENUM_CLASS : OnceCell <PyObject > = OnceCell :: new( ) ;
126
+ static ENUM_CLASS : OnceCell <Py < PyAny > > = OnceCell :: new( ) ;
127
127
}
128
128
129
- pub fn enum_class ( py : Python ) -> PyObject {
129
+ pub fn enum_class ( py : Python ) -> Py < PyAny > {
130
130
ENUM_CLASS . with ( |cls| {
131
- cls. get_or_init ( || -> PyObject {
131
+ cls. get_or_init ( || -> Py < PyAny > {
132
132
let enum_module = py. import ( "enum" ) . unwrap ( ) ;
133
133
enum_module. getattr ( "Enum" ) . unwrap ( ) . into ( )
134
134
} )
@@ -141,7 +141,7 @@ pub fn enum_class(py: Python) -> PyObject {
141
141
/// a `.slint` file loaded with load_file. This is used to map enums
142
142
/// provided by Slint to the correct python enum classes.
143
143
pub struct TypeCollection {
144
- enum_classes : Rc < HashMap < String , PyObject > > ,
144
+ enum_classes : Rc < HashMap < String , Py < PyAny > > > ,
145
145
}
146
146
147
147
impl TypeCollection {
@@ -193,7 +193,7 @@ impl TypeCollection {
193
193
enum_name : & str ,
194
194
enum_value : & str ,
195
195
py : Python < ' _ > ,
196
- ) -> Result < PyObject , PyErr > {
196
+ ) -> Result < Py < PyAny > , PyErr > {
197
197
let enum_cls = self . enum_classes . get ( enum_name) . ok_or_else ( || {
198
198
PyErr :: new :: < pyo3:: exceptions:: PyTypeError , _ > ( format ! (
199
199
"Slint provided enum {enum_name} is unknown"
@@ -209,13 +209,13 @@ impl TypeCollection {
209
209
crate :: models:: ReadOnlyRustModel { model : model. clone ( ) , type_collection : self . clone ( ) }
210
210
}
211
211
212
- pub fn enums ( & self ) -> impl Iterator < Item = ( & String , & PyObject ) > {
212
+ pub fn enums ( & self ) -> impl Iterator < Item = ( & String , & Py < PyAny > ) > {
213
213
self . enum_classes . iter ( )
214
214
}
215
215
216
216
pub fn slint_value_from_py_value (
217
217
py : Python < ' _ > ,
218
- ob : & PyObject ,
218
+ ob : & Py < PyAny > ,
219
219
type_collection : Option < & Self > ,
220
220
) -> PyResult < slint_interpreter:: Value > {
221
221
Self :: slint_value_from_py_value_bound ( & ob. bind ( py) , type_collection)
0 commit comments