From 2580d6415d6b0d719ef0fa919c5de49b524ac11b Mon Sep 17 00:00:00 2001 From: Andrew Schweitzer Date: Fri, 10 May 2024 18:02:23 -0400 Subject: [PATCH] Clean up various warnings (#304) * Clean up various warnings * Clean up various warnings --- .github/labels.yml | 2 +- .github/workflows/tests.yml | 4 ++-- docs/conf.py | 2 +- src/gwproto/data_classes/component.py | 11 ++++++----- src/gwproto/data_classes/component_attribute_class.py | 4 +--- src/gwproto/enums/actor_class.py | 2 +- src/gwproto/enums/local_comm_interface.py | 2 +- src/gwproto/enums/make_model.py | 2 +- src/gwproto/enums/role.py | 2 +- src/gwproto/enums/telemetry_name.py | 2 +- src/gwproto/enums/unit.py | 2 +- src/gwproto/gs/gs_dispatch.py | 2 +- src/gwproto/gs/gs_pwr.py | 2 +- tests/types/test_data_channel.py | 2 +- tests/types/test_electric_meter_cac_gt.py | 4 ++-- .../types/test_gt_sh_multipurpose_telemetry_status.py | 2 +- tests/types/test_gt_sh_simple_telemetry_status.py | 2 +- tests/types/test_gt_telemetry.py | 2 +- tests/types/test_multipurpose_sensor_cac_gt.py | 4 ++-- tests/types/test_pipe_flow_sensor_cac_gt.py | 2 +- tests/types/test_relay_cac_gt.py | 2 +- tests/types/test_resistive_heater_cac_gt.py | 2 +- tests/types/test_simple_temp_sensor_cac_gt.py | 6 +++--- tests/types/test_spaceheat_node_gt.py | 4 ++-- tests/types/test_telemetry_reporting_config.py | 4 ++-- 25 files changed, 37 insertions(+), 38 deletions(-) diff --git a/.github/labels.yml b/.github/labels.yml index f7f83aad..21a15056 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -36,7 +36,7 @@ color: 7057ff - name: help wanted description: Extra attention is needed - color: 008672 + color: "008672" - name: invalid description: This doesn't seem right color: e4e669 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c2a1c0ea..9c30747e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,7 +6,7 @@ on: jobs: tests: - name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }} + name: "${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }}" runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -93,7 +93,7 @@ jobs: if: matrix.session == 'pre-commit' with: path: ~/.cache/pre-commit - key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} + key: "${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}" restore-keys: | ${{ steps.pre-commit-cache.outputs.result }}- diff --git a/docs/conf.py b/docs/conf.py index 5b435778..6a107202 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,7 @@ project = "Gridworks Protocol" author = "Jessica Millar" -copyright = "2022, Jessica Millar" +copyright = "2022, Jessica Millar" # noqa extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon", diff --git a/src/gwproto/data_classes/component.py b/src/gwproto/data_classes/component.py index 13e3d73c..39c19bbe 100644 --- a/src/gwproto/data_classes/component.py +++ b/src/gwproto/data_classes/component.py @@ -10,11 +10,12 @@ class Component(ABC, StreamlinedSerializerMixin): by_id: Dict[str, "Component"] = {} - base_props = [] - base_props.append("component_id") - base_props.append("display_name") - base_props.append("component_attribute_class_id") - base_props.append("hw_uid") + base_props = [ + "component_id", + "display_name", + "component_attribute_class_id", + "hw_uid", + ] def __new__(cls, component_id, *args, **kwargs): try: diff --git a/src/gwproto/data_classes/component_attribute_class.py b/src/gwproto/data_classes/component_attribute_class.py index 538a41a6..5b55516a 100644 --- a/src/gwproto/data_classes/component_attribute_class.py +++ b/src/gwproto/data_classes/component_attribute_class.py @@ -10,9 +10,7 @@ class ComponentAttributeClass(ABC, StreamlinedSerializerMixin): by_id: Dict[str, "ComponentAttributeClass"] = {} - base_props = [] - base_props.append("component_attribute_class_id") - base_props.append("display_name") + base_props = ["component_attribute_class_id", "display_name"] def __new__(cls, component_attribute_class_id, *args, **kwargs): try: diff --git a/src/gwproto/enums/actor_class.py b/src/gwproto/enums/actor_class.py index eaefb32a..2616590f 100644 --- a/src/gwproto/enums/actor_class.py +++ b/src/gwproto/enums/actor_class.py @@ -148,7 +148,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a ActorClass enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/enums/local_comm_interface.py b/src/gwproto/enums/local_comm_interface.py index 32175df4..9c30af48 100644 --- a/src/gwproto/enums/local_comm_interface.py +++ b/src/gwproto/enums/local_comm_interface.py @@ -111,7 +111,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a LocalCommInterface enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/enums/make_model.py b/src/gwproto/enums/make_model.py index 1fb07531..fe0d7748 100644 --- a/src/gwproto/enums/make_model.py +++ b/src/gwproto/enums/make_model.py @@ -156,7 +156,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a MakeModel enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/enums/role.py b/src/gwproto/enums/role.py index 4f52cc6f..15b73752 100644 --- a/src/gwproto/enums/role.py +++ b/src/gwproto/enums/role.py @@ -144,7 +144,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a Role enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/enums/telemetry_name.py b/src/gwproto/enums/telemetry_name.py index 52713c2f..d446ea96 100644 --- a/src/gwproto/enums/telemetry_name.py +++ b/src/gwproto/enums/telemetry_name.py @@ -133,7 +133,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a TelemetryName enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/enums/unit.py b/src/gwproto/enums/unit.py index b13c55af..4a8251d2 100644 --- a/src/gwproto/enums/unit.py +++ b/src/gwproto/enums/unit.py @@ -115,7 +115,7 @@ def value_to_symbol(cls, value: str) -> str: Provides the encoding symbol for a Unit enum to send in seriliazed messages. Args: - symbol (str): The candidate value. + value (str): The candidate value. Returns: str: The symbol encoding that value. If the value is not recognized - diff --git a/src/gwproto/gs/gs_dispatch.py b/src/gwproto/gs/gs_dispatch.py index 146adcf0..253a5fb4 100644 --- a/src/gwproto/gs/gs_dispatch.py +++ b/src/gwproto/gs/gs_dispatch.py @@ -9,5 +9,5 @@ def check_for_errors(self): if len(errors) > 0: raise SchemaError(f" Errors making making gs.pwr.100 for {self}: {errors}") - def hand_coded_errors(self): + def hand_coded_errors(self): # noqa return [] diff --git a/src/gwproto/gs/gs_pwr.py b/src/gwproto/gs/gs_pwr.py index 0a8cd306..36a8d17b 100644 --- a/src/gwproto/gs/gs_pwr.py +++ b/src/gwproto/gs/gs_pwr.py @@ -9,5 +9,5 @@ def check_for_errors(self): if len(errors) > 0: raise SchemaError(f" Errors making making gs.pwr.100 for {self}: {errors}") - def hand_coded_errors(self): + def hand_coded_errors(self): # noqa return [] diff --git a/tests/types/test_data_channel.py b/tests/types/test_data_channel.py index ea7050b0..867de68d 100644 --- a/tests/types/test_data_channel.py +++ b/tests/types/test_data_channel.py @@ -76,7 +76,7 @@ def test_data_channel_generated() -> None: ###################################### d2 = dict(d, TelemetryNameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() + assert Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() ###################################### # SchemaError raised if TypeName is incorrect diff --git a/tests/types/test_electric_meter_cac_gt.py b/tests/types/test_electric_meter_cac_gt.py index 3ce171ae..2ff9ab97 100644 --- a/tests/types/test_electric_meter_cac_gt.py +++ b/tests/types/test_electric_meter_cac_gt.py @@ -110,14 +110,14 @@ def test_electric_meter_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() d2 = dict(d, PollPeriodMs="1000.1") with pytest.raises(ValidationError): Maker.dict_to_tuple(d2) d2 = dict(d, InterfaceGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).Interface == LocalCommInterface.default() + assert Maker.dict_to_tuple(d2).Interface == LocalCommInterface.default() d2 = dict(d, DefaultBaud="9600.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_gt_sh_multipurpose_telemetry_status.py b/tests/types/test_gt_sh_multipurpose_telemetry_status.py index a0e6dbf9..1645b626 100644 --- a/tests/types/test_gt_sh_multipurpose_telemetry_status.py +++ b/tests/types/test_gt_sh_multipurpose_telemetry_status.py @@ -83,7 +83,7 @@ def test_gt_sh_multipurpose_telemetry_status_generated() -> None: ###################################### d2 = dict(d, TelemetryNameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() + assert Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() ###################################### # SchemaError raised if TypeName is incorrect diff --git a/tests/types/test_gt_sh_simple_telemetry_status.py b/tests/types/test_gt_sh_simple_telemetry_status.py index 408ee830..3d802472 100644 --- a/tests/types/test_gt_sh_simple_telemetry_status.py +++ b/tests/types/test_gt_sh_simple_telemetry_status.py @@ -76,7 +76,7 @@ def test_gt_sh_simple_telemetry_status_generated() -> None: ###################################### d2 = dict(d, TelemetryNameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() + assert Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() ###################################### # SchemaError raised if TypeName is incorrect diff --git a/tests/types/test_gt_telemetry.py b/tests/types/test_gt_telemetry.py index 1825da5e..729793f1 100644 --- a/tests/types/test_gt_telemetry.py +++ b/tests/types/test_gt_telemetry.py @@ -84,7 +84,7 @@ def test_gt_telemetry_generated() -> None: Maker.dict_to_tuple(d2) d2 = dict(d, NameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).Name == TelemetryName.default() + assert Maker.dict_to_tuple(d2).Name == TelemetryName.default() d2 = dict(d, Exponent="3.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_multipurpose_sensor_cac_gt.py b/tests/types/test_multipurpose_sensor_cac_gt.py index b2d78616..08a61023 100644 --- a/tests/types/test_multipurpose_sensor_cac_gt.py +++ b/tests/types/test_multipurpose_sensor_cac_gt.py @@ -124,7 +124,7 @@ def test_multipurpose_sensor_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() d2 = dict(d, PollPeriodMs="880.1") with pytest.raises(ValidationError): @@ -135,7 +135,7 @@ def test_multipurpose_sensor_cac_gt_generated() -> None: Maker.dict_to_tuple(d2) d2 = dict(d, TempUnitGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TempUnit == Unit.default() + assert Maker.dict_to_tuple(d2).TempUnit == Unit.default() d2 = dict(d, MaxThermistors="12.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_pipe_flow_sensor_cac_gt.py b/tests/types/test_pipe_flow_sensor_cac_gt.py index d1740367..0049e76c 100644 --- a/tests/types/test_pipe_flow_sensor_cac_gt.py +++ b/tests/types/test_pipe_flow_sensor_cac_gt.py @@ -88,7 +88,7 @@ def test_pipe_flow_sensor_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() ###################################### # SchemaError raised if TypeName is incorrect diff --git a/tests/types/test_relay_cac_gt.py b/tests/types/test_relay_cac_gt.py index ec126c59..5ca52fe8 100644 --- a/tests/types/test_relay_cac_gt.py +++ b/tests/types/test_relay_cac_gt.py @@ -88,7 +88,7 @@ def test_relay_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() d2 = dict(d, TypicalResponseTimeMs="400.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_resistive_heater_cac_gt.py b/tests/types/test_resistive_heater_cac_gt.py index 82e6356b..655472fa 100644 --- a/tests/types/test_resistive_heater_cac_gt.py +++ b/tests/types/test_resistive_heater_cac_gt.py @@ -95,7 +95,7 @@ def test_resistive_heater_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() d2 = dict(d, NameplateMaxPowerW="4500.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_simple_temp_sensor_cac_gt.py b/tests/types/test_simple_temp_sensor_cac_gt.py index 0a13dbf0..6a47a36d 100644 --- a/tests/types/test_simple_temp_sensor_cac_gt.py +++ b/tests/types/test_simple_temp_sensor_cac_gt.py @@ -118,7 +118,7 @@ def test_simple_temp_sensor_cac_gt_generated() -> None: ###################################### d2 = dict(d, MakeModelGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() + assert Maker.dict_to_tuple(d2).MakeModel == MakeModel.default() d2 = dict(d, TypicalResponseTimeMs="880.1") with pytest.raises(ValidationError): @@ -129,10 +129,10 @@ def test_simple_temp_sensor_cac_gt_generated() -> None: Maker.dict_to_tuple(d2) d2 = dict(d, TempUnitGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TempUnit == Unit.default() + assert Maker.dict_to_tuple(d2).TempUnit == Unit.default() d2 = dict(d, TelemetryNameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() + assert Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() ###################################### # SchemaError raised if TypeName is incorrect diff --git a/tests/types/test_spaceheat_node_gt.py b/tests/types/test_spaceheat_node_gt.py index 68a04e5d..8e657c32 100644 --- a/tests/types/test_spaceheat_node_gt.py +++ b/tests/types/test_spaceheat_node_gt.py @@ -131,10 +131,10 @@ def test_spaceheat_node_gt_generated() -> None: ###################################### d2 = dict(d, ActorClassGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).ActorClass == ActorClass.default() + assert Maker.dict_to_tuple(d2).ActorClass == ActorClass.default() d2 = dict(d, RoleGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).Role == Role.default() + assert Maker.dict_to_tuple(d2).Role == Role.default() d2 = dict(d, ReportingSamplePeriodS="300.1") with pytest.raises(ValidationError): diff --git a/tests/types/test_telemetry_reporting_config.py b/tests/types/test_telemetry_reporting_config.py index 219659c6..3faa6bbf 100644 --- a/tests/types/test_telemetry_reporting_config.py +++ b/tests/types/test_telemetry_reporting_config.py @@ -112,7 +112,7 @@ def test_telemetry_reporting_config_generated() -> None: ###################################### d2 = dict(d, TelemetryNameGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() + assert Maker.dict_to_tuple(d2).TelemetryName == TelemetryName.default() d2 = dict(d, ReportOnChange="this is not a boolean") with pytest.raises(ValidationError): @@ -127,7 +127,7 @@ def test_telemetry_reporting_config_generated() -> None: Maker.dict_to_tuple(d2) d2 = dict(d, UnitGtEnumSymbol="unknown_symbol") - Maker.dict_to_tuple(d2).Unit == Unit.default() + assert Maker.dict_to_tuple(d2).Unit == Unit.default() d2 = dict(d, AsyncReportThreshold="this is not a float") with pytest.raises(ValidationError):