Skip to content

Commit

Permalink
Clean up various warnings (#304)
Browse files Browse the repository at this point in the history
* Clean up various warnings

* Clean up various warnings
  • Loading branch information
anschweitzer committed May 10, 2024
1 parent df96c15 commit 2580d64
Show file tree
Hide file tree
Showing 25 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}-
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions src/gwproto/data_classes/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 1 addition & 3 deletions src/gwproto/data_classes/component_attribute_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/actor_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/local_comm_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/make_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/telemetry_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/enums/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
Expand Down
2 changes: 1 addition & 1 deletion src/gwproto/gs/gs_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
2 changes: 1 addition & 1 deletion src/gwproto/gs/gs_pwr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
2 changes: 1 addition & 1 deletion tests/types/test_data_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/types/test_electric_meter_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_gt_sh_multipurpose_telemetry_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_gt_sh_simple_telemetry_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_gt_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/types/test_multipurpose_sensor_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_pipe_flow_sensor_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_relay_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/types/test_resistive_heater_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tests/types/test_simple_temp_sensor_cac_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/types/test_spaceheat_node_gt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/types/test_telemetry_reporting_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 2580d64

Please sign in to comment.