Automatic Test#18383#29
Conversation
HocaChen
left a comment
There was a problem hiding this comment.
I download the branch and test with 3 types of commands
*IDN?
*LOCAL
move_chuck_xy
it can work as expected
| Response.check_resp(self.comm.read_line()) | ||
|
|
||
|
|
||
| def send_cmd(self, cmd: str) -> Response: |
There was a problem hiding this comment.
Please always return a response object.
- When we send a SENTIO remote command we have a response object anyway.
- When we send a "*IDN?" create a new response object, and set the response as the "message()" return
- When we send a low level command, that does not have a response create a response object on the fly and assign an empty string to the message.
Here is my reasoning:
Your modification is perfectly fine and technically correct but it breaks the "principle of least suprise". When using a send_cmd function that can return different types I have to know in advance which type i will receive. If i do not know the type the client would need to add a type checks on their side whenever send_cmd is used. If i dont do this i will get runtime errors. In addition a python type checker running on client code would mark code that does not actually do the type checking as an error.
The only way to avoid runtime errors or errors from the python type checker in your version would be to check which type is returned whenever send_cmd is used. The easiest way to avoid that and allow clients to write code that works regardless of the type of command sent is to always return a SENTIO response object.
There was a problem hiding this comment.
I have already fixed the modification.
Please assist with the confirmation again.
Return of low level remote command can't parses