File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,9 @@ def _callable_get_arguments(
189189
190190
191191class TypeInfo :
192+
193+ # This struct tries to emulate gi.TypeInfo
194+
192195 def __init__ (
193196 self ,
194197 obj : Any ,
@@ -218,6 +221,9 @@ def get_name(self) -> str:
218221 def get_namespace (self ) -> str :
219222 return self .obj .get_namespace ()
220223
224+ def get_type (self ) -> GIRepository .InfoType :
225+ return self .obj .get_type ()
226+
221227
222228def _build_type (type : GIRepository .BaseInfo ) -> TypeInfo :
223229 return TypeInfo (
@@ -315,6 +321,15 @@ def _type_to_python(
315321 namespace = interface .get_namespace ()
316322 name = interface .get_name ()
317323
324+ if not re .match (_identifier_re , name ):
325+ # Convert Flags and Enums with invalid name to int
326+ # Example NM 1.0 library
327+ if interface .get_type () in (
328+ GIRepository .InfoType .FLAGS ,
329+ GIRepository .InfoType .ENUM ,
330+ ):
331+ return "int"
332+
318333 if namespace == "GObject" and name == "Value" :
319334 return "typing.Any"
320335
You can’t perform that action at this time.
0 commit comments