Skip to content

Commit

Permalink
release/v0.23.0 (viamrobotics#666)
Browse files Browse the repository at this point in the history
Co-authored-by: njooma <[email protected]>
  • Loading branch information
github-actions[bot] and njooma authored Jun 25, 2024
1 parent 330b342 commit 37c135d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "viam-sdk"
version = "0.22.0"
version = "0.23.0"
description = "Viam Robotics Python SDK"
authors = [ "Naveed <[email protected]>" ]
license = "Apache-2.0"
Expand Down
10 changes: 6 additions & 4 deletions src/viam/resource/easy_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ def _create_stub_fn(name: str, is_async: bool) -> Callable:
if is_async:
# note: this is a pyright bug https://github.com/microsoft/pyright/issues/2136
async def stub_fn(*args, **kwargs): # pyright: ignore [reportRedeclaration]
logger.info(f'{name} not implemented')
logger.info(f"{name} not implemented")
raise MethodNotImplementedError(name)

else:

def stub_fn(*args, **kwargs):
logger.info(f'{name} not implemented')
logger.info(f"{name} not implemented")
raise MethodNotImplementedError(name)

stub_fn.__name__ = f'{name}_stub'
stub_fn.__name__ = f"{name}_stub"
return stub_fn


Expand All @@ -67,7 +69,7 @@ class MyMotor(Motor, EasyResource):
is_async = inspect.iscoroutinefunction(val)
stub_fn = _create_stub_fn(attr, is_async)
setattr(cls, attr, stub_fn)
logger.debug('patched %s.%s with %s', cls, attr, stub_fn)
logger.debug("patched %s.%s with %s", cls, attr, stub_fn)
cls.__abstractmethods__ -= {attr}
return cls

Expand Down
5 changes: 3 additions & 2 deletions tests/test_easy_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ class SubclassTest(Generic, EasyResource):
def test_stubs(self, clear_registry):
class MyMotor(Motor, EasyResource):
MODEL = "org:type:name"

with pytest.raises(TypeError):
# this has unimplemented abstract methods and should fail with TypeError
MyMotor('name')
MyMotor("name")

MyMotor = stub_model(MyMotor)
MyMotor('name') # this has been stubbed and should now succeed
MyMotor("name") # this has been stubbed and should now succeed

0 comments on commit 37c135d

Please sign in to comment.