Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions space_packet_parser/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Common mixins"""

from __future__ import annotations

import inspect
import logging
import warnings
Expand Down Expand Up @@ -154,7 +156,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None,
parameter_type_lookup: dict[str, any] | None,
container_lookup: dict[str, any] | None,
) -> "XmlObject":
) -> XmlObject:
"""Create an object from an XML element

Notes
Expand Down Expand Up @@ -202,7 +204,7 @@ def to_xml(self, *, elmaker: ElementMaker) -> ElementTree.Element:
class Parseable(Protocol):
"""Defines an object that can be parsed from packet data."""

def parse(self, packet: "SpacePacket") -> None:
def parse(self, packet: SpacePacket) -> None:
"""Parse this entry from the packet data and add the necessary items to the packet."""


Expand Down
12 changes: 7 additions & 5 deletions space_packet_parser/xtce/calibrators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Calibrator definitions"""

from __future__ import annotations

from abc import ABCMeta, abstractmethod
from collections import namedtuple

Expand All @@ -23,7 +25,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "Calibrator":
) -> Calibrator:
"""Abstract classmethod to create a default_calibrator object from an XML element.

Parameters
Expand Down Expand Up @@ -100,7 +102,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "SplineCalibrator":
) -> SplineCalibrator:
"""Create a spline default_calibrator object from an <xtce:SplineCalibrator> XML element.

Parameters
Expand Down Expand Up @@ -270,7 +272,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "PolynomialCalibrator":
) -> PolynomialCalibrator:
"""Create a polynomial default_calibrator object from an <xtce:PolynomialCalibrator> XML element.

Parameters
Expand Down Expand Up @@ -352,7 +354,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "MathOperationCalibrator":
) -> MathOperationCalibrator:
"""Create a math operation default_calibrator from an <xtce:MathOperationCalibrator> XML element.

Parameters
Expand Down Expand Up @@ -456,7 +458,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "ContextCalibrator":
) -> ContextCalibrator:
"""Create a ContextCalibrator object from an <xtce:ContextCalibrator> XML element

Parameters
Expand Down
10 changes: 6 additions & 4 deletions space_packet_parser/xtce/comparisons.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Matching logical objects"""

from __future__ import annotations

from abc import ABCMeta, abstractmethod
from collections import namedtuple
from typing import Any
Expand Down Expand Up @@ -111,7 +113,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "Comparison":
) -> Comparison:
"""Create

Parameters
Expand Down Expand Up @@ -301,7 +303,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "Condition":
) -> Condition:
"""Classmethod to create a Condition object from an XML element.

Parameters
Expand Down Expand Up @@ -448,7 +450,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "BooleanExpression":
) -> BooleanExpression:
"""Abstract classmethod to create a match criteria object from an XML element.

Parameters
Expand Down Expand Up @@ -615,7 +617,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "DiscreteLookup":
) -> DiscreteLookup:
"""Create a DiscreteLookup object from an <xtce:DiscreteLookup> XML element

Parameters
Expand Down
10 changes: 6 additions & 4 deletions space_packet_parser/xtce/encodings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""DataEncoding definitions"""

from __future__ import annotations

import logging
import struct
import warnings
Expand Down Expand Up @@ -378,7 +380,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "StringDataEncoding":
) -> StringDataEncoding:
"""Create a data encoding object from an <xtce:StringDataEncoding> XML element.

Notes
Expand Down Expand Up @@ -724,7 +726,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "IntegerDataEncoding":
) -> IntegerDataEncoding:
"""Create a data encoding object from an <xtce:IntegerDataEncoding> XML element.

Parameters
Expand Down Expand Up @@ -891,7 +893,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "FloatDataEncoding":
) -> FloatDataEncoding:
"""Create a data encoding object from an <xtce:FloatDataEncoding> XML element.

Parameters
Expand Down Expand Up @@ -1029,7 +1031,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "BinaryDataEncoding":
) -> BinaryDataEncoding:
"""Create a data encoding object from an <xtce:BinaryDataEncoding> XML element.

Parameters
Expand Down
6 changes: 4 additions & 2 deletions space_packet_parser/xtce/parameter_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Parameter type objects"""

from __future__ import annotations

import warnings
from abc import ABCMeta

Expand Down Expand Up @@ -48,7 +50,7 @@ def from_xml(
parameter_lookup: dict | None = None,
parameter_type_lookup: dict | None = None,
container_lookup: dict[str, any] | None = None,
) -> "ParameterType":
) -> ParameterType:
"""Create a *ParameterType* from an <xtce:ParameterType> XML element.

Parameters
Expand Down Expand Up @@ -241,7 +243,7 @@ def from_xml(
parameter_lookup: dict[str, any] | None = None,
parameter_type_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "EnumeratedParameterType":
) -> EnumeratedParameterType:
"""Create an EnumeratedParameterType from an <xtce:EnumeratedParameterType> XML element.
Overrides ParameterType.from_parameter_type_xml_element

Expand Down
4 changes: 3 additions & 1 deletion space_packet_parser/xtce/parameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""ParameterType definitions"""

from __future__ import annotations

from dataclasses import dataclass

import lxml.etree as ElementTree
Expand Down Expand Up @@ -47,7 +49,7 @@ def from_xml(
tree: ElementTree.ElementTree | None = None,
parameter_lookup: dict[str, any] | None = None,
container_lookup: dict[str, any] | None = None,
) -> "Parameter":
) -> Parameter:
"""Create a Parameter object from an XML element.

Parameters
Expand Down
8 changes: 7 additions & 1 deletion space_packet_parser/xtce/validation.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""XTCE document validation classes and utilities."""

from __future__ import annotations

import hashlib
import logging
import os
Expand Down Expand Up @@ -534,7 +536,11 @@ def validate_xtce(

# Parse XML document into a tree object
try:
if isinstance(xml_source, ElementTree.ElementTree):
# In lxml >= 5.2.1 (Cython 3.0), ElementTree.ElementTree is a Cython function
# rather than a class, which makes isinstance() fail with a TypeError.
# ElementTree._ElementTree is the actual underlying class and is available in all
# supported lxml versions.
if isinstance(xml_source, ElementTree._ElementTree):
xml_tree = xml_source
elif isinstance(xml_source, Path):
xml_tree = ElementTree.parse(str(xml_source))
Expand Down
Loading