Rework some code to help with typing.

This commit is contained in:
Mike Auty
2018-11-01 11:17:15 +00:00
parent 8b7c34c20b
commit 001d53e768
2 changed files with 15 additions and 16 deletions
+4 -4
View File
@@ -43,13 +43,13 @@ class PrimitiveObject(interfaces.objects.ObjectInterface):
struct_format = struct_format)
self._struct_format = struct_format
def __new__(cls,
def __new__(cls: typing.Type,
context: interfaces.context.ContextInterface,
type_name: str,
object_info: interfaces.objects.ObjectInformation,
struct_format: str,
new_value: typing.Union[int, float, bool, bytes, str] = None,
**kwargs) -> 'PrimitiveObject':
**kwargs) -> typing.Type['PrimitiveObject']:
"""Creates the appropriate class and returns it so that the native type is inherited
The only reason the **kwargs is added, is so that the inherriting types can override __init__
@@ -136,12 +136,12 @@ class Bytes(PrimitiveObject, bytes):
struct_format = str(length) + "s")
self._vol['length'] = length
def __new__(cls,
def __new__(cls: typing.Type,
context: interfaces.context.ContextInterface,
type_name: str,
object_info: interfaces.objects.ObjectInformation,
length: int = 1,
**kwargs) -> 'Bytes':
**kwargs) -> typing.Type['Bytes']:
"""Creates the appropriate class and returns it so that the native type is inherritted
The only reason the **kwargs is added, is so that the inherriting types can override __init__