@@ -108,8 +108,8 @@ def __bool__(self):
108108
109109
110110class SymbolBASICTYPE (SymbolTYPE ):
111- """Defines a basic type (Ubyte, Byte, etc.. )
112- Basic (default) types are defined upon start and are case insensitive.
111+ """Defines a basic type (Ubyte, Byte, etc.)
112+ Basic (default) types are defined upon start and are case- insensitive.
113113 If name is None or '', default typename from TYPES.to_string will be used.
114114 """
115115
@@ -237,73 +237,74 @@ class Type:
237237 fixed = SymbolBASICTYPE (TYPE .fixed )
238238 float_ = SymbolBASICTYPE (TYPE .float )
239239 string = SymbolBASICTYPE (TYPE .string )
240+ boolean = SymbolBASICTYPE (TYPE .boolean )
240241
241- types = [ unknown , ubyte , byte_ , uinteger , integer , ulong , long_ , fixed , float_ , string ]
242+ types = unknown , ubyte , byte_ , uinteger , integer , ulong , long_ , fixed , float_ , string , boolean
242243
243244 _by_name = {x .name : x for x in types }
244245
245246 @staticmethod
246- def size (t : SymbolTYPE ):
247+ def size (t : SymbolTYPE ) -> int :
247248 assert isinstance (t , SymbolTYPE )
248249 return t .size
249250
250251 @staticmethod
251- def to_string (t : SymbolTYPE ):
252+ def to_string (t : SymbolTYPE ) -> str :
252253 assert isinstance (t , SymbolTYPE )
253254 return t .name
254255
255256 @classmethod
256- def by_name (cls , typename ):
257+ def by_name (cls , typename ) -> SymbolBASICTYPE | None :
257258 """Converts a given typename to Type"""
258259 return cls ._by_name .get (typename , None )
259260
260261 @classproperty
261- def integrals (cls ):
262- return ( cls .byte_ , cls .ubyte , cls .integer , cls .uinteger , cls .long_ , cls .ulong )
262+ def integrals (cls ) -> set [ SymbolBASICTYPE ] :
263+ return { cls .boolean , cls . byte_ , cls .ubyte , cls .integer , cls .uinteger , cls .long_ , cls .ulong }
263264
264265 @classproperty
265- def signed (cls ):
266- return cls .byte_ , cls .integer , cls .long_ , cls .fixed , cls .float_
266+ def signed (cls ) -> set [ SymbolBASICTYPE ] :
267+ return { cls .byte_ , cls .integer , cls .long_ , cls .fixed , cls .float_ }
267268
268269 @classproperty
269- def unsigned (cls ):
270- return cls .ubyte , cls .uinteger , cls .ulong
270+ def unsigned (cls ) -> set [ SymbolBASICTYPE ] :
271+ return { cls .boolean , cls . ubyte , cls .uinteger , cls .ulong }
271272
272273 @classproperty
273- def decimals (cls ):
274- return cls .fixed , cls .float_
274+ def decimals (cls ) -> set [ SymbolBASICTYPE ] :
275+ return { cls .fixed , cls .float_ }
275276
276277 @classproperty
277- def numbers (cls ):
278- return tuple ( list ( cls .integrals ) + list ( cls .decimals ))
278+ def numbers (cls ) -> set [ SymbolBASICTYPE ] :
279+ return cls .integrals | cls .decimals
279280
280281 @classmethod
281- def is_numeric (cls , t : SymbolTYPE ):
282+ def is_numeric (cls , t : SymbolTYPE ) -> bool :
282283 assert isinstance (t , SymbolTYPE )
283284 return t .final in cls .numbers
284285
285286 @classmethod
286- def is_signed (cls , t : SymbolTYPE ):
287+ def is_signed (cls , t : SymbolTYPE ) -> bool :
287288 assert isinstance (t , SymbolTYPE )
288289 return t .final in cls .signed
289290
290291 @classmethod
291- def is_unsigned (cls , t : SymbolTYPE ):
292+ def is_unsigned (cls , t : SymbolTYPE ) -> bool :
292293 assert isinstance (t , SymbolTYPE )
293294 return t .final in cls .unsigned
294295
295296 @classmethod
296- def is_integral (cls , t : SymbolTYPE ):
297+ def is_integral (cls , t : SymbolTYPE ) -> bool :
297298 assert isinstance (t , SymbolTYPE )
298299 return t .final in cls .integrals
299300
300301 @classmethod
301- def is_decimal (cls , t : SymbolTYPE ):
302+ def is_decimal (cls , t : SymbolTYPE ) -> bool :
302303 assert isinstance (t , SymbolTYPE )
303304 return t .final in cls .decimals
304305
305306 @classmethod
306- def is_string (cls , t : SymbolTYPE ):
307+ def is_string (cls , t : SymbolTYPE ) -> bool :
307308 assert isinstance (t , SymbolTYPE )
308309 return t .final == cls .string
309310
0 commit comments