Improve the typing in places.

This commit is contained in:
Mike Auty
2018-10-11 11:14:29 +01:00
parent 21384be035
commit f1c5b3ca29
2 changed files with 8 additions and 5 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ class DtbTest(validity.ValidityRoutines):
self.ptr_size = struct.calcsize(ptr_struct)
self.ptr_reference = self._check_type(ptr_reference, int)
self.mask = self._check_type(mask, int)
self.page_size = layer_type.page_size
self.page_size = layer_type.page_size # type: int
def _unpack(self, value: bytes) -> int:
return struct.unpack("<" + self.ptr_struct, value)[0]
+7 -4
View File
@@ -9,16 +9,19 @@ from volatility.framework.configuration import requirements
vollog = logging.getLogger(__name__)
_T = typing.TypeVar("_T")
_S = typing.TypeVar("_S")
class classproperty(object):
"""Class property decorator
Note this will change the return type """
def __init__(self, func: typing.Callable[[typing.Any], typing.Any]) -> None:
def __init__(self, func: typing.Callable[[_S], _T]) -> None:
self._func = func
def __get__(self, _owner_self, owner_cls: typing.Type) -> typing.Any:
def __get__(self, _owner_self, owner_cls: _S) -> _T:
return self._func(owner_cls)
@@ -65,11 +68,11 @@ class Intel(interfaces.layers.TranslationLayerInterface):
return cls._bits_per_register
@classproperty
def minimum_address(cls) -> int: # type: ignore
def minimum_address(cls) -> int:
return 0
@classproperty
def maximum_address(cls) -> int: # type: ignore
def maximum_address(cls) -> int:
return (1 << cls._maxvirtaddr) - 1
@classproperty