From b22d8d06e96cd5ca532ddd5fb1fc500eb39c50f7 Mon Sep 17 00:00:00 2001 From: MauriceHendrix Date: Wed, 23 Jul 2025 13:33:57 +0200 Subject: [PATCH] fix linting errors --- src/s2python/common/power_forecast_element.py | 2 +- src/s2python/common/power_measurement.py | 4 ++-- src/s2python/pebc/pebc_allowed_limit_range.py | 5 ++--- src/s2python/pebc/pebc_power_constraints.py | 8 ++++---- tests/unit/common/power_forecast_element_test.py | 4 +--- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/s2python/common/power_forecast_element.py b/src/s2python/common/power_forecast_element.py index 38fab23..da37a2f 100644 --- a/src/s2python/common/power_forecast_element.py +++ b/src/s2python/common/power_forecast_element.py @@ -35,7 +35,7 @@ def validate_values_at_most_one_per_commodity_quantity(self) -> Self: if has_value.get(value.commodity_quantity, False): raise ValueError( self, - f"There must be at most 1 PowerForecastValue per CommodityQuantity", + "There must be at most 1 PowerForecastValue per CommodityQuantity", ) has_value[value.commodity_quantity] = True diff --git a/src/s2python/common/power_measurement.py b/src/s2python/common/power_measurement.py index 669ac08..691fccc 100644 --- a/src/s2python/common/power_measurement.py +++ b/src/s2python/common/power_measurement.py @@ -1,6 +1,6 @@ +import uuid from typing import List from typing_extensions import Self -import uuid from pydantic import model_validator from s2python.common.power_value import PowerValue @@ -32,7 +32,7 @@ def validate_values_at_most_one_per_commodity_quantity(self) -> Self: if has_value.get(value.commodity_quantity, False): raise ValueError( self, - f"The measured PowerValues must contain at most one item per CommodityQuantity.", + "The measured PowerValues must contain at most one item per CommodityQuantity.", ) has_value[value.commodity_quantity] = True diff --git a/src/s2python/pebc/pebc_allowed_limit_range.py b/src/s2python/pebc/pebc_allowed_limit_range.py index 81e82b6..7377c2b 100644 --- a/src/s2python/pebc/pebc_allowed_limit_range.py +++ b/src/s2python/pebc/pebc_allowed_limit_range.py @@ -29,15 +29,14 @@ class PEBCAllowedLimitRange(GenPEBCAllowedLimitRange, S2MessageComponent): @model_validator(mode="after") def validate_range_boundary(self) -> Self: - # According to the specification "There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT + # According to the specification "There must be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT # and at least one AllowedLimitRange for the LOWER_LIMIT." However for something that produces energy # end_of_range=-2000 and start_of_range=0 is valid. Therefore absolute value used here. - # TODO: Check that this is the correct interpretation of the wording if abs(self.range_boundary.start_of_range) > abs( self.range_boundary.end_of_range ): raise ValueError( self, - f"The start of the range must shall be smaller or equal than the end of the range.", + "The start of the range must be smaller or equal than the end of the range.", ) return self diff --git a/src/s2python/pebc/pebc_power_constraints.py b/src/s2python/pebc/pebc_power_constraints.py index 71ab1bc..64035e0 100644 --- a/src/s2python/pebc/pebc_power_constraints.py +++ b/src/s2python/pebc/pebc_power_constraints.py @@ -4,7 +4,7 @@ from pydantic import model_validator -from s2python.common import CommodityQuantity, NumberRange +from s2python.common import CommodityQuantity from s2python.generated.gen_s2 import ( PEBCPowerConstraints as GenPEBCPowerConstraints, PEBCPowerEnvelopeConsequenceType as GenPEBCPowerEnvelopeConsequenceType, @@ -60,10 +60,10 @@ def validate_has_one_upper_one_lower_limit_range(self) -> Self: for upper, lower in commodity_type_ranges.values(): valid = valid and upper and lower - if not (valid): + if not valid: raise ValueError( self, - f"There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.", + "There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.", ) return self @@ -72,6 +72,6 @@ def validate_has_one_upper_one_lower_limit_range(self) -> Self: def validate_valid_until_after_valid_from(self) -> Self: if self.valid_until is not None and self.valid_until < self.valid_from: raise ValueError( - self, f"valid_until cannot be set to a value that is before valid_from." + self, "valid_until cannot be set to a value that is before valid_from." ) return self diff --git a/tests/unit/common/power_forecast_element_test.py b/tests/unit/common/power_forecast_element_test.py index ec2505d..9db7801 100644 --- a/tests/unit/common/power_forecast_element_test.py +++ b/tests/unit/common/power_forecast_element_test.py @@ -1,8 +1,6 @@ -import datetime import json from datetime import timedelta from unittest import TestCase -import uuid from s2python.s2_validation_error import S2ValidationError @@ -81,4 +79,4 @@ def test__init__multiple_power_forecast_values_for_commodity_quantity(self): ) ], duration=Duration.from_timedelta(timedelta(seconds=4)), - ) \ No newline at end of file + )