Skip to content

Commit

Permalink
Pylint: fix {load,store}_state warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenbe committed May 24, 2024
1 parent 8ba3145 commit cae7a0e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions comfospot40/hal.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ async def send_state(self, state: State, timer):
self._writer.write(bytes(packet))
await sleep(0.1)

def storeState(self, storefile, state):
def store_state(self, storefile, state):
json.dump(state.to_json(), storefile, indent=2)

def loadState(self, storefile, state):
def load_state(self, storefile, state):
try:
loadedjson = json.load(storefile)
except json.decoder.JSONDecodeError as e:
Expand Down
4 changes: 2 additions & 2 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def main(
hal = comfospot40.Hal(state, oscillation_time)
if storestate and path.isfile(storestate):
with open(storestate, "r") as storefile:
hal.loadState(storefile, state)
hal.load_state(storefile, state)
mqtt = comfospot40.Mqtt(client, state, mqttprefix)
x = None
if dev:
Expand All @@ -58,7 +58,7 @@ async def main(
await hal.send_state(state, new_print)
if storestate:
with open(storestate, "w") as storefile:
hal.storeState(storefile, state)
hal.store_state(storefile, state)
if x and x.done():
state = x.result()
x = asyncio.create_task(parser.run())
Expand Down
6 changes: 3 additions & 3 deletions tests/state_store_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_empty_file(self):
with open(
Path(__file__).parent / "state_store_test/empty.json", "r"
) as storefile:
hal.loadState(storefile, state)
hal.load_state(storefile, state)
self.assertEqual(state, state_default)

def test_broken_file(self):
Expand All @@ -22,13 +22,13 @@ def test_broken_file(self):
with open(
Path(__file__).parent / "state_store_test/broken.json", "r"
) as storefile:
hal.loadState(storefile, state)
hal.load_state(storefile, state)
self.assertEqual(state, state_default)

def test_v2_file(self):
state = comfospot40.State(60, False)
state_default = comfospot40.State(60, False)
hal = comfospot40.Hal(state, 60)
with open(Path(__file__).parent / "state_store_test/v2.json", "r") as storefile:
hal.loadState(storefile, state)
hal.load_state(storefile, state)
self.assertEqual(state, state_default)

0 comments on commit cae7a0e

Please sign in to comment.