-
Notifications
You must be signed in to change notification settings - Fork 18
Lewis handler, adapter for OPCUA server emulator #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
at lewis/examples/modbus_device. | ||
""" | ||
|
||
import asyncio |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the issue, we will remove the unused asyncio
import from line 35. This will clean up the code and eliminate the unnecessary dependency. No other changes are required since the module is not used in the visible snippet.
@@ -34,3 +34,2 @@ | ||
|
||
import asyncio | ||
import inspect |
import inspect | ||
import threading | ||
import time | ||
from typing import Any, Dict, Optional, List |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
The best way to fix this issue is to remove the unused List
import from the typing
module. This involves editing the import statement on line 39 to exclude List
while retaining the other types (Any
, Dict
, and Optional
) that may still be in use. This change will not affect the functionality of the code.
-
Copy modified line R39
@@ -38,3 +38,3 @@ | ||
import time | ||
from typing import Any, Dict, Optional, List | ||
from typing import Any, Dict, Optional | ||
from asyncua import Server, Node, ua |
import time | ||
from typing import Any, Dict, Optional, List | ||
from asyncua import Server, Node, ua | ||
from asyncua.common.methods import uamethod |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
The best way to fix this issue is to remove the unused import statement from asyncua.common.methods import uamethod
. This will clean up the code and eliminate the unnecessary dependency. No other changes are required since the removal of this import does not affect the functionality of the code.
-
Copy modified line R41
@@ -40,3 +40,3 @@ | ||
from asyncua import Server, Node, ua | ||
from asyncua.common.methods import uamethod | ||
|
||
|
from asyncua.common.methods import uamethod | ||
|
||
from lewis.core.adapters import Adapter | ||
from lewis.core.devices import InterfaceBase |
Check notice
Code scanning / CodeQL
Unused import Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To fix the issue, the unused import of InterfaceBase
should be removed from the file. This will clean up the code and eliminate the unnecessary dependency. No other changes are required, as the removal of this import does not affect the functionality of the code.
@@ -43,3 +43,2 @@ | ||
from lewis.core.adapters import Adapter | ||
from lewis.core.devices import InterfaceBase | ||
from lewis.core.logging import has_log |
|
||
return self._running | ||
|
||
def handle(self, cycle_delay: float = 0.1) -> None: |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To address the issue, we need to either:
- Remove the
handle
method if it is genuinely unused and serves no purpose in the broader application. - Rename the method to indicate that it is intentionally unused (e.g.,
_unused_handle
) if it is kept for documentation or future use.
Since the method includes logic and a docstring, it is likely intended for use. If it is not currently used but might be in the future, renaming it to _unused_handle
is the best approach to clarify its status while preserving its implementation.
-
Copy modified line R331
@@ -330,3 +330,3 @@ | ||
|
||
def handle(self, cycle_delay: float = 0.1) -> None: | ||
def _unused_handle(self, cycle_delay: float = 0.1) -> None: | ||
""" |
if self._running and self.interface: | ||
time.sleep(min(cycle_delay, self._options.update_interval)) | ||
|
||
def _update_variables(self) -> None: |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 months ago
To address the issue, we will rename the _update_variables
method to _unused_update_variables
to indicate that it is intentionally unused. This approach preserves the method for potential future use while making it clear to readers and static analysis tools that it is not currently invoked. No functionality will be altered, and the fix will only involve renaming the method.
-
Copy modified line R345
@@ -344,3 +344,3 @@ | ||
|
||
def _update_variables(self) -> None: | ||
def _unused_update_variables(self) -> None: | ||
""" |
The |
Add asyncua, the opcua python module, as dependency