This is an automated email from the ASF dual-hosted git repository.

bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 48e136fa8f fix: Resolve python client mypy failed in pre-commit (#2884)
48e136fa8f is described below

commit 48e136fa8f84c381ca85f3c2c66b8d5b978672a2
Author: airwish <[email protected]>
AuthorDate: Thu May 23 22:30:09 2024 +0800

    fix: Resolve python client mypy failed in pre-commit (#2884)
    
    * fix: Resolve mypy failed in pre-commit
    
    * update make pre-commit
    
    * change pre-commit to directly add tests
    
    * only scan the changed files
---
 streampipes-client-python/Makefile                      |  7 ++++++-
 .../streampipes/endpoint/api/version.py                 | 17 +++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/streampipes-client-python/Makefile 
b/streampipes-client-python/Makefile
index 2ac4ef1576..df6cb0b098 100644
--- a/streampipes-client-python/Makefile
+++ b/streampipes-client-python/Makefile
@@ -47,7 +47,12 @@ reformat-all:
 
 .PHONY: pre-commit
 pre-commit:
-       git ls-files -- 'streampipes/**/*' | xargs poetry run pre-commit run 
--verbose --files
+       @CHANGED_FILES_PYTHON=$$(git diff --name-only HEAD~1 HEAD -- 
'streampipes/**/*' 'tests/**/*'); \
+       if [ -n "$$CHANGED_FILES_PYTHON" ]; then \
+               poetry run pre-commit run --verbose --files 
$$CHANGED_FILES_PYTHON; \
+       else \
+               echo "No files changed in 'streampipes' or 'tests' 
directories."; \
+       fi
 
 .PHONY: unit-tests
 unit-tests:
diff --git a/streampipes-client-python/streampipes/endpoint/api/version.py 
b/streampipes-client-python/streampipes/endpoint/api/version.py
index 1a319a6de5..fb06583e3a 100644
--- a/streampipes-client-python/streampipes/endpoint/api/version.py
+++ b/streampipes-client-python/streampipes/endpoint/api/version.py
@@ -28,6 +28,7 @@ from typing import Tuple, Type
 from streampipes.endpoint import APIEndpoint
 from streampipes.model.container import Versions
 from streampipes.model.container.resource_container import ResourceContainer
+from streampipes.model.resource import Version
 from streampipes.model.resource.resource import Resource
 
 
@@ -73,6 +74,16 @@ class VersionEndpoint(APIEndpoint):
 
         return Versions
 
+    @property
+    def _resource_cls(cls) -> Type[Version]:
+        """Returns the class of the resource that are bundled.
+
+        Returns
+        -------
+        [Version][streampipes.model.resource.Version]
+        """
+        return Version
+
     @property
     def _relative_api_path(self) -> Tuple[str, ...]:
         """Defines the relative api path to the DataStream endpoint.
@@ -99,7 +110,7 @@ class VersionEndpoint(APIEndpoint):
         """
         raise NotImplementedError("The `all()` method is not supported by this 
endpoint.")
 
-    def get(self, identifier: str, **kwargs) -> Resource:
+    def get(self, identifier: str, **kwargs) -> Version:
         """Queries the resource from the API endpoint.
 
         For this endpoint only one resource is available.
@@ -125,7 +136,9 @@ class VersionEndpoint(APIEndpoint):
                 "Please set 'identifier' to an empty string or 'None'."
             )
 
-        return super().get(identifier="")
+        response = 
self._make_request(request_method=self._parent_client.request_session.get, 
url=self.build_url())
+
+        return self._resource_cls(**response.json())
 
     def post(self, resource: Resource) -> None:
         """Usually, this method allows to create via this endpoint.

Reply via email to