mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-12 20:57:39 +02:00
Fix more typing issues.
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user