Skip to content

Commit

Permalink
feat(pyd): use noop consumer default for upy eval/eval_script
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Apr 17, 2023
1 parent 885e9d3 commit 720ace4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions micropy/pyd/backend_upydevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,17 @@ def read_file(
value = buffer.getvalue().decode()
return value

def eval(self, command: str, *, consumer: MessageConsumer | None = None) -> str | None:
if consumer:
return self._pydevice.cmd(
command, follow=True, pipe=lambda m, *args, **kws: consumer.on_message(m)
)
return self._pydevice.cmd(command)
def eval(self, command: str, *, consumer: MessageConsumer = NoOpConsumer) -> str | None:
return self._pydevice.cmd(
command, follow=True, pipe=lambda m, *args, **kws: consumer.on_message(m)
)

def eval_script(
self,
contents: AnyStr,
target_path: DevicePath | None = None,
*,
consumer: PyDeviceConsumer | None = None,
consumer: PyDeviceConsumer = NoOpConsumer,
):
_target_path = (
self.resolve_path(target_path) if target_path else f"{self._rand_device_path()}.py"
Expand Down

0 comments on commit 720ace4

Please sign in to comment.