Skip to content

Commit

Permalink
lestarch: fixing static analysis errors
Browse files Browse the repository at this point in the history
  • Loading branch information
LeStarch committed May 9, 2022
1 parent cdb6818 commit b3efca4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/fprime/common/models/serialize/array_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@
Created on May 29, 2020
@author: jishii
"""
import copy

from .type_base import DictionaryType
from .type_exceptions import (
ArrayLengthException,
NotInitializedException,
TypeMismatchException,
)

from . import serializable_type
Expand Down
2 changes: 1 addition & 1 deletion src/fprime/common/models/serialize/bool_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def serialize(self):
"""Serialize a boolean value"""
if self.val is None:
raise NotInitializedException(type(self))
return struct.pack("B", self.TRUE if self.val else self.FALSE)
return struct.pack("B", self.TRUE if self._val else self.FALSE)

def deserialize(self, data, offset):
"""Deserialize boolean value"""
Expand Down
9 changes: 3 additions & 6 deletions src/fprime/common/models/serialize/numerical_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@author mstarch
"""
import abc
import re
import struct

from .type_base import ValueType
Expand All @@ -18,8 +17,6 @@
TypeRangeException,
)

# BITS_RE = re.compile(r"[IUF](\d\d?)")


class NumericalType(ValueType, abc.ABC):
"""Numerical types that can be serialized using struct and are of some power of 2 byte width"""
Expand All @@ -42,14 +39,14 @@ def get_serialize_format():

def serialize(self):
"""Serializes this type using struct and the val property"""
if self.val is None:
if self._val is None:
raise NotInitializedException(type(self))
return struct.pack(self.get_serialize_format(), self.val)
return struct.pack(self.get_serialize_format(), self._val)

def deserialize(self, data, offset):
"""Serializes this type using struct and the val property"""
try:
self.val = struct.unpack_from(self.get_serialize_format(), data, offset)[0]
self._val = struct.unpack_from(self.get_serialize_format(), data, offset)[0]
except struct.error as err:
raise DeserializeException(str(err))

Expand Down
2 changes: 0 additions & 2 deletions src/fprime/common/models/serialize/serializable_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
@author: tcanham
"""
import copy

from .type_base import BaseType, DictionaryType
from .type_exceptions import (
MissingMemberException,
Expand Down

0 comments on commit b3efca4

Please sign in to comment.