Skip to content

Commit

Permalink
Test ruff2
Browse files Browse the repository at this point in the history
  • Loading branch information
a-kleinf committed Nov 14, 2024
1 parent 036863b commit bd7801f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ log_file_date_format = "%Y-%m-%d %H:%M:%S:%f"
[tool.ruff]
line-length = 120 # https://beta.ruff.rs/docs/settings/#line-length
target-version = "py39" # https://beta.ruff.rs/docs/settings/#target-version
# Allow imports relative to the "src" and "test" directories.
src = ["src", "test"] # https://beta.ruff.rs/docs/settings/#src
# Allow imports relative to the "src" and "tests" directories.
src = ["src", "tests"] # https://beta.ruff.rs/docs/settings/#src
# In addition to the standard set of exclusions, omit all tutorials and examples
extend-exclude = ["examples", "tools", "tutorial"] # https://beta.ruff.rs/docs/settings/#extend-exclude

Expand Down
34 changes: 18 additions & 16 deletions src/sdc11073/xml_types/xml_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from lxml import etree as etree_

from sdc11073 import xml_utils
from sdc11073.exceptions import ApiUsageError
from sdc11073.namespaces import QN_TYPE, docname_from_qname, text_to_qname

Expand All @@ -32,14 +33,15 @@
StringConverter,
TimestampConverter,
)
from sdc11073 import xml_utils

if TYPE_CHECKING:
from collections.abc import Iterable, Sequence
from decimal import Decimal

from sdc11073.mdib.containerbase import ContainerBase
from sdc11073.namespaces import NamespaceHelper
from sdc11073.xml_types.basetypes import XMLTypeBase
from sdc11073.mdib.containerbase import ContainerBase

from .dataconverters import DataConverterProtocol
from .isoduration import DurationType

Expand Down Expand Up @@ -75,7 +77,7 @@ class _XmlStructureBaseProperty(ABC):
update_xml_value: convert the Python data type to XML type and write it to XML node.
"""

def __init__(self, local_var_name: str, # noqa: PLR0913
def __init__(self, local_var_name: str,
value_converter: DataConverterProtocol,
default_py_value: Any | None = None,
implied_py_value: Any | None = None,
Expand Down Expand Up @@ -197,7 +199,7 @@ class _AttributeBase(_XmlStructureBaseProperty):
The python representation is determined by value_converter.
"""

def __init__(self, attribute_name: str, # noqa: PLR0913
def __init__(self, attribute_name: str,
value_converter: DataConverterProtocol | None = None,
default_py_value: Any = None,
implied_py_value: Any = None,
Expand Down Expand Up @@ -248,7 +250,7 @@ def __str__(self) -> str:
class _ElementBase(_XmlStructureBaseProperty, ABC):
"""_ElementBase represents an XML Element."""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
value_converter: DataConverterProtocol,
default_py_value: Any = None,
implied_py_value: Any = None,
Expand Down Expand Up @@ -337,7 +339,7 @@ class TimeZoneAttributeProperty(StringAttributeProperty):
class EnumAttributeProperty(_AttributeBase):
"""Base class for enum attributes."""

def __init__(self, attribute_name: str, # noqa: PLR0913
def __init__(self, attribute_name: str,
enum_cls: Any,
default_py_value: Any = None,
implied_py_value: Any = None,
Expand Down Expand Up @@ -656,7 +658,7 @@ class NodeStringProperty(NodeTextProperty):
if the xml element that should contain the text does not exist, the python value is None.
"""

def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None = None,
default_py_value: str | None = None,
implied_py_value: str | None = None,
is_optional: bool = False,
Expand All @@ -679,7 +681,7 @@ class NodeEnumTextProperty(NodeTextProperty):
Python representation is an enum.
"""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
enum_cls: Any,
default_py_value: Any | None = None,
implied_py_value: Any | None = None,
Expand All @@ -695,7 +697,7 @@ class NodeEnumQNameProperty(NodeTextProperty):
Python representation is an Enum of QName, XML is prefix:localname.
"""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
enum_cls: Any,
default_py_value: Any | None = None,
implied_py_value: Any | None = None,
Expand Down Expand Up @@ -748,7 +750,7 @@ def update_xml_value(self, instance: Any, node: xml_utils.LxmlElement):
class NodeIntProperty(NodeTextProperty):
"""Python representation is an int."""

def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None = None,
default_py_value: int | None = None,
implied_py_value: int | None = None,
is_optional: bool = False,
Expand All @@ -759,7 +761,7 @@ def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR091
class NodeDecimalProperty(NodeTextProperty):
"""Python representation is an int."""

def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None = None,
default_py_value: Decimal | None = None,
implied_py_value: Decimal | None = None,
is_optional: bool = False,
Expand All @@ -770,7 +772,7 @@ def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR091
class NodeDurationProperty(NodeTextProperty):
"""Python representation is an int."""

def __init__(self, sub_element_name: etree_.QName | None = None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None = None,
default_py_value: isoduration.DurationType | None = None,
implied_py_value: isoduration.DurationType | None = None,
is_optional: bool = False,
Expand Down Expand Up @@ -955,7 +957,7 @@ def update_xml_value(self, instance: Any, node: xml_utils.LxmlElement):
class SubElementProperty(_ElementBase):
"""Uses a value that has an "as_etree_node" method."""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
value_class: type[XMLTypeBase],
default_py_value: Any | None = None,
implied_py_value: Any | None = None,
Expand Down Expand Up @@ -998,7 +1000,7 @@ def update_xml_value(self, instance: Any, node: xml_utils.LxmlElement):
class ContainerProperty(_ElementBase):
"""ContainerProperty supports xsi:type information from xml and instantiates value accordingly."""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
value_class: type[ContainerBase],
cls_getter: Callable[[etree_.QName], type],
ns_helper: NamespaceHelper,
Expand Down Expand Up @@ -1115,7 +1117,7 @@ def update_xml_value(self, instance: Any, node: xml_utils.LxmlElement):
py_value = getattr(instance, self._local_var_name)
except AttributeError: # set to None (it is in the responsibility of the called method to do the right thing)
py_value = self._default_py_value

a = 1

Check failure on line 1120 in src/sdc11073/xml_types/xml_structure.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F841)

src/sdc11073/xml_types/xml_structure.py:1120:9: F841 Local variable `a` is assigned to but never used
if py_value is not None:
for val in py_value:
sub_node = val.as_etree_node(self._sub_element_name, node.nsmap, node)
Expand All @@ -1134,7 +1136,7 @@ class ContainerListProperty(_ElementListProperty):
Used if maxOccurs="Unbounded" in BICEPS_ParticipantModel.
"""

def __init__(self, sub_element_name: etree_.QName | None, # noqa: PLR0913
def __init__(self, sub_element_name: etree_.QName | None,
value_class: type[ContainerBase],
cls_getter: Callable[[etree_.QName], type],
ns_helper: NamespaceHelper,
Expand Down

0 comments on commit bd7801f

Please sign in to comment.