Fix more typing issues.

This commit is contained in:
Mike Auty
2018-04-12 14:09:11 +01:00
parent c758c249d0
commit 66af2f16de
2 changed files with 8 additions and 5 deletions
+5 -3
View File
@@ -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))
+3 -2
View File
@@ -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):