From e1250d86775dd4acd2f09eb8c706f89182cd03de Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 20 Nov 2025 20:43:42 +0000 Subject: [PATCH 1/5] Apply black formatting --- docs/source/conf.py | 4 +--- pyproject.toml | 3 +++ src/vws/query.py | 4 +--- src/vws/vws.py | 8 ++----- tests/test_cloud_reco_exceptions.py | 8 ++----- tests/test_vws.py | 34 +++++++---------------------- tests/test_vws_exceptions.py | 4 +--- 7 files changed, 18 insertions(+), 47 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 914bcb88..60b8a2c6 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -42,9 +42,7 @@ specifiers = SpecifierSet(specifiers=requires_python) (specifier,) = specifiers if specifier.operator != ">=": - msg = ( - f"We only support '>=' for Requires-Python, got {specifier.operator}." - ) + msg = f"We only support '>=' for Requires-Python, got {specifier.operator}." raise ValueError(msg) minimum_python_version = specifier.version diff --git a/pyproject.toml b/pyproject.toml index 7b0e67fa..13332080 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,6 +107,9 @@ universal = true # Code to match this is in ``conf.py``. version_scheme = "post-release" +[tool.uv.sources] +docformatter = { git = "https://github.com/PyCQA/docformatter.git", branch = "master" } + [tool.ruff] line-length = 79 diff --git a/src/vws/query.py b/src/vws/query.py index 96122aa1..7d4e3e86 100644 --- a/src/vws/query.py +++ b/src/vws/query.py @@ -164,9 +164,7 @@ def query( if "Integer out of range" in response.text: raise MaxNumResultsOutOfRangeError(response=response) - if ( - response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR - ): # pragma: no cover + if response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR: # pragma: no cover raise ServerError(response=response) result_code = json.loads(s=response.text)["result_code"] diff --git a/src/vws/vws.py b/src/vws/vws.py index 5dd7503d..4d9b7f6c 100644 --- a/src/vws/vws.py +++ b/src/vws/vws.py @@ -195,15 +195,11 @@ def make_request( base_vws_url=self._base_vws_url, ) - if ( - response.status_code == HTTPStatus.TOO_MANY_REQUESTS - ): # pragma: no cover + if response.status_code == HTTPStatus.TOO_MANY_REQUESTS: # pragma: no cover # The Vuforia API returns a 429 response with no JSON body. raise TooManyRequestsError(response=response) - if ( - response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR - ): # pragma: no cover + if response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR: # pragma: no cover raise ServerError(response=response) result_code = json.loads(s=response.text)["result_code"] diff --git a/tests/test_cloud_reco_exceptions.py b/tests/test_cloud_reco_exceptions.py index 3515b0d2..112382a5 100644 --- a/tests/test_cloud_reco_exceptions.py +++ b/tests/test_cloud_reco_exceptions.py @@ -57,9 +57,7 @@ def test_image_too_large( with pytest.raises(expected_exception=RequestEntityTooLargeError) as exc: cloud_reco_client.query(image=png_too_large) - assert ( - exc.value.response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE - ) + assert exc.value.response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE def test_cloudrecoexception_inheritance() -> None: @@ -92,9 +90,7 @@ def test_authentication_failure( with MockVWS() as mock: mock.add_database(database=database) - with pytest.raises( - expected_exception=AuthenticationFailureError - ) as exc: + with pytest.raises(expected_exception=AuthenticationFailureError) as exc: cloud_reco_client.query(image=high_quality_image) assert exc.value.response.status_code == HTTPStatus.UNAUTHORIZED diff --git a/tests/test_vws.py b/tests/test_vws.py index e16eff55..15934865 100644 --- a/tests/test_vws.py +++ b/tests/test_vws.py @@ -229,12 +229,8 @@ def test_get_target_summary_report( assert report.active_flag == expected_report.active_flag assert report.tracking_rating == expected_report.tracking_rating assert report.total_recos == expected_report.total_recos - assert ( - report.current_month_recos == expected_report.current_month_recos - ) - assert ( - report.previous_month_recos == expected_report.previous_month_recos - ) + assert report.current_month_recos == expected_report.current_month_recos + assert report.previous_month_recos == expected_report.previous_month_recos assert report == expected_report @@ -267,15 +263,11 @@ def test_get_target(vws_client: VWS) -> None: ) assert report.active_images == expected_report.active_images - assert ( - report.current_month_recos == expected_report.current_month_recos - ) + assert report.current_month_recos == expected_report.current_month_recos assert report.failed_images == expected_report.failed_images assert report.inactive_images == expected_report.inactive_images assert report.name == expected_report.name - assert ( - report.previous_month_recos == expected_report.previous_month_recos - ) + assert report.previous_month_recos == expected_report.previous_month_recos assert report.processing_images == expected_report.processing_images assert report.reco_threshold == expected_report.reco_threshold assert report.request_quota == expected_report.request_quota @@ -319,23 +311,15 @@ def test_get_target_record( assert result.target_record == expected_target_record - assert ( - result.target_record.target_id == expected_target_record.target_id - ) - assert ( - result.target_record.active_flag - == expected_target_record.active_flag - ) + assert result.target_record.target_id == expected_target_record.target_id + assert result.target_record.active_flag == expected_target_record.active_flag assert result.target_record.name == expected_target_record.name assert result.target_record.width == expected_target_record.width assert ( result.target_record.tracking_rating == expected_target_record.tracking_rating ) - assert ( - result.target_record.reco_rating - == expected_target_record.reco_rating - ) + assert result.target_record.reco_rating == expected_target_record.reco_rating assert result.status == TargetStatuses.PROCESSING @@ -514,9 +498,7 @@ def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None: report = vws_client.get_target_summary_report(target_id=target_id) assert report.status == TargetStatuses.PROCESSING - with pytest.raises( - expected_exception=TargetProcessingTimeoutError - ): + with pytest.raises(expected_exception=TargetProcessingTimeoutError): vws_client.wait_for_target_processed( target_id=target_id, timeout_seconds=0.1, diff --git a/tests/test_vws_exceptions.py b/tests/test_vws_exceptions.py index 86da6604..d34e497d 100644 --- a/tests/test_vws_exceptions.py +++ b/tests/test_vws_exceptions.py @@ -287,9 +287,7 @@ def test_authentication_failure( with MockVWS() as mock: mock.add_database(database=database) - with pytest.raises( - expected_exception=AuthenticationFailureError - ) as exc: + with pytest.raises(expected_exception=AuthenticationFailureError) as exc: vws_client.add_target( name="x", width=1, From 96142ea121089e30da4aab94cf77d46b0709a544 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 20 Nov 2025 20:44:32 +0000 Subject: [PATCH 2/5] Docformatter black --- conftest.py | 1 + docs/source/__init__.py | 2 ++ docs/source/conf.py | 1 + src/vws/__init__.py | 1 + src/vws/exceptions/__init__.py | 2 ++ src/vws/exceptions/base_exceptions.py | 5 +-- src/vws/exceptions/cloud_reco_exceptions.py | 12 +++---- src/vws/exceptions/custom_exceptions.py | 2 +- src/vws/exceptions/vws_exceptions.py | 29 +++-------------- src/vws/include_target_data.py | 4 +-- src/vws/query.py | 1 + src/vws/reports.py | 1 + src/vws/response.py | 1 + src/vws/vws.py | 8 ++--- tests/__init__.py | 2 ++ tests/conftest.py | 1 + tests/test_cloud_reco_exceptions.py | 16 +++++----- tests/test_query.py | 16 +++++----- tests/test_vws.py | 4 +-- tests/test_vws_exceptions.py | 35 ++++++++++----------- 20 files changed, 66 insertions(+), 78 deletions(-) diff --git a/conftest.py b/conftest.py index 1d776f8d..e9e69d94 100644 --- a/conftest.py +++ b/conftest.py @@ -2,6 +2,7 @@ Setup for Sybil. """ + import io import uuid from collections.abc import Generator diff --git a/docs/source/__init__.py b/docs/source/__init__.py index b63eed5f..555f06d3 100644 --- a/docs/source/__init__.py +++ b/docs/source/__init__.py @@ -1,3 +1,5 @@ """ Documentation. """ + + diff --git a/docs/source/conf.py b/docs/source/conf.py index 60b8a2c6..6b6f298c 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,6 +3,7 @@ Configuration for Sphinx. """ + import importlib.metadata from pathlib import Path diff --git a/src/vws/__init__.py b/src/vws/__init__.py index 42788b92..4153f523 100644 --- a/src/vws/__init__.py +++ b/src/vws/__init__.py @@ -2,6 +2,7 @@ A library for Vuforia Web Services. """ + from .query import CloudRecoService from .vws import VWS diff --git a/src/vws/exceptions/__init__.py b/src/vws/exceptions/__init__.py index a1e3cd91..07d9bf0e 100644 --- a/src/vws/exceptions/__init__.py +++ b/src/vws/exceptions/__init__.py @@ -1,3 +1,5 @@ """ Custom exceptions raised by this package. """ + + diff --git a/src/vws/exceptions/base_exceptions.py b/src/vws/exceptions/base_exceptions.py index 943323bf..1114469d 100644 --- a/src/vws/exceptions/base_exceptions.py +++ b/src/vws/exceptions/base_exceptions.py @@ -1,8 +1,9 @@ """ -Base exceptions for errors returned by Vuforia Web Services or the Vuforia -Cloud Recognition Web API. +Base exceptions for errors returned by Vuforia Web Services or the Vuforia Cloud +Recognition Web API. """ + from beartype import beartype from vws.response import Response diff --git a/src/vws/exceptions/cloud_reco_exceptions.py b/src/vws/exceptions/cloud_reco_exceptions.py index ff5dde20..4f0a94f2 100644 --- a/src/vws/exceptions/cloud_reco_exceptions.py +++ b/src/vws/exceptions/cloud_reco_exceptions.py @@ -2,6 +2,7 @@ Exceptions which match errors raised by the Vuforia Cloud Recognition Web APIs. """ + from beartype import beartype from vws.exceptions.base_exceptions import CloudRecoError @@ -10,11 +11,10 @@ @beartype class MaxNumResultsOutOfRangeError(CloudRecoError): """ - Exception raised when the ``max_num_results`` given to the Cloud - Recognition Web API query endpoint is out of range. + Exception raised when the ``max_num_results`` given to the Cloud Recognition Web API + query endpoint is out of range. """ - @beartype class InactiveProjectError(CloudRecoError): """ @@ -22,15 +22,12 @@ class InactiveProjectError(CloudRecoError): 'InactiveProject'. """ - @beartype class BadImageError(CloudRecoError): """ - Exception raised when Vuforia returns a response with a result code - 'BadImage'. + Exception raised when Vuforia returns a response with a result code 'BadImage'. """ - @beartype class AuthenticationFailureError(CloudRecoError): """ @@ -38,7 +35,6 @@ class AuthenticationFailureError(CloudRecoError): 'AuthenticationFailure'. """ - @beartype class RequestTimeTooSkewedError(CloudRecoError): """ diff --git a/src/vws/exceptions/custom_exceptions.py b/src/vws/exceptions/custom_exceptions.py index 694e98c3..e634b97c 100644 --- a/src/vws/exceptions/custom_exceptions.py +++ b/src/vws/exceptions/custom_exceptions.py @@ -4,6 +4,7 @@ or simple errors given by the cloud recognition service. """ + from beartype import beartype from vws.response import Response @@ -37,7 +38,6 @@ class TargetProcessingTimeoutError(Exception): Exception raised when waiting for a target to be processed times out. """ - @beartype class ServerError(Exception): # pragma: no cover """ diff --git a/src/vws/exceptions/vws_exceptions.py b/src/vws/exceptions/vws_exceptions.py index 48222376..0f437a79 100644 --- a/src/vws/exceptions/vws_exceptions.py +++ b/src/vws/exceptions/vws_exceptions.py @@ -4,6 +4,7 @@ https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes. """ + import json from urllib.parse import urlparse @@ -15,8 +16,7 @@ @beartype class UnknownTargetError(VWSError): """ - Exception raised when Vuforia returns a response with a result code - 'UnknownTarget'. + Exception raised when Vuforia returns a response with a result code 'UnknownTarget'. """ @property @@ -36,15 +36,12 @@ class FailError(VWSError): Exception raised when Vuforia returns a response with a result code 'Fail'. """ - @beartype class BadImageError(VWSError): """ - Exception raised when Vuforia returns a response with a result code - 'BadImage'. + Exception raised when Vuforia returns a response with a result code 'BadImage'. """ - @beartype class AuthenticationFailureError(VWSError): """ @@ -52,7 +49,6 @@ class AuthenticationFailureError(VWSError): 'AuthenticationFailure'. """ - # See https://github.com/VWS-Python/vws-python/issues/822. @beartype class RequestQuotaReachedError(VWSError): # pragma: no cover @@ -61,14 +57,12 @@ class RequestQuotaReachedError(VWSError): # pragma: no cover 'RequestQuotaReached'. """ - @beartype class TargetStatusProcessingError(VWSError): """ Exception raised when Vuforia returns a response with a result code 'TargetStatusProcessing'. """ - @property def target_id(self) -> str: """ @@ -87,8 +81,6 @@ class DateRangeError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'DateRangeError'. """ - - # This is not simulated by the mock. @beartype class TargetQuotaReachedError(VWSError): # pragma: no cover @@ -96,8 +88,6 @@ class TargetQuotaReachedError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'TargetQuotaReached'. """ - - # This is not simulated by the mock. @beartype class ProjectSuspendedError(VWSError): # pragma: no cover @@ -105,8 +95,6 @@ class ProjectSuspendedError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'ProjectSuspended'. """ - - # This is not simulated by the mock. @beartype class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover @@ -114,16 +102,12 @@ class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'ProjectHasNoAPIAccess'. """ - - @beartype class ProjectInactiveError(VWSError): """ Exception raised when Vuforia returns a response with a result code 'ProjectInactive'. """ - - @beartype class MetadataTooLargeError(VWSError): """ @@ -131,7 +115,6 @@ class MetadataTooLargeError(VWSError): 'MetadataTooLarge'. """ - @beartype class RequestTimeTooSkewedError(VWSError): """ @@ -139,7 +122,6 @@ class RequestTimeTooSkewedError(VWSError): 'RequestTimeTooSkewed'. """ - @beartype class TargetNameExistError(VWSError): """ @@ -160,11 +142,9 @@ def target_name(self) -> str: @beartype class ImageTooLargeError(VWSError): """ - Exception raised when Vuforia returns a response with a result code - 'ImageTooLarge'. + Exception raised when Vuforia returns a response with a result code 'ImageTooLarge'. """ - @beartype class TargetStatusNotSuccessError(VWSError): """ @@ -189,3 +169,4 @@ class TooManyRequestsError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'TooManyRequests'. """ + diff --git a/src/vws/include_target_data.py b/src/vws/include_target_data.py index 37682e08..28a5e797 100644 --- a/src/vws/include_target_data.py +++ b/src/vws/include_target_data.py @@ -2,6 +2,7 @@ Tools for managing ``CloudRecoService.query``'s ``include_target_data``. """ + from enum import StrEnum, auto, unique from beartype import beartype @@ -11,8 +12,7 @@ @unique class CloudRecoIncludeTargetData(StrEnum): """ - Options for the ``include_target_data`` parameter of - ``CloudRecoService.query``. + Options for the ``include_target_data`` parameter of ``CloudRecoService.query``. """ TOP = auto() diff --git a/src/vws/query.py b/src/vws/query.py index 7d4e3e86..fbb2bed3 100644 --- a/src/vws/query.py +++ b/src/vws/query.py @@ -2,6 +2,7 @@ Tools for interacting with the Vuforia Cloud Recognition Web APIs. """ + import datetime import io import json diff --git a/src/vws/reports.py b/src/vws/reports.py index f6a77133..07172c12 100644 --- a/src/vws/reports.py +++ b/src/vws/reports.py @@ -2,6 +2,7 @@ Classes for representing Vuforia reports. """ + import datetime from dataclasses import dataclass from enum import Enum, unique diff --git a/src/vws/response.py b/src/vws/response.py index 269f2e23..f8601097 100644 --- a/src/vws/response.py +++ b/src/vws/response.py @@ -2,6 +2,7 @@ Responses for requests to VWS and VWQ. """ + from dataclasses import dataclass from beartype import beartype diff --git a/src/vws/vws.py b/src/vws/vws.py index 4d9b7f6c..f310d287 100644 --- a/src/vws/vws.py +++ b/src/vws/vws.py @@ -2,6 +2,7 @@ Tools for interacting with Vuforia APIs. """ + import base64 import io import json @@ -308,8 +309,7 @@ def add_target( return str(object=json.loads(s=response.text)["target_id"]) def get_target_record(self, target_id: str) -> TargetStatusAndRecord: - """Get a given target's target record from the Target Management - System. + """Get a given target's target record from the Target Management System. See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record. @@ -365,8 +365,8 @@ def wait_for_target_processed( seconds_between_requests: float = 0.2, timeout_seconds: float = 60 * 5, ) -> None: - """Wait up to five minutes (arbitrary) for a target to get past the - processing stage. + """Wait up to five minutes (arbitrary) for a target to get past the processing + stage. Args: target_id: The ID of the target to wait for. diff --git a/tests/__init__.py b/tests/__init__.py index c7e38a86..faa5c00c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,3 +1,5 @@ """ Tests for ``vws``. """ + + diff --git a/tests/conftest.py b/tests/conftest.py index 74c6fc56..4cdd29cc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ Configuration, plugins and fixtures for `pytest`. """ + import io from collections.abc import Generator from pathlib import Path diff --git a/tests/test_cloud_reco_exceptions.py b/tests/test_cloud_reco_exceptions.py index 112382a5..3ba09d48 100644 --- a/tests/test_cloud_reco_exceptions.py +++ b/tests/test_cloud_reco_exceptions.py @@ -2,6 +2,7 @@ Tests for exceptions raised when using the CloudRecoService. """ + import io import uuid from http import HTTPStatus @@ -30,8 +31,8 @@ def test_too_many_max_results( high_quality_image: io.BytesIO, ) -> None: """ - A ``MaxNumResultsOutOfRange`` error is raised if the given - ``max_num_results`` is out of range. + A ``MaxNumResultsOutOfRange`` error is raised if the given ``max_num_results`` is + out of range. """ with pytest.raises(expected_exception=MaxNumResultsOutOfRangeError) as exc: cloud_reco_client.query( @@ -51,8 +52,8 @@ def test_image_too_large( png_too_large: io.BytesIO | io.BufferedRandom, ) -> None: """ - A ``RequestEntityTooLarge`` exception is raised if an image which is too - large is given. + A ``RequestEntityTooLarge`` exception is raised if an image which is too large is + given. """ with pytest.raises(expected_exception=RequestEntityTooLargeError) as exc: cloud_reco_client.query(image=png_too_large) @@ -79,8 +80,8 @@ def test_authentication_failure( high_quality_image: io.BytesIO, ) -> None: """ - An ``AuthenticationFailure`` exception is raised when the client access key - exists but the client secret key is incorrect. + An ``AuthenticationFailure`` exception is raised when the client access key exists + but the client secret key is incorrect. """ database = VuforiaDatabase() cloud_reco_client = CloudRecoService( @@ -100,8 +101,7 @@ def test_inactive_project( high_quality_image: io.BytesIO, ) -> None: """ - An ``InactiveProject`` exception is raised when querying an inactive - database. + An ``InactiveProject`` exception is raised when querying an inactive database. """ database = VuforiaDatabase(state=States.PROJECT_INACTIVE) with MockVWS() as mock: diff --git a/tests/test_query.py b/tests/test_query.py index e229cf95..9c7913c4 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -2,6 +2,7 @@ Tests for the ``CloudRecoService`` querying functionality. """ + import io import uuid from typing import BinaryIO @@ -58,8 +59,7 @@ class TestCustomBaseVWQURL: @staticmethod def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None: """ - It is possible to use query a target to a database under a custom VWQ - URL. + It is possible to use query a target to a database under a custom VWQ URL. """ base_vwq_url = "http://example.com" with MockVWS(base_vwq_url=base_vwq_url) as mock: @@ -210,8 +210,8 @@ def test_top( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.TOP`` is given, target data is only - returned in the top match. + When ``CloudRecoIncludeTargetData.TOP`` is given, target data is only returned + in the top match. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, @@ -244,8 +244,8 @@ def test_none( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.NONE`` is given, target data is not - returned in any match. + When ``CloudRecoIncludeTargetData.NONE`` is given, target data is not returned + in any match. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, @@ -278,8 +278,8 @@ def test_all( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.ALL`` is given, target data is - returned in all matches. + When ``CloudRecoIncludeTargetData.ALL`` is given, target data is returned in all + matches. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, diff --git a/tests/test_vws.py b/tests/test_vws.py index 15934865..25af0c0e 100644 --- a/tests/test_vws.py +++ b/tests/test_vws.py @@ -2,6 +2,7 @@ Tests for helper functions for managing a Vuforia database. """ + import base64 import datetime import io @@ -105,8 +106,7 @@ class TestCustomBaseVWSURL: @staticmethod def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None: """ - It is possible to use add a target to a database under a custom VWS - URL. + It is possible to use add a target to a database under a custom VWS URL. """ base_vws_url = "http://example.com" with MockVWS(base_vws_url=base_vws_url) as mock: diff --git a/tests/test_vws_exceptions.py b/tests/test_vws_exceptions.py index d34e497d..d172042b 100644 --- a/tests/test_vws_exceptions.py +++ b/tests/test_vws_exceptions.py @@ -2,6 +2,7 @@ Tests for VWS exceptions. """ + import io import uuid from http import HTTPStatus @@ -42,8 +43,7 @@ def test_image_too_large( png_too_large: io.BytesIO | io.BufferedRandom, ) -> None: """ - When giving an image which is too large, an ``ImageTooLarge`` exception is - raised. + When giving an image which is too large, an ``ImageTooLarge`` exception is raised. """ with pytest.raises(expected_exception=ImageTooLargeError) as exc: vws_client.add_target( @@ -59,8 +59,8 @@ def test_image_too_large( def test_invalid_given_id(vws_client: VWS) -> None: """ - Giving an invalid ID to a helper which requires a target ID to be given - causes an ``UnknownTarget`` exception to be raised. + Giving an invalid ID to a helper which requires a target ID to be given causes an + ``UnknownTarget`` exception to be raised. """ target_id = "12345abc" with pytest.raises(expected_exception=UnknownTargetError) as exc: @@ -71,8 +71,7 @@ def test_invalid_given_id(vws_client: VWS) -> None: def test_add_bad_name(vws_client: VWS, high_quality_image: io.BytesIO) -> None: """ - When a name with a bad character is given, a ``ServerError`` exception is - raised. + When a name with a bad character is given, a ``ServerError`` exception is raised. """ max_char_value = 65535 bad_name = chr(max_char_value + 1) @@ -141,8 +140,8 @@ def test_target_name_exist( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetNameExist`` exception is raised after adding two targets with the - same name. + A ``TargetNameExist`` exception is raised after adding two targets with the same + name. """ vws_client.add_target( name="x", @@ -196,8 +195,8 @@ def test_target_status_processing( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetStatusProcessing`` exception is raised if trying to delete a - target which is processing. + A ``TargetStatusProcessing`` exception is raised if trying to delete a target which + is processing. """ target_id = vws_client.add_target( name="x", @@ -219,8 +218,7 @@ def test_metadata_too_large( high_quality_image: io.BytesIO, ) -> None: """ - A ``MetadataTooLarge`` exception is raised if the metadata given is too - large. + A ``MetadataTooLarge`` exception is raised if the metadata given is too large. """ with pytest.raises(expected_exception=MetadataTooLargeError) as exc: vws_client.add_target( @@ -239,8 +237,8 @@ def test_request_time_too_skewed( high_quality_image: io.BytesIO, ) -> None: """ - A ``RequestTimeTooSkewed`` exception is raised when the request time is - more than five minutes different from the server time. + A ``RequestTimeTooSkewed`` exception is raised when the request time is more than + five minutes different from the server time. """ target_id = vws_client.add_target( name="x", @@ -273,9 +271,8 @@ def test_authentication_failure( high_quality_image: io.BytesIO, ) -> None: """ - An ``AuthenticationFailure`` exception is raised when the server access key - exists but the server secret key is incorrect, or when a client key is - incorrect. + An ``AuthenticationFailure`` exception is raised when the server access key exists + but the server secret key is incorrect, or when a client key is incorrect. """ database = VuforiaDatabase() @@ -304,8 +301,8 @@ def test_target_status_not_success( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetStatusNotSuccess`` exception is raised when updating a target - which has a status which is not "Success". + A ``TargetStatusNotSuccess`` exception is raised when updating a target which has a + status which is not "Success". """ target_id = vws_client.add_target( name="x", From 65d7afd4fbc390f2da0d0320d2756ff12150e2be Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 20 Nov 2025 20:44:44 +0000 Subject: [PATCH 3/5] Docformatter black --- src/vws/exceptions/cloud_reco_exceptions.py | 1 + src/vws/exceptions/vws_exceptions.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/vws/exceptions/cloud_reco_exceptions.py b/src/vws/exceptions/cloud_reco_exceptions.py index 4f0a94f2..2a78179a 100644 --- a/src/vws/exceptions/cloud_reco_exceptions.py +++ b/src/vws/exceptions/cloud_reco_exceptions.py @@ -41,3 +41,4 @@ class RequestTimeTooSkewedError(CloudRecoError): Exception raised when Vuforia returns a response with a result code 'RequestTimeTooSkewed'. """ + diff --git a/src/vws/exceptions/vws_exceptions.py b/src/vws/exceptions/vws_exceptions.py index 0f437a79..87f002c4 100644 --- a/src/vws/exceptions/vws_exceptions.py +++ b/src/vws/exceptions/vws_exceptions.py @@ -63,6 +63,7 @@ class TargetStatusProcessingError(VWSError): Exception raised when Vuforia returns a response with a result code 'TargetStatusProcessing'. """ + @property def target_id(self) -> str: """ @@ -81,6 +82,7 @@ class DateRangeError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'DateRangeError'. """ + # This is not simulated by the mock. @beartype class TargetQuotaReachedError(VWSError): # pragma: no cover @@ -88,6 +90,7 @@ class TargetQuotaReachedError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'TargetQuotaReached'. """ + # This is not simulated by the mock. @beartype class ProjectSuspendedError(VWSError): # pragma: no cover @@ -95,6 +98,7 @@ class ProjectSuspendedError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'ProjectSuspended'. """ + # This is not simulated by the mock. @beartype class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover @@ -102,12 +106,14 @@ class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'ProjectHasNoAPIAccess'. """ + @beartype class ProjectInactiveError(VWSError): """ Exception raised when Vuforia returns a response with a result code 'ProjectInactive'. """ + @beartype class MetadataTooLargeError(VWSError): """ From 763af650793f6ed1b93054cbb3bb3ec536cb6a42 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 26 Nov 2025 09:24:28 +0000 Subject: [PATCH 4/5] Run finswimmer docformatter with black style --- conftest.py | 1 - docs/source/__init__.py | 2 -- docs/source/conf.py | 5 +-- pyproject.toml | 3 +- src/vws/__init__.py | 1 - src/vws/exceptions/__init__.py | 2 -- src/vws/exceptions/base_exceptions.py | 5 ++- src/vws/exceptions/cloud_reco_exceptions.py | 13 ++++--- src/vws/exceptions/custom_exceptions.py | 2 +- src/vws/exceptions/vws_exceptions.py | 19 +++++++--- src/vws/include_target_data.py | 4 +-- src/vws/query.py | 5 +-- src/vws/reports.py | 1 - src/vws/response.py | 1 - src/vws/vws.py | 16 +++++---- tests/__init__.py | 2 -- tests/conftest.py | 1 - tests/test_cloud_reco_exceptions.py | 24 +++++++------ tests/test_query.py | 16 ++++----- tests/test_vws.py | 38 ++++++++++++++------ tests/test_vws_exceptions.py | 39 ++++++++++++--------- 21 files changed, 117 insertions(+), 83 deletions(-) diff --git a/conftest.py b/conftest.py index e9e69d94..1d776f8d 100644 --- a/conftest.py +++ b/conftest.py @@ -2,7 +2,6 @@ Setup for Sybil. """ - import io import uuid from collections.abc import Generator diff --git a/docs/source/__init__.py b/docs/source/__init__.py index 555f06d3..b63eed5f 100644 --- a/docs/source/__init__.py +++ b/docs/source/__init__.py @@ -1,5 +1,3 @@ """ Documentation. """ - - diff --git a/docs/source/conf.py b/docs/source/conf.py index 6b6f298c..914bcb88 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,7 +3,6 @@ Configuration for Sphinx. """ - import importlib.metadata from pathlib import Path @@ -43,7 +42,9 @@ specifiers = SpecifierSet(specifiers=requires_python) (specifier,) = specifiers if specifier.operator != ">=": - msg = f"We only support '>=' for Requires-Python, got {specifier.operator}." + msg = ( + f"We only support '>=' for Requires-Python, got {specifier.operator}." + ) raise ValueError(msg) minimum_python_version = specifier.version diff --git a/pyproject.toml b/pyproject.toml index 2cf188d7..88a691c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ universal = true version_scheme = "post-release" [tool.uv.sources] -docformatter = { git = "https://github.com/PyCQA/docformatter.git", branch = "master" } +docformatter = { git = "https://github.com/finswimmer/docformatter.git", branch = "fix-new-lines" } [tool.ruff] line-length = 79 @@ -276,6 +276,7 @@ spelling-store-unknown-words = 'no' [tool.docformatter] make-summary-multi-line = true +style = "black" [tool.check-manifest] diff --git a/src/vws/__init__.py b/src/vws/__init__.py index 4153f523..42788b92 100644 --- a/src/vws/__init__.py +++ b/src/vws/__init__.py @@ -2,7 +2,6 @@ A library for Vuforia Web Services. """ - from .query import CloudRecoService from .vws import VWS diff --git a/src/vws/exceptions/__init__.py b/src/vws/exceptions/__init__.py index 07d9bf0e..a1e3cd91 100644 --- a/src/vws/exceptions/__init__.py +++ b/src/vws/exceptions/__init__.py @@ -1,5 +1,3 @@ """ Custom exceptions raised by this package. """ - - diff --git a/src/vws/exceptions/base_exceptions.py b/src/vws/exceptions/base_exceptions.py index 1114469d..943323bf 100644 --- a/src/vws/exceptions/base_exceptions.py +++ b/src/vws/exceptions/base_exceptions.py @@ -1,9 +1,8 @@ """ -Base exceptions for errors returned by Vuforia Web Services or the Vuforia Cloud -Recognition Web API. +Base exceptions for errors returned by Vuforia Web Services or the Vuforia +Cloud Recognition Web API. """ - from beartype import beartype from vws.response import Response diff --git a/src/vws/exceptions/cloud_reco_exceptions.py b/src/vws/exceptions/cloud_reco_exceptions.py index 2a78179a..ff5dde20 100644 --- a/src/vws/exceptions/cloud_reco_exceptions.py +++ b/src/vws/exceptions/cloud_reco_exceptions.py @@ -2,7 +2,6 @@ Exceptions which match errors raised by the Vuforia Cloud Recognition Web APIs. """ - from beartype import beartype from vws.exceptions.base_exceptions import CloudRecoError @@ -11,10 +10,11 @@ @beartype class MaxNumResultsOutOfRangeError(CloudRecoError): """ - Exception raised when the ``max_num_results`` given to the Cloud Recognition Web API - query endpoint is out of range. + Exception raised when the ``max_num_results`` given to the Cloud + Recognition Web API query endpoint is out of range. """ + @beartype class InactiveProjectError(CloudRecoError): """ @@ -22,12 +22,15 @@ class InactiveProjectError(CloudRecoError): 'InactiveProject'. """ + @beartype class BadImageError(CloudRecoError): """ - Exception raised when Vuforia returns a response with a result code 'BadImage'. + Exception raised when Vuforia returns a response with a result code + 'BadImage'. """ + @beartype class AuthenticationFailureError(CloudRecoError): """ @@ -35,10 +38,10 @@ class AuthenticationFailureError(CloudRecoError): 'AuthenticationFailure'. """ + @beartype class RequestTimeTooSkewedError(CloudRecoError): """ Exception raised when Vuforia returns a response with a result code 'RequestTimeTooSkewed'. """ - diff --git a/src/vws/exceptions/custom_exceptions.py b/src/vws/exceptions/custom_exceptions.py index e634b97c..694e98c3 100644 --- a/src/vws/exceptions/custom_exceptions.py +++ b/src/vws/exceptions/custom_exceptions.py @@ -4,7 +4,6 @@ or simple errors given by the cloud recognition service. """ - from beartype import beartype from vws.response import Response @@ -38,6 +37,7 @@ class TargetProcessingTimeoutError(Exception): Exception raised when waiting for a target to be processed times out. """ + @beartype class ServerError(Exception): # pragma: no cover """ diff --git a/src/vws/exceptions/vws_exceptions.py b/src/vws/exceptions/vws_exceptions.py index 87f002c4..0ed136c5 100644 --- a/src/vws/exceptions/vws_exceptions.py +++ b/src/vws/exceptions/vws_exceptions.py @@ -4,7 +4,6 @@ https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes. """ - import json from urllib.parse import urlparse @@ -16,7 +15,8 @@ @beartype class UnknownTargetError(VWSError): """ - Exception raised when Vuforia returns a response with a result code 'UnknownTarget'. + Exception raised when Vuforia returns a response with a result code + 'UnknownTarget'. """ @property @@ -36,12 +36,15 @@ class FailError(VWSError): Exception raised when Vuforia returns a response with a result code 'Fail'. """ + @beartype class BadImageError(VWSError): """ - Exception raised when Vuforia returns a response with a result code 'BadImage'. + Exception raised when Vuforia returns a response with a result code + 'BadImage'. """ + @beartype class AuthenticationFailureError(VWSError): """ @@ -57,6 +60,7 @@ class RequestQuotaReachedError(VWSError): # pragma: no cover 'RequestQuotaReached'. """ + @beartype class TargetStatusProcessingError(VWSError): """ @@ -107,6 +111,7 @@ class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover 'ProjectHasNoAPIAccess'. """ + @beartype class ProjectInactiveError(VWSError): """ @@ -114,6 +119,7 @@ class ProjectInactiveError(VWSError): 'ProjectInactive'. """ + @beartype class MetadataTooLargeError(VWSError): """ @@ -121,6 +127,7 @@ class MetadataTooLargeError(VWSError): 'MetadataTooLarge'. """ + @beartype class RequestTimeTooSkewedError(VWSError): """ @@ -128,6 +135,7 @@ class RequestTimeTooSkewedError(VWSError): 'RequestTimeTooSkewed'. """ + @beartype class TargetNameExistError(VWSError): """ @@ -148,9 +156,11 @@ def target_name(self) -> str: @beartype class ImageTooLargeError(VWSError): """ - Exception raised when Vuforia returns a response with a result code 'ImageTooLarge'. + Exception raised when Vuforia returns a response with a result code + 'ImageTooLarge'. """ + @beartype class TargetStatusNotSuccessError(VWSError): """ @@ -175,4 +185,3 @@ class TooManyRequestsError(VWSError): # pragma: no cover Exception raised when Vuforia returns a response with a result code 'TooManyRequests'. """ - diff --git a/src/vws/include_target_data.py b/src/vws/include_target_data.py index 28a5e797..37682e08 100644 --- a/src/vws/include_target_data.py +++ b/src/vws/include_target_data.py @@ -2,7 +2,6 @@ Tools for managing ``CloudRecoService.query``'s ``include_target_data``. """ - from enum import StrEnum, auto, unique from beartype import beartype @@ -12,7 +11,8 @@ @unique class CloudRecoIncludeTargetData(StrEnum): """ - Options for the ``include_target_data`` parameter of ``CloudRecoService.query``. + Options for the ``include_target_data`` parameter of + ``CloudRecoService.query``. """ TOP = auto() diff --git a/src/vws/query.py b/src/vws/query.py index fbb2bed3..96122aa1 100644 --- a/src/vws/query.py +++ b/src/vws/query.py @@ -2,7 +2,6 @@ Tools for interacting with the Vuforia Cloud Recognition Web APIs. """ - import datetime import io import json @@ -165,7 +164,9 @@ def query( if "Integer out of range" in response.text: raise MaxNumResultsOutOfRangeError(response=response) - if response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR: # pragma: no cover + if ( + response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR + ): # pragma: no cover raise ServerError(response=response) result_code = json.loads(s=response.text)["result_code"] diff --git a/src/vws/reports.py b/src/vws/reports.py index 07172c12..f6a77133 100644 --- a/src/vws/reports.py +++ b/src/vws/reports.py @@ -2,7 +2,6 @@ Classes for representing Vuforia reports. """ - import datetime from dataclasses import dataclass from enum import Enum, unique diff --git a/src/vws/response.py b/src/vws/response.py index f8601097..269f2e23 100644 --- a/src/vws/response.py +++ b/src/vws/response.py @@ -2,7 +2,6 @@ Responses for requests to VWS and VWQ. """ - from dataclasses import dataclass from beartype import beartype diff --git a/src/vws/vws.py b/src/vws/vws.py index f310d287..5dd7503d 100644 --- a/src/vws/vws.py +++ b/src/vws/vws.py @@ -2,7 +2,6 @@ Tools for interacting with Vuforia APIs. """ - import base64 import io import json @@ -196,11 +195,15 @@ def make_request( base_vws_url=self._base_vws_url, ) - if response.status_code == HTTPStatus.TOO_MANY_REQUESTS: # pragma: no cover + if ( + response.status_code == HTTPStatus.TOO_MANY_REQUESTS + ): # pragma: no cover # The Vuforia API returns a 429 response with no JSON body. raise TooManyRequestsError(response=response) - if response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR: # pragma: no cover + if ( + response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR + ): # pragma: no cover raise ServerError(response=response) result_code = json.loads(s=response.text)["result_code"] @@ -309,7 +312,8 @@ def add_target( return str(object=json.loads(s=response.text)["target_id"]) def get_target_record(self, target_id: str) -> TargetStatusAndRecord: - """Get a given target's target record from the Target Management System. + """Get a given target's target record from the Target Management + System. See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record. @@ -365,8 +369,8 @@ def wait_for_target_processed( seconds_between_requests: float = 0.2, timeout_seconds: float = 60 * 5, ) -> None: - """Wait up to five minutes (arbitrary) for a target to get past the processing - stage. + """Wait up to five minutes (arbitrary) for a target to get past the + processing stage. Args: target_id: The ID of the target to wait for. diff --git a/tests/__init__.py b/tests/__init__.py index faa5c00c..c7e38a86 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,3 @@ """ Tests for ``vws``. """ - - diff --git a/tests/conftest.py b/tests/conftest.py index 4cdd29cc..74c6fc56 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,7 +2,6 @@ Configuration, plugins and fixtures for `pytest`. """ - import io from collections.abc import Generator from pathlib import Path diff --git a/tests/test_cloud_reco_exceptions.py b/tests/test_cloud_reco_exceptions.py index 3ba09d48..3515b0d2 100644 --- a/tests/test_cloud_reco_exceptions.py +++ b/tests/test_cloud_reco_exceptions.py @@ -2,7 +2,6 @@ Tests for exceptions raised when using the CloudRecoService. """ - import io import uuid from http import HTTPStatus @@ -31,8 +30,8 @@ def test_too_many_max_results( high_quality_image: io.BytesIO, ) -> None: """ - A ``MaxNumResultsOutOfRange`` error is raised if the given ``max_num_results`` is - out of range. + A ``MaxNumResultsOutOfRange`` error is raised if the given + ``max_num_results`` is out of range. """ with pytest.raises(expected_exception=MaxNumResultsOutOfRangeError) as exc: cloud_reco_client.query( @@ -52,13 +51,15 @@ def test_image_too_large( png_too_large: io.BytesIO | io.BufferedRandom, ) -> None: """ - A ``RequestEntityTooLarge`` exception is raised if an image which is too large is - given. + A ``RequestEntityTooLarge`` exception is raised if an image which is too + large is given. """ with pytest.raises(expected_exception=RequestEntityTooLargeError) as exc: cloud_reco_client.query(image=png_too_large) - assert exc.value.response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE + assert ( + exc.value.response.status_code == HTTPStatus.REQUEST_ENTITY_TOO_LARGE + ) def test_cloudrecoexception_inheritance() -> None: @@ -80,8 +81,8 @@ def test_authentication_failure( high_quality_image: io.BytesIO, ) -> None: """ - An ``AuthenticationFailure`` exception is raised when the client access key exists - but the client secret key is incorrect. + An ``AuthenticationFailure`` exception is raised when the client access key + exists but the client secret key is incorrect. """ database = VuforiaDatabase() cloud_reco_client = CloudRecoService( @@ -91,7 +92,9 @@ def test_authentication_failure( with MockVWS() as mock: mock.add_database(database=database) - with pytest.raises(expected_exception=AuthenticationFailureError) as exc: + with pytest.raises( + expected_exception=AuthenticationFailureError + ) as exc: cloud_reco_client.query(image=high_quality_image) assert exc.value.response.status_code == HTTPStatus.UNAUTHORIZED @@ -101,7 +104,8 @@ def test_inactive_project( high_quality_image: io.BytesIO, ) -> None: """ - An ``InactiveProject`` exception is raised when querying an inactive database. + An ``InactiveProject`` exception is raised when querying an inactive + database. """ database = VuforiaDatabase(state=States.PROJECT_INACTIVE) with MockVWS() as mock: diff --git a/tests/test_query.py b/tests/test_query.py index 9c7913c4..e229cf95 100644 --- a/tests/test_query.py +++ b/tests/test_query.py @@ -2,7 +2,6 @@ Tests for the ``CloudRecoService`` querying functionality. """ - import io import uuid from typing import BinaryIO @@ -59,7 +58,8 @@ class TestCustomBaseVWQURL: @staticmethod def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None: """ - It is possible to use query a target to a database under a custom VWQ URL. + It is possible to use query a target to a database under a custom VWQ + URL. """ base_vwq_url = "http://example.com" with MockVWS(base_vwq_url=base_vwq_url) as mock: @@ -210,8 +210,8 @@ def test_top( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.TOP`` is given, target data is only returned - in the top match. + When ``CloudRecoIncludeTargetData.TOP`` is given, target data is only + returned in the top match. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, @@ -244,8 +244,8 @@ def test_none( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.NONE`` is given, target data is not returned - in any match. + When ``CloudRecoIncludeTargetData.NONE`` is given, target data is not + returned in any match. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, @@ -278,8 +278,8 @@ def test_all( image: io.BytesIO | BinaryIO, ) -> None: """ - When ``CloudRecoIncludeTargetData.ALL`` is given, target data is returned in all - matches. + When ``CloudRecoIncludeTargetData.ALL`` is given, target data is + returned in all matches. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, diff --git a/tests/test_vws.py b/tests/test_vws.py index 25af0c0e..e16eff55 100644 --- a/tests/test_vws.py +++ b/tests/test_vws.py @@ -2,7 +2,6 @@ Tests for helper functions for managing a Vuforia database. """ - import base64 import datetime import io @@ -106,7 +105,8 @@ class TestCustomBaseVWSURL: @staticmethod def test_custom_base_url(image: io.BytesIO | BinaryIO) -> None: """ - It is possible to use add a target to a database under a custom VWS URL. + It is possible to use add a target to a database under a custom VWS + URL. """ base_vws_url = "http://example.com" with MockVWS(base_vws_url=base_vws_url) as mock: @@ -229,8 +229,12 @@ def test_get_target_summary_report( assert report.active_flag == expected_report.active_flag assert report.tracking_rating == expected_report.tracking_rating assert report.total_recos == expected_report.total_recos - assert report.current_month_recos == expected_report.current_month_recos - assert report.previous_month_recos == expected_report.previous_month_recos + assert ( + report.current_month_recos == expected_report.current_month_recos + ) + assert ( + report.previous_month_recos == expected_report.previous_month_recos + ) assert report == expected_report @@ -263,11 +267,15 @@ def test_get_target(vws_client: VWS) -> None: ) assert report.active_images == expected_report.active_images - assert report.current_month_recos == expected_report.current_month_recos + assert ( + report.current_month_recos == expected_report.current_month_recos + ) assert report.failed_images == expected_report.failed_images assert report.inactive_images == expected_report.inactive_images assert report.name == expected_report.name - assert report.previous_month_recos == expected_report.previous_month_recos + assert ( + report.previous_month_recos == expected_report.previous_month_recos + ) assert report.processing_images == expected_report.processing_images assert report.reco_threshold == expected_report.reco_threshold assert report.request_quota == expected_report.request_quota @@ -311,15 +319,23 @@ def test_get_target_record( assert result.target_record == expected_target_record - assert result.target_record.target_id == expected_target_record.target_id - assert result.target_record.active_flag == expected_target_record.active_flag + assert ( + result.target_record.target_id == expected_target_record.target_id + ) + assert ( + result.target_record.active_flag + == expected_target_record.active_flag + ) assert result.target_record.name == expected_target_record.name assert result.target_record.width == expected_target_record.width assert ( result.target_record.tracking_rating == expected_target_record.tracking_rating ) - assert result.target_record.reco_rating == expected_target_record.reco_rating + assert ( + result.target_record.reco_rating + == expected_target_record.reco_rating + ) assert result.status == TargetStatuses.PROCESSING @@ -498,7 +514,9 @@ def test_custom_timeout(image: io.BytesIO | BinaryIO) -> None: report = vws_client.get_target_summary_report(target_id=target_id) assert report.status == TargetStatuses.PROCESSING - with pytest.raises(expected_exception=TargetProcessingTimeoutError): + with pytest.raises( + expected_exception=TargetProcessingTimeoutError + ): vws_client.wait_for_target_processed( target_id=target_id, timeout_seconds=0.1, diff --git a/tests/test_vws_exceptions.py b/tests/test_vws_exceptions.py index d172042b..86da6604 100644 --- a/tests/test_vws_exceptions.py +++ b/tests/test_vws_exceptions.py @@ -2,7 +2,6 @@ Tests for VWS exceptions. """ - import io import uuid from http import HTTPStatus @@ -43,7 +42,8 @@ def test_image_too_large( png_too_large: io.BytesIO | io.BufferedRandom, ) -> None: """ - When giving an image which is too large, an ``ImageTooLarge`` exception is raised. + When giving an image which is too large, an ``ImageTooLarge`` exception is + raised. """ with pytest.raises(expected_exception=ImageTooLargeError) as exc: vws_client.add_target( @@ -59,8 +59,8 @@ def test_image_too_large( def test_invalid_given_id(vws_client: VWS) -> None: """ - Giving an invalid ID to a helper which requires a target ID to be given causes an - ``UnknownTarget`` exception to be raised. + Giving an invalid ID to a helper which requires a target ID to be given + causes an ``UnknownTarget`` exception to be raised. """ target_id = "12345abc" with pytest.raises(expected_exception=UnknownTargetError) as exc: @@ -71,7 +71,8 @@ def test_invalid_given_id(vws_client: VWS) -> None: def test_add_bad_name(vws_client: VWS, high_quality_image: io.BytesIO) -> None: """ - When a name with a bad character is given, a ``ServerError`` exception is raised. + When a name with a bad character is given, a ``ServerError`` exception is + raised. """ max_char_value = 65535 bad_name = chr(max_char_value + 1) @@ -140,8 +141,8 @@ def test_target_name_exist( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetNameExist`` exception is raised after adding two targets with the same - name. + A ``TargetNameExist`` exception is raised after adding two targets with the + same name. """ vws_client.add_target( name="x", @@ -195,8 +196,8 @@ def test_target_status_processing( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetStatusProcessing`` exception is raised if trying to delete a target which - is processing. + A ``TargetStatusProcessing`` exception is raised if trying to delete a + target which is processing. """ target_id = vws_client.add_target( name="x", @@ -218,7 +219,8 @@ def test_metadata_too_large( high_quality_image: io.BytesIO, ) -> None: """ - A ``MetadataTooLarge`` exception is raised if the metadata given is too large. + A ``MetadataTooLarge`` exception is raised if the metadata given is too + large. """ with pytest.raises(expected_exception=MetadataTooLargeError) as exc: vws_client.add_target( @@ -237,8 +239,8 @@ def test_request_time_too_skewed( high_quality_image: io.BytesIO, ) -> None: """ - A ``RequestTimeTooSkewed`` exception is raised when the request time is more than - five minutes different from the server time. + A ``RequestTimeTooSkewed`` exception is raised when the request time is + more than five minutes different from the server time. """ target_id = vws_client.add_target( name="x", @@ -271,8 +273,9 @@ def test_authentication_failure( high_quality_image: io.BytesIO, ) -> None: """ - An ``AuthenticationFailure`` exception is raised when the server access key exists - but the server secret key is incorrect, or when a client key is incorrect. + An ``AuthenticationFailure`` exception is raised when the server access key + exists but the server secret key is incorrect, or when a client key is + incorrect. """ database = VuforiaDatabase() @@ -284,7 +287,9 @@ def test_authentication_failure( with MockVWS() as mock: mock.add_database(database=database) - with pytest.raises(expected_exception=AuthenticationFailureError) as exc: + with pytest.raises( + expected_exception=AuthenticationFailureError + ) as exc: vws_client.add_target( name="x", width=1, @@ -301,8 +306,8 @@ def test_target_status_not_success( high_quality_image: io.BytesIO, ) -> None: """ - A ``TargetStatusNotSuccess`` exception is raised when updating a target which has a - status which is not "Success". + A ``TargetStatusNotSuccess`` exception is raised when updating a target + which has a status which is not "Success". """ target_id = vws_client.add_target( name="x", From 97816455b8c744deb99b8bece419aae967b6aee7 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 26 Nov 2025 20:14:42 +0000 Subject: [PATCH 5/5] Run latest docformatter --- pyproject.toml | 2 +- src/vws/exceptions/vws_exceptions.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 88a691c4..548388e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -108,7 +108,7 @@ universal = true version_scheme = "post-release" [tool.uv.sources] -docformatter = { git = "https://github.com/finswimmer/docformatter.git", branch = "fix-new-lines" } +docformatter = { git = "https://github.com/finswimmer/docformatter.git", rev = "948c28a5d43106bad3ec796fdf26f87cbdaee085" } [tool.ruff] line-length = 79 diff --git a/src/vws/exceptions/vws_exceptions.py b/src/vws/exceptions/vws_exceptions.py index 0ed136c5..48222376 100644 --- a/src/vws/exceptions/vws_exceptions.py +++ b/src/vws/exceptions/vws_exceptions.py @@ -52,6 +52,7 @@ class AuthenticationFailureError(VWSError): 'AuthenticationFailure'. """ + # See https://github.com/VWS-Python/vws-python/issues/822. @beartype class RequestQuotaReachedError(VWSError): # pragma: no cover @@ -87,6 +88,7 @@ class DateRangeError(VWSError): # pragma: no cover 'DateRangeError'. """ + # This is not simulated by the mock. @beartype class TargetQuotaReachedError(VWSError): # pragma: no cover @@ -95,6 +97,7 @@ class TargetQuotaReachedError(VWSError): # pragma: no cover 'TargetQuotaReached'. """ + # This is not simulated by the mock. @beartype class ProjectSuspendedError(VWSError): # pragma: no cover @@ -103,6 +106,7 @@ class ProjectSuspendedError(VWSError): # pragma: no cover 'ProjectSuspended'. """ + # This is not simulated by the mock. @beartype class ProjectHasNoAPIAccessError(VWSError): # pragma: no cover