diff --git a/volatility/framework/__init__.py b/volatility/framework/__init__.py index 83fd54cd7..bebd2ca29 100644 --- a/volatility/framework/__init__.py +++ b/volatility/framework/__init__.py @@ -3,6 +3,7 @@ import inspect import logging import os import sys +import typing from volatility.framework import interfaces @@ -20,8 +21,6 @@ from volatility.framework import interfaces # 4. If changes or removals of the interface have been made, set age to 0 # We use the libtool library versioning -import typing - CURRENT = 0 # Number of releases of the library with any change REVISION = 0 # Number of changes that don't affect the interface AGE = 0 # Number of consecutive versions of the interface the current version supports @@ -68,7 +67,10 @@ def hide_from_subclasses(cls: typing.Type) -> typing.Type: return cls -def class_subclasses(cls: typing.Type) -> typing.Iterable[typing.Type]: +T = typing.TypeVar('T', typing.Type, typing.Type) + + +def class_subclasses(cls: T) -> typing.Generator[T, None, None]: """Returns all the (recursive) subclasses of a given class""" if not inspect.isclass(cls): raise TypeError("class_subclasses parameter not a valid class: {}".format(cls)) diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index a186da73a..ef1a482db 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -48,7 +48,7 @@ class PrimitiveObject(interfaces.objects.ObjectInterface): type_name: str, object_info: interfaces.objects.ObjectInformation, struct_format: str, - new_value = None, + new_value: typing.Union[int, float, bool, bytes, str] = None, **kwargs) -> 'PrimitiveObject': """Creates the appropriate class and returns it so that the native type is inherited @@ -66,7 +66,8 @@ class PrimitiveObject(interfaces.objects.ObjectInterface): value = new_value result = cls._struct_type.__new__(cls, value) # This prevents us having to go read a context layer when recreating after unpickling - result.__new_value = value + # Mypy complains that result doesn't have a __new_value, but using setattr causes pycharm to complain further down + result.__new_value = value # type: ignore return result def __getnewargs_ex__(self):