Skip to content

Commit

Permalink
Remove unused self.open
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudd2 committed Jun 28, 2023
1 parent 6f82f2c commit 9831b54
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions productivity/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def __init__(self, address, timeout=1):
self.client = ReconnectingAsyncioModbusTcpClient()
self.lock = asyncio.Lock()
self.connectTask = asyncio.create_task(self._connect())
self.open = False

async def __aenter__(self):
"""Asynchronously connect with the context manager."""
Expand All @@ -68,6 +67,7 @@ async def __aexit__(self, *args):
await self._close()

def _detect_pymodbus_version(self) -> None:
"""Detect various pymodbus versions."""
self.pymodbus30plus = int(pymodbus.__version__[0]) == 3
self.pymodbus32plus = self.pymodbus30plus and int(pymodbus.__version__[2]) >= 2
self.pymodbus33plus = self.pymodbus30plus and int(pymodbus.__version__[2]) >= 3
Expand All @@ -80,7 +80,6 @@ async def _connect(self):
await asyncio.wait_for(self.client.connect(), timeout=self.timeout) # 3.x
else: # 2.4.x - 2.5.x
await self.client.start(self.ip) # type: ignore
self.open = True
except Exception:
raise OSError(f"Could not connect to '{self.ip}'.")

Expand Down Expand Up @@ -175,4 +174,3 @@ async def _close(self) -> None:
await self.client.close() # type: ignore # 3.0.x - 3.2.x
else: # 2.4.x - 2.5.x
self.client.stop() # type: ignore
self.open = False

0 comments on commit 9831b54

Please sign in to comment.