From a8616a28c2b4144162d03b45ecd93841814f049b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 26 Apr 2024 11:43:04 +0100 Subject: [PATCH 001/331] Use match statement rather than dict in Enum conversions Pros: * Pyright tells us when we have missed a case * We can use multi-line statements for each case Cons: * We need to handle the type error "Missing return statement" --- src/mock_vws/_flask_server/target_manager.py | 16 +++++++++------- src/mock_vws/_flask_server/vwq.py | 14 +++++++------- src/mock_vws/_flask_server/vws.py | 14 +++++++------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index 3790016b1..55f067407 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -38,13 +38,15 @@ class _TargetRaterChoice(StrEnum): def to_target_rater(self) -> TargetTrackingRater: """Get the target rater.""" - rater = { - _TargetRaterChoice.BRISQUE: BrisqueTargetTrackingRater(), - _TargetRaterChoice.PERFECT: HardcodedTargetTrackingRater(rating=5), - _TargetRaterChoice.RANDOM: RandomTargetTrackingRater(), - }[self] - assert isinstance(rater, TargetTrackingRater) - return rater + match self: + case self.BRISQUE: + return BrisqueTargetTrackingRater() + case self.PERFECT: + HardcodedTargetTrackingRater(rating=5) + case self.RANDOM: + return RandomTargetTrackingRater() + + raise ValueError # pragma: no cover class TargetManagerSettings(BaseSettings): diff --git a/src/mock_vws/_flask_server/vwq.py b/src/mock_vws/_flask_server/vwq.py index 9eb32abf4..173c9425d 100644 --- a/src/mock_vws/_flask_server/vwq.py +++ b/src/mock_vws/_flask_server/vwq.py @@ -39,13 +39,13 @@ class _ImageMatcherChoice(StrEnum): def to_image_matcher(self) -> ImageMatcher: """Get the image matcher.""" - ssim_matcher = StructuralSimilarityMatcher() - matcher = { - _ImageMatcherChoice.EXACT: ExactMatcher(), - _ImageMatcherChoice.STRUCTURAL_SIMILARITY: ssim_matcher, - }[self] - assert isinstance(matcher, ImageMatcher) - return matcher + match self: + case self.EXACT: + return ExactMatcher() + case self.STRUCTURAL_SIMILARITY: + return StructuralSimilarityMatcher() + + raise ValueError # pragma: no cover class VWQSettings(BaseSettings): diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index 7dc277fab..6b126de5c 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -53,13 +53,13 @@ class _ImageMatcherChoice(StrEnum): def to_image_matcher(self) -> ImageMatcher: """Get the image matcher.""" - ssim_matcher = StructuralSimilarityMatcher() - matcher = { - _ImageMatcherChoice.EXACT: ExactMatcher(), - _ImageMatcherChoice.STRUCTURAL_SIMILARITY: ssim_matcher, - }[self] - assert isinstance(matcher, ImageMatcher) - return matcher + match self: + case self.EXACT: + return ExactMatcher() + case self.STRUCTURAL_SIMILARITY: + return StructuralSimilarityMatcher() + + raise ValueError # pragma: no cover class VWSSettings(BaseSettings): From c953138d15e5880795f35900e562a99d6d7b6374 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Aug 2024 04:53:25 +0000 Subject: [PATCH 002/331] Update numpy requirement from <2.0.0 to <3.0.0 Updates the requirements on [numpy](https://github.com/numpy/numpy) to permit the latest version. - [Release notes](https://github.com/numpy/numpy/releases) - [Changelog](https://github.com/numpy/numpy/blob/main/doc/RELEASE_WALKTHROUGH.rst) - [Commits](https://github.com/numpy/numpy/compare/v0.2.0...v2.1.0) --- updated-dependencies: - dependency-name: numpy dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 97e334ba8..0f1d91aa6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,7 +40,7 @@ dependencies = [ "flask", # Pin numpy to avoid: # https://github.com/pytorch/pytorch/issues/128860 - "numpy<2.0.0", + "numpy<3.0.0", "pillow", "piq", "pydantic-settings", From 77cd415427f703a2df4a812bf87358f13f119e11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 05:23:21 +0000 Subject: [PATCH 003/331] Bump pylint from 3.2.6 to 3.2.7 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.2.6 to 3.2.7. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.2.6...v3.2.7) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6cd9ff3a0..64312e32b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ optional-dependencies.dev = [ "pre-commit==3.8.0", "pydocstyle==6.3", "pyenchant==3.2.2", - "pylint==3.2.6", + "pylint==3.2.7", "pyproject-fmt==2.2.1", "pyright==1.1.378", "pyroma==4.2", From fe622458567c3724c68788f5796cf0ef66ed9aa7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 05:24:49 +0000 Subject: [PATCH 004/331] Bump vws-python from 2024.2.19 to 2024.9.2 Bumps [vws-python](https://github.com/VWS-Python/vws-python) from 2024.2.19 to 2024.9.2. - [Release notes](https://github.com/VWS-Python/vws-python/releases) - [Changelog](https://github.com/VWS-Python/vws-python/blob/main/CHANGELOG.rst) - [Commits](https://github.com/VWS-Python/vws-python/compare/2024.02.19...2024.09.02) --- updated-dependencies: - dependency-name: vws-python dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 64312e32b..377b64475 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ optional-dependencies.dev = [ "types-requests==2.32.0.20240712", "urllib3==2.2.2", "vulture==2.11", - "vws-python==2024.2.19", + "vws-python==2024.9.2", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] From cffe80d93998485b83a61e09681dc4f455a9b238 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 09:51:53 +0100 Subject: [PATCH 005/331] Update for VWS-Python changes --- docs/source/differences-to-vws.rst | 2 +- src/mock_vws/_constants.py | 22 +++++----- src/mock_vws/_flask_server/vws.py | 8 ++-- .../_query_validators/auth_validators.py | 10 ++--- .../content_length_validators.py | 6 +-- src/mock_vws/_query_validators/exceptions.py | 20 ++++----- .../_query_validators/image_validators.py | 23 +++++----- .../num_results_validators.py | 8 ++-- .../project_state_validators.py | 6 +-- .../mock_web_services_api.py | 8 ++-- .../_services_validators/auth_validators.py | 12 ++--- .../content_length_validators.py | 8 ++-- .../content_type_validators.py | 10 +++-- .../_services_validators/exceptions.py | 32 +++++++------- .../_services_validators/image_validators.py | 23 +++++----- .../metadata_validators.py | 6 +-- .../_services_validators/name_validators.py | 18 ++++---- .../project_state_validators.py | 8 ++-- .../_services_validators/target_validators.py | 8 ++-- tests/mock_vws/fixtures/vuforia_backends.py | 4 +- tests/mock_vws/test_add_target.py | 44 ++++++++++--------- tests/mock_vws/test_authorization_header.py | 12 ++--- tests/mock_vws/test_database_summary.py | 6 +-- tests/mock_vws/test_delete_target.py | 16 ++++--- tests/mock_vws/test_get_duplicates.py | 6 +-- tests/mock_vws/test_get_target.py | 6 +-- tests/mock_vws/test_query.py | 40 +++++++++-------- tests/mock_vws/test_target_list.py | 2 +- tests/mock_vws/test_target_summary.py | 6 +-- tests/mock_vws/test_update_target.py | 36 +++++++-------- tests/mock_vws/utils/retries.py | 4 +- tests/mock_vws/utils/too_many_requests.py | 7 +-- 32 files changed, 219 insertions(+), 208 deletions(-) diff --git a/docs/source/differences-to-vws.rst b/docs/source/differences-to-vws.rst index 86218f4eb..4794b2048 100644 --- a/docs/source/differences-to-vws.rst +++ b/docs/source/differences-to-vws.rst @@ -96,7 +96,7 @@ These are: * ``ProjectSuspended`` * ``RequestQuotaReached`` * ``TargetQuotaReached`` -* ``TooManyRequests`` +* ``TooManyRequestsError`` ``Content-Length`` headers -------------------------- diff --git a/src/mock_vws/_constants.py b/src/mock_vws/_constants.py index dc964520d..131bbb670 100644 --- a/src/mock_vws/_constants.py +++ b/src/mock_vws/_constants.py @@ -20,24 +20,24 @@ class ResultCodes(Enum): SUCCESS = "Success" TARGET_CREATED = "TargetCreated" - AUTHENTICATION_FAILURE = "AuthenticationFailure" + AUTHENTICATION_FAILURE = "AuthenticationFailureError" REQUEST_TIME_TOO_SKEWED = "RequestTimeTooSkewed" - TARGET_NAME_EXIST = "TargetNameExist" - UNKNOWN_TARGET = "UnknownTarget" - BAD_IMAGE = "BadImage" - IMAGE_TOO_LARGE = "ImageTooLarge" - METADATA_TOO_LARGE = "MetadataTooLarge" + TARGET_NAME_EXIST = "TargetNameExistError" + UNKNOWN_TARGET = "UnknownTargetError" + BAD_IMAGE = "BadImageError" + IMAGE_TOO_LARGE = "ImageTooLargeError" + METADATA_TOO_LARGE = "MetadataTooLargeError" # The documentation says "Start date is after the end date" but, at the # time of writing, I do not know how to trigger that, therefore this is not # tested. DATE_RANGE_ERROR = "DateRangeError" FAIL = "Fail" - TARGET_STATUS_PROCESSING = "TargetStatusProcessing" + TARGET_STATUS_PROCESSING = "TargetStatusProcessingError" REQUEST_QUOTA_REACHED = "RequestQuotaReached" - TARGET_STATUS_NOT_SUCCESS = "TargetStatusNotSuccess" - PROJECT_INACTIVE = "ProjectInactive" - INACTIVE_PROJECT = "InactiveProject" - TOO_MANY_REQUESTS = "TooManyRequests" + TARGET_STATUS_NOT_SUCCESS = "TargetStatusNotSuccessError" + PROJECT_INACTIVE = "ProjectInactiveError" + INACTIVE_PROJECT = "InactiveProjectError" + TOO_MANY_REQUESTS = "TooManyRequestsError" @beartype diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index d5913f479..db0fbd2b2 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -24,8 +24,8 @@ from mock_vws._services_validators import run_services_validators from mock_vws._services_validators.exceptions import ( FailError, - TargetStatusNotSuccessError, - TargetStatusProcessingError, + TargetStatusNotSuccessErrorError, + TargetStatusProcessingErrorError, ValidatorError, ) from mock_vws.database import VuforiaDatabase @@ -306,7 +306,7 @@ def delete_target(target_id: str) -> Response: ) if target.status == TargetStatuses.PROCESSING.value: - raise TargetStatusProcessingError + raise TargetStatusProcessingErrorError databases_url = f"{settings.target_manager_base_url}/databases" requests.delete( @@ -572,7 +572,7 @@ def update_target(target_id: str) -> Response: ) if target.status != TargetStatuses.SUCCESS.value: - raise TargetStatusNotSuccessError + raise TargetStatusNotSuccessErrorError update_values: dict[str, str | int | float | bool | None] = {} if "width" in request_json: diff --git a/src/mock_vws/_query_validators/auth_validators.py b/src/mock_vws/_query_validators/auth_validators.py index 054a82a78..6ddaed862 100644 --- a/src/mock_vws/_query_validators/auth_validators.py +++ b/src/mock_vws/_query_validators/auth_validators.py @@ -9,7 +9,7 @@ from mock_vws._database_matchers import get_database_matching_client_keys from mock_vws._query_validators.exceptions import ( - AuthenticationFailureError, + AuthenticationFailureErrorError, AuthHeaderMissingError, MalformedAuthHeaderError, ) @@ -75,7 +75,7 @@ def validate_client_key_exists( databases: All Vuforia databases. Raises: - AuthenticationFailureError: The client key is unknown. + AuthenticationFailureErrorError: The client key is unknown. """ header = request_headers["Authorization"] first_part, _ = header.split(sep=":") @@ -85,7 +85,7 @@ def validate_client_key_exists( return _LOGGER.warning(msg="The client key is unknown.") - raise AuthenticationFailureError + raise AuthenticationFailureErrorError @beartype @@ -129,7 +129,7 @@ def validate_authorization( databases: All Vuforia databases. Raises: - AuthenticationFailureError: The "Authorization" header is not as + AuthenticationFailureErrorError: The "Authorization" header is not as expected. """ try: @@ -144,4 +144,4 @@ def validate_authorization( _LOGGER.warning( msg="The authorization header does not match any databases.", ) - raise AuthenticationFailureError from exc + raise AuthenticationFailureErrorError from exc diff --git a/src/mock_vws/_query_validators/content_length_validators.py b/src/mock_vws/_query_validators/content_length_validators.py index 4abbf6bf0..933a73d2b 100644 --- a/src/mock_vws/_query_validators/content_length_validators.py +++ b/src/mock_vws/_query_validators/content_length_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._query_validators.exceptions import ( - AuthenticationFailureGoodFormattingError, + AuthenticationFailureErrorGoodFormattingError, ContentLengthHeaderNotIntError, ContentLengthHeaderTooLargeError, ) @@ -81,7 +81,7 @@ def validate_content_length_header_not_too_small( request_body: The body of the request. Raises: - AuthenticationFailureGoodFormattingError: The given content length + AuthenticationFailureErrorGoodFormattingError: The given content length header says that the content length is smaller than the body length. """ @@ -92,4 +92,4 @@ def validate_content_length_header_not_too_small( if given_content_length_value < body_length: _LOGGER.warning(msg="The Content-Length header is too small.") - raise AuthenticationFailureGoodFormattingError + raise AuthenticationFailureErrorGoodFormattingError diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index 8a39d468b..a0a6f0213 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -125,10 +125,10 @@ def __init__(self) -> None: @beartype -class BadImageError(ValidatorError): +class BadImageErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'BadImage'. + 'BadImageError'. """ def __init__(self) -> None: @@ -168,10 +168,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureError(ValidatorError): +class AuthenticationFailureErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailure'. + 'AuthenticationFailureError'. """ def __init__(self) -> None: @@ -211,10 +211,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureGoodFormattingError(ValidatorError): +class AuthenticationFailureErrorGoodFormattingError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailure' with a standard JSON formatting. + 'AuthenticationFailureError' with a standard JSON formatting. """ def __init__(self) -> None: @@ -380,10 +380,10 @@ def __init__(self) -> None: @beartype -class InactiveProjectError(ValidatorError): +class InactiveProjectErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'InactiveProject'. + 'InactiveProjectError'. """ def __init__(self) -> None: @@ -459,7 +459,7 @@ def __init__(self, given_value: str) -> None: @beartype -class MaxNumResultsOutOfRangeError(ValidatorError): +class MaxNumResultsOutOfRangeErrorError(ValidatorError): """ Exception raised when an integer value is given as the "max_num_results" field which is out of range. @@ -679,7 +679,7 @@ def __init__(self) -> None: @beartype -class RequestEntityTooLargeError(ValidatorError): +class RequestEntityTooLargeErrorError(ValidatorError): """ Exception raised when the given image file size is too large. """ diff --git a/src/mock_vws/_query_validators/image_validators.py b/src/mock_vws/_query_validators/image_validators.py index 7c5d2e1d8..299a836cc 100644 --- a/src/mock_vws/_query_validators/image_validators.py +++ b/src/mock_vws/_query_validators/image_validators.py @@ -12,9 +12,9 @@ from werkzeug.formparser import MultiPartParser from mock_vws._query_validators.exceptions import ( - BadImageError, + BadImageErrorError, ImageNotGivenError, - RequestEntityTooLargeError, + RequestEntityTooLargeErrorError, ) _LOGGER = logging.getLogger(name=__name__) @@ -66,7 +66,7 @@ def validate_image_file_size( request_body: The body of the request. Raises: - RequestEntityTooLargeError: The image file size is too large. + RequestEntityTooLargeErrorError: The image file size is too large. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -90,7 +90,7 @@ def validate_image_file_size( # See https://github.com/urllib3/urllib3/issues/2733. if len(image_value) > max_bytes: # pragma: no cover _LOGGER.warning(msg="The image file size is too large.") - raise RequestEntityTooLargeError + raise RequestEntityTooLargeErrorError @beartype @@ -107,8 +107,8 @@ def validate_image_dimensions( request_body: The body of the request. Raises: - BadImageError: The image is given and is not within the maximum width - and height limits. + BadImageErrorError: The image is given and is not within the maximum + width and height limits. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -129,7 +129,7 @@ def validate_image_dimensions( return _LOGGER.warning(msg="The image dimensions are too large.") - raise BadImageError + raise BadImageErrorError @beartype @@ -146,7 +146,8 @@ def validate_image_format( request_body: The body of the request. Raises: - BadImageError: The image is given and is not either a PNG or a JPEG. + BadImageErrorError: The image is given and is not either a PNG or a + JPEG. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -164,7 +165,7 @@ def validate_image_format( return _LOGGER.warning(msg="The image format is not PNG or JPEG.") - raise BadImageError + raise BadImageErrorError @beartype @@ -180,7 +181,7 @@ def validate_image_is_image( request_body: The body of the request. Raises: - BadImageError: Image data is given and it is not an image file. + BadImageErrorError: Image data is given and it is not an image file. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -198,4 +199,4 @@ def validate_image_is_image( Image.open(fp=image_file) except OSError as exc: _LOGGER.warning(msg="The image is not an image file.") - raise BadImageError from exc + raise BadImageErrorError from exc diff --git a/src/mock_vws/_query_validators/num_results_validators.py b/src/mock_vws/_query_validators/num_results_validators.py index 65705ae33..e4fce4a92 100644 --- a/src/mock_vws/_query_validators/num_results_validators.py +++ b/src/mock_vws/_query_validators/num_results_validators.py @@ -12,7 +12,7 @@ from mock_vws._query_validators.exceptions import ( InvalidMaxNumResultsError, - MaxNumResultsOutOfRangeError, + MaxNumResultsOutOfRangeErrorError, ) _LOGGER = logging.getLogger(name=__name__) @@ -35,8 +35,8 @@ def validate_max_num_results( Raises: InvalidMaxNumResultsError: The ``max_num_results`` given is not an integer less than or equal to the max integer in Java. - MaxNumResultsOutOfRangeError: The ``max_num_results`` given is not in - range. + MaxNumResultsOutOfRangeErrorError: The ``max_num_results`` given is + not in range. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -63,4 +63,4 @@ def validate_max_num_results( max_allowed_results = 50 if max_num_results_int < 1 or max_num_results_int > max_allowed_results: _LOGGER.warning(msg="The max_num_results field is out of range.") - raise MaxNumResultsOutOfRangeError(given_value=max_num_results) + raise MaxNumResultsOutOfRangeErrorError(given_value=max_num_results) diff --git a/src/mock_vws/_query_validators/project_state_validators.py b/src/mock_vws/_query_validators/project_state_validators.py index dccf202fc..187f3c718 100644 --- a/src/mock_vws/_query_validators/project_state_validators.py +++ b/src/mock_vws/_query_validators/project_state_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_client_keys -from mock_vws._query_validators.exceptions import InactiveProjectError +from mock_vws._query_validators.exceptions import InactiveProjectErrorError from mock_vws.database import VuforiaDatabase from mock_vws.states import States @@ -34,7 +34,7 @@ def validate_project_state( databases: All Vuforia databases. Raises: - InactiveProjectError: The project is inactive. + InactiveProjectErrorError: The project is inactive. """ database = get_database_matching_client_keys( request_headers=request_headers, @@ -48,4 +48,4 @@ def validate_project_state( return _LOGGER.warning(msg="The project is inactive.") - raise InactiveProjectError + raise InactiveProjectErrorError diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 36936c034..ce68e653b 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -25,8 +25,8 @@ from mock_vws._services_validators import run_services_validators from mock_vws._services_validators.exceptions import ( FailError, - TargetStatusNotSuccessError, - TargetStatusProcessingError, + TargetStatusNotSuccessErrorError, + TargetStatusProcessingErrorError, ValidatorError, ) from mock_vws.image_matchers import ImageMatcher @@ -244,7 +244,7 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: target = database.get_target(target_id=target_id) if target.status == TargetStatuses.PROCESSING.value: - target_processing_exception = TargetStatusProcessingError() + target_processing_exception = TargetStatusProcessingErrorError() return ( target_processing_exception.status_code, target_processing_exception.headers, @@ -577,7 +577,7 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: ) if target.status != TargetStatuses.SUCCESS.value: - exception = TargetStatusNotSuccessError() + exception = TargetStatusNotSuccessErrorError() return ( exception.status_code, exception.headers, diff --git a/src/mock_vws/_services_validators/auth_validators.py b/src/mock_vws/_services_validators/auth_validators.py index e3ec36d23..f0d4bb45b 100644 --- a/src/mock_vws/_services_validators/auth_validators.py +++ b/src/mock_vws/_services_validators/auth_validators.py @@ -10,7 +10,7 @@ from mock_vws._database_matchers import get_database_matching_server_keys from mock_vws._services_validators.exceptions import ( - AuthenticationFailureError, + AuthenticationFailureErrorError, FailError, ) from mock_vws.database import VuforiaDatabase @@ -27,11 +27,11 @@ def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None: request_headers: The headers sent with the request. Raises: - AuthenticationFailureError: There is no "Authorization" header. + AuthenticationFailureErrorError: There is no "Authorization" header. """ if "Authorization" not in request_headers: _LOGGER.warning(msg="There is no authorization header.") - raise AuthenticationFailureError + raise AuthenticationFailureErrorError @beartype @@ -108,8 +108,8 @@ def validate_authorization( databases: All Vuforia databases. Raises: - AuthenticationFailureError: No database matches the given authorization - header. + AuthenticationFailureErrorError: No database matches the given + authorization header. """ try: get_database_matching_server_keys( @@ -123,4 +123,4 @@ def validate_authorization( _LOGGER.warning( msg="No database matches the given authorization header.", ) - raise AuthenticationFailureError from exc + raise AuthenticationFailureErrorError from exc diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index 88f3e451d..80b3eb603 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._services_validators.exceptions import ( - AuthenticationFailureError, + AuthenticationFailureErrorError, ContentLengthHeaderNotIntError, ContentLengthHeaderTooLargeError, ) @@ -83,8 +83,8 @@ def validate_content_length_header_not_too_small( request_body: The body of the request. Raises: - AuthenticationFailureError: The given content length header says that - the content length is smaller than the body length. + AuthenticationFailureErrorError: The given content length header says + that the content length is smaller than the body length. """ body_length = len(request_body) given_content_length = request_headers.get("Content-Length", body_length) @@ -92,4 +92,4 @@ def validate_content_length_header_not_too_small( if given_content_length_value < body_length: _LOGGER.warning(msg="The Content-Length header is too small.") - raise AuthenticationFailureError + raise AuthenticationFailureErrorError diff --git a/src/mock_vws/_services_validators/content_type_validators.py b/src/mock_vws/_services_validators/content_type_validators.py index 6afa606dc..ad01448c4 100644 --- a/src/mock_vws/_services_validators/content_type_validators.py +++ b/src/mock_vws/_services_validators/content_type_validators.py @@ -8,7 +8,9 @@ from beartype import beartype -from mock_vws._services_validators.exceptions import AuthenticationFailureError +from mock_vws._services_validators.exceptions import ( + AuthenticationFailureErrorError, +) _LOGGER = logging.getLogger(name=__name__) @@ -27,8 +29,8 @@ def validate_content_type_header_given( request_method: The HTTP method of the request. Raises: - AuthenticationFailureError: No ``Content-Type`` header is given and the - request requires one. + AuthenticationFailureErrorError: No ``Content-Type`` header is given + and the request requires one. """ request_needs_content_type = bool( request_method in {HTTPMethod.POST, HTTPMethod.PUT}, @@ -37,4 +39,4 @@ def validate_content_type_header_given( return _LOGGER.warning(msg="No Content-Type header is given.") - raise AuthenticationFailureError + raise AuthenticationFailureErrorError diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index f528f1bf0..3b9947825 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -26,10 +26,10 @@ class ValidatorError(Exception): @beartype -class UnknownTargetError(ValidatorError): +class UnknownTargetErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'UnknownTarget'. + 'UnknownTargetError'. """ def __init__(self) -> None: @@ -66,10 +66,10 @@ def __init__(self) -> None: @beartype -class ProjectInactiveError(ValidatorError): +class ProjectInactiveErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'ProjectInactive'. + 'ProjectInactiveError'. """ def __init__(self) -> None: @@ -106,10 +106,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureError(ValidatorError): +class AuthenticationFailureErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailure'. + 'AuthenticationFailureError'. """ def __init__(self) -> None: @@ -185,10 +185,10 @@ def __init__(self, *, status_code: HTTPStatus) -> None: @beartype -class MetadataTooLargeError(ValidatorError): +class MetadataTooLargeErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'MetadataTooLarge'. + 'MetadataTooLargeError'. """ def __init__(self) -> None: @@ -225,10 +225,10 @@ def __init__(self) -> None: @beartype -class TargetNameExistError(ValidatorError): +class TargetNameExistErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'TargetNameExist'. + 'TargetNameExistError'. """ def __init__(self) -> None: @@ -307,10 +307,10 @@ def __init__(self) -> None: @beartype -class BadImageError(ValidatorError): +class BadImageErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'BadImage'. + 'BadImageError'. """ def __init__(self) -> None: @@ -347,10 +347,10 @@ def __init__(self) -> None: @beartype -class ImageTooLargeError(ValidatorError): +class ImageTooLargeErrorError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'ImageTooLarge'. + 'ImageTooLargeError'. """ def __init__(self) -> None: @@ -529,7 +529,7 @@ def __init__(self) -> None: @beartype -class TargetStatusNotSuccessError(ValidatorError): +class TargetStatusNotSuccessErrorError(ValidatorError): """ Exception raised when trying to update a target that does not have a success status. @@ -569,7 +569,7 @@ def __init__(self) -> None: @beartype -class TargetStatusProcessingError(ValidatorError): +class TargetStatusProcessingErrorError(ValidatorError): """ Exception raised when trying to delete a target which is processing. """ diff --git a/src/mock_vws/_services_validators/image_validators.py b/src/mock_vws/_services_validators/image_validators.py index 8927b7986..2847af218 100644 --- a/src/mock_vws/_services_validators/image_validators.py +++ b/src/mock_vws/_services_validators/image_validators.py @@ -13,9 +13,9 @@ from mock_vws._base64_decoding import decode_base64 from mock_vws._services_validators.exceptions import ( - BadImageError, + BadImageErrorError, FailError, - ImageTooLargeError, + ImageTooLargeErrorError, ) _LOGGER = logging.getLogger(name=__name__) @@ -30,7 +30,8 @@ def validate_image_format(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageError: The image is given and is not either a PNG or a JPEG. + BadImageErrorError: The image is given and is not either a PNG or a + JPEG. """ if not request_body: return @@ -49,7 +50,7 @@ def validate_image_format(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The image is not a PNG or JPEG.") - raise BadImageError + raise BadImageErrorError @beartype @@ -61,7 +62,7 @@ def validate_image_color_space(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageError: The image is given and is not in either the RGB or + BadImageErrorError: The image is given and is not in either the RGB or greyscale color space. """ if not request_body: @@ -83,7 +84,7 @@ def validate_image_color_space(*, request_body: bytes) -> None: _LOGGER.warning( msg="The image is not in the RGB or greyscale color space.", ) - raise BadImageError + raise BadImageErrorError @beartype @@ -95,8 +96,8 @@ def validate_image_size(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - ImageTooLargeError: The image is given and is not under a certain file - size threshold. + ImageTooLargeErrorError: The image is given and is not under a + certain file size threshold. """ if not request_body: return @@ -114,7 +115,7 @@ def validate_image_size(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The image is too large.") - raise ImageTooLargeError + raise ImageTooLargeErrorError @beartype @@ -126,7 +127,7 @@ def validate_image_is_image(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageError: Image data is given and it is not an image file. + BadImageErrorError: Image data is given and it is not an image file. """ if not request_body: return @@ -143,7 +144,7 @@ def validate_image_is_image(*, request_body: bytes) -> None: try: Image.open(fp=image_file) except OSError as exc: - raise BadImageError from exc + raise BadImageErrorError from exc @beartype diff --git a/src/mock_vws/_services_validators/metadata_validators.py b/src/mock_vws/_services_validators/metadata_validators.py index b8b81deb1..9d90df0a1 100644 --- a/src/mock_vws/_services_validators/metadata_validators.py +++ b/src/mock_vws/_services_validators/metadata_validators.py @@ -12,7 +12,7 @@ from mock_vws._base64_decoding import decode_base64 from mock_vws._services_validators.exceptions import ( FailError, - MetadataTooLargeError, + MetadataTooLargeErrorError, ) _LOGGER = logging.getLogger(name=__name__) @@ -28,7 +28,7 @@ def validate_metadata_size(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - MetadataTooLargeError: Application metadata is given and it is too + MetadataTooLargeErrorError: Application metadata is given and it is too large. """ if not request_body: @@ -46,7 +46,7 @@ def validate_metadata_size(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The application metadata is too large.") - raise MetadataTooLargeError + raise MetadataTooLargeErrorError @beartype diff --git a/src/mock_vws/_services_validators/name_validators.py b/src/mock_vws/_services_validators/name_validators.py index f11de3cd6..09dee37b4 100644 --- a/src/mock_vws/_services_validators/name_validators.py +++ b/src/mock_vws/_services_validators/name_validators.py @@ -13,7 +13,7 @@ from mock_vws._services_validators.exceptions import ( FailError, OopsErrorOccurredResponseError, - TargetNameExistError, + TargetNameExistErrorError, ) from mock_vws.database import VuforiaDatabase @@ -38,8 +38,8 @@ def validate_name_characters_in_range( Raises: OopsErrorOccurredResponseError: Characters are out of range and the request is trying to make a new target. - TargetNameExistError: Characters are out of range and the request is - for another endpoint. + TargetNameExistErrorError: Characters are out of range and the request + is for another endpoint. """ if not request_body: return @@ -59,7 +59,7 @@ def validate_name_characters_in_range( raise OopsErrorOccurredResponseError _LOGGER.warning(msg="Characters are out of range.") - raise TargetNameExistError + raise TargetNameExistErrorError @beartype @@ -138,7 +138,7 @@ def validate_name_does_not_exist_new_target( request_path: The path to the endpoint. Raises: - TargetNameExistError: The target name already exists. + TargetNameExistErrorError: The target name already exists. """ if not request_body: return @@ -172,7 +172,7 @@ def validate_name_does_not_exist_new_target( return _LOGGER.warning(msg="Target name already exists.") - raise TargetNameExistError + raise TargetNameExistErrorError @beartype @@ -196,8 +196,8 @@ def validate_name_does_not_exist_existing_target( request_path: The path to the endpoint. Raises: - TargetNameExistError: The target name is not the same as the name of - the target being updated but it is the same as another target. + TargetNameExistErrorError: The target name is not the same as the name + of the target being updated but it is the same as another target. """ if not request_body: return @@ -236,4 +236,4 @@ def validate_name_does_not_exist_existing_target( return _LOGGER.warning(msg="Name already exists for another target.") - raise TargetNameExistError + raise TargetNameExistErrorError diff --git a/src/mock_vws/_services_validators/project_state_validators.py b/src/mock_vws/_services_validators/project_state_validators.py index cd21bebee..2ebca78a3 100644 --- a/src/mock_vws/_services_validators/project_state_validators.py +++ b/src/mock_vws/_services_validators/project_state_validators.py @@ -9,7 +9,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_server_keys -from mock_vws._services_validators.exceptions import ProjectInactiveError +from mock_vws._services_validators.exceptions import ProjectInactiveErrorError from mock_vws.database import VuforiaDatabase from mock_vws.states import States @@ -36,8 +36,8 @@ def validate_project_state( databases: All Vuforia databases. Raises: - ProjectInactiveError: The project is inactive and this endpoint does - not work with inactive projects. + ProjectInactiveErrorError: The project is inactive and this endpoint + does not work with inactive projects. """ database = get_database_matching_server_keys( request_headers=request_headers, @@ -54,4 +54,4 @@ def validate_project_state( return _LOGGER.warning(msg="The project is inactive.") - raise ProjectInactiveError + raise ProjectInactiveErrorError diff --git a/src/mock_vws/_services_validators/target_validators.py b/src/mock_vws/_services_validators/target_validators.py index 11bb4df9c..d078f122c 100644 --- a/src/mock_vws/_services_validators/target_validators.py +++ b/src/mock_vws/_services_validators/target_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_server_keys -from mock_vws._services_validators.exceptions import UnknownTargetError +from mock_vws._services_validators.exceptions import UnknownTargetErrorError from mock_vws.database import VuforiaDatabase _LOGGER = logging.getLogger(name=__name__) @@ -35,8 +35,8 @@ def validate_target_id_exists( databases: All Vuforia databases. Raises: - UnknownTargetError: There are no matching targets for a given target - ID. + UnknownTargetErrorError: There are no matching targets for a given + target ID. """ split_path = request_path.split(sep="/") @@ -61,4 +61,4 @@ def validate_target_id_exists( ) except ValueError as exc: _LOGGER.warning('The target ID "%s" does not exist.', target_id) - raise UnknownTargetError from exc + raise UnknownTargetErrorError from exc diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index 7f1df5f25..dae00c333 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -14,7 +14,7 @@ from requests_mock_flask import add_flask_app_to_mock from vws import VWS from vws.exceptions.vws_exceptions import ( - TargetStatusNotSuccess, + TargetStatusNotSuccessError, ) from mock_vws import MockVWS @@ -54,7 +54,7 @@ def _delete_all_targets(*, database_keys: VuforiaDatabase) -> None: ) # Even deleted targets can be matched by a query for a few seconds so # we change the target to inactive before deleting it. - with contextlib.suppress(TargetStatusNotSuccess): + with contextlib.suppress(TargetStatusNotSuccessError): vws_client.update_target(target_id=target, active_flag=False) vws_client.wait_for_target_processed(target_id=target) vws_client.delete_target(target_id=target) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index fdb627eac..45fda5753 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -16,15 +16,17 @@ from dirty_equals import IsInstance from requests.structures import CaseInsensitiveDict from vws import VWS -from vws.exceptions.custom_exceptions import OopsAnErrorOccurredPossiblyBadName +from vws.exceptions.custom_exceptions import ( + OopsAnErrorOccurredPossiblyBadNameError, +) from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import ( - BadImage, - Fail, - ImageTooLarge, - MetadataTooLarge, - ProjectInactive, - TargetNameExist, + BadImageError, + FailError, + ImageTooLargeError, + MetadataTooLargeError, + ProjectInactiveError, + TargetNameExistError, ) from vws_auth_tools import authorization_header, rfc_1123_date @@ -387,7 +389,7 @@ def test_name_invalid( """ if status_code == HTTPStatus.INTERNAL_SERVER_ERROR: with pytest.raises( - expected_exception=OopsAnErrorOccurredPossiblyBadName, + expected_exception=OopsAnErrorOccurredPossiblyBadNameError, ) as oops_exc: vws_client.add_target( name=name, # type: ignore[arg-type] @@ -400,7 +402,7 @@ def test_name_invalid( _assert_oops_response(response=oops_exc.value.response) return - with pytest.raises(expected_exception=Fail) as exc: + with pytest.raises(expected_exception=FailError) as exc: vws_client.add_target( name=name, # type: ignore[arg-type] width=1, @@ -430,7 +432,7 @@ def test_existing_target_name( active_flag=True, ) - with pytest.raises(expected_exception=TargetNameExist) as exc: + with pytest.raises(expected_exception=TargetNameExistError) as exc: vws_client.add_target( name="example_name", width=1, @@ -507,7 +509,7 @@ def test_bad_image_format_or_color_space( a JPEG or PNG file is given, or if the given image is not in the greyscale or RGB color space. """ - with pytest.raises(expected_exception=BadImage) as exc: + with pytest.raises(expected_exception=BadImageError) as exc: vws_client.add_target( name="example_name", width=1, @@ -541,8 +543,8 @@ def test_corrupted( @staticmethod def test_image_file_size_too_large(vws_client: VWS) -> None: """ - An ``ImageTooLarge`` result is returned if the image file size is above - a certain threshold. + An ``ImageTooLargeError`` result is returned if the image file size is + above a certain threshold. """ max_bytes = 2.3 * 1024 * 1024 width = height = 886 @@ -590,7 +592,7 @@ def test_image_file_size_too_large(vws_client: VWS) -> None: assert image_content_size < max_bytes assert (image_content_size * 1.05) > max_bytes - with pytest.raises(expected_exception=ImageTooLarge) as exc: + with pytest.raises(expected_exception=ImageTooLargeError) as exc: vws_client.add_target( name="example_name_2", width=1, @@ -663,10 +665,10 @@ def test_not_base64_encoded_not_processable( @staticmethod def test_not_image(vws_client: VWS) -> None: """ - If the given image is not an image file then a `BadImage` result is - returned. + If the given image is not an image file then a `BadImageError` result + is returned. """ - with pytest.raises(expected_exception=BadImage) as exc: + with pytest.raises(expected_exception=BadImageError) as exc: vws_client.add_target( name="example_name", width=1, @@ -983,7 +985,7 @@ def test_not_base64_encoded_not_processable( Some strings which are not valid base64 encoded strings are not allowed as application metadata. """ - with pytest.raises(expected_exception=Fail) as exc: + with pytest.raises(expected_exception=FailError) as exc: vws_client.add_target( name="example", width=1, @@ -1010,7 +1012,7 @@ def test_metadata_too_large( metadata = b"a" * (_MAX_METADATA_BYTES + 1) metadata_encoded = base64.b64encode(s=metadata).decode("ascii") - with pytest.raises(expected_exception=MetadataTooLarge) as exc: + with pytest.raises(expected_exception=MetadataTooLargeError) as exc: vws_client.add_target( name="example", width=1, @@ -1027,7 +1029,7 @@ def test_metadata_too_large( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -1040,7 +1042,7 @@ def test_inactive_project( """ If the project is inactive, a FORBIDDEN response is returned. """ - with pytest.raises(expected_exception=ProjectInactive) as exc: + with pytest.raises(expected_exception=ProjectInactiveError) as exc: inactive_vws_client.add_target( name="example", width=1, diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index 52bcc7a1c..3dc966840 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -12,7 +12,7 @@ import requests from vws import VWS, CloudRecoService from vws.exceptions import cloud_reco_exceptions -from vws.exceptions.vws_exceptions import AuthenticationFailure, Fail +from vws.exceptions.vws_exceptions import AuthenticationFailureError, FailError from vws_auth_tools import rfc_1123_date from mock_vws._constants import ResultCodes @@ -209,7 +209,7 @@ def test_bad_access_key_services( server_secret_key=vuforia_database.server_secret_key, ) - with pytest.raises(expected_exception=Fail) as exc: + with pytest.raises(expected_exception=FailError) as exc: vws_client.get_target_record(target_id=uuid.uuid4().hex) assert exc.value.response.status_code == HTTPStatus.BAD_REQUEST @@ -229,7 +229,7 @@ def test_bad_access_key_query( ) with pytest.raises( - expected_exception=cloud_reco_exceptions.AuthenticationFailure + expected_exception=cloud_reco_exceptions.AuthenticationFailureError ) as exc: cloud_reco_client.query(image=high_quality_image) @@ -267,14 +267,14 @@ def test_bad_secret_key_services( ) -> None: """ If the server secret key given is incorrect, an - ``AuthenticationFailure`` response is returned. + ``AuthenticationFailureError`` response is returned. """ vws_client = VWS( server_access_key=vuforia_database.server_access_key, server_secret_key="example", ) - with pytest.raises(expected_exception=AuthenticationFailure): + with pytest.raises(expected_exception=AuthenticationFailureError): vws_client.get_target_record(target_id=uuid.uuid4().hex) @staticmethod @@ -292,7 +292,7 @@ def test_bad_secret_key_query( ) with pytest.raises( - expected_exception=cloud_reco_exceptions.AuthenticationFailure + expected_exception=cloud_reco_exceptions.AuthenticationFailureError ) as exc: cloud_reco_client.query(image=high_quality_image) diff --git a/tests/mock_vws/test_database_summary.py b/tests/mock_vws/test_database_summary.py index 91de33bd9..a75a900f7 100644 --- a/tests/mock_vws/test_database_summary.py +++ b/tests/mock_vws/test_database_summary.py @@ -14,7 +14,7 @@ from tenacity.stop import stop_after_delay from tenacity.wait import wait_fixed from vws import VWS, CloudRecoService -from vws.exceptions.vws_exceptions import Fail +from vws.exceptions.vws_exceptions import FailError from mock_vws import MockVWS from mock_vws.database import VuforiaDatabase @@ -375,7 +375,7 @@ def test_bad_target_request( report = vws_client.get_database_summary_report() original_request_usage = report.request_usage - with pytest.raises(expected_exception=Fail) as exc: + with pytest.raises(expected_exception=FailError) as exc: vws_client.add_target( name="example", width=-1, @@ -410,7 +410,7 @@ def test_query_request( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_delete_target.py b/tests/mock_vws/test_delete_target.py index de06137ad..8516d5d6a 100644 --- a/tests/mock_vws/test_delete_target.py +++ b/tests/mock_vws/test_delete_target.py @@ -7,9 +7,9 @@ import pytest from vws import VWS from vws.exceptions.vws_exceptions import ( - ProjectInactive, - TargetStatusProcessing, - UnknownTarget, + ProjectInactiveError, + TargetStatusProcessingError, + UnknownTargetError, ) from mock_vws._constants import ResultCodes @@ -33,7 +33,9 @@ def test_no_wait(target_id: str, vws_client: VWS) -> None: There is a race condition here - if the target goes into a success or fail state before the deletion attempt. """ - with pytest.raises(expected_exception=TargetStatusProcessing) as exc: + with pytest.raises( + expected_exception=TargetStatusProcessingError + ) as exc: vws_client.delete_target(target_id=target_id) assert_vws_failure( @@ -50,12 +52,12 @@ def test_processed(target_id: str, vws_client: VWS) -> None: vws_client.wait_for_target_processed(target_id=target_id) vws_client.delete_target(target_id=target_id) - with pytest.raises(expected_exception=UnknownTarget): + with pytest.raises(expected_exception=UnknownTargetError): vws_client.get_target_record(target_id=target_id) @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -66,7 +68,7 @@ def test_inactive_project(inactive_vws_client: VWS) -> None: If the project is inactive, a FORBIDDEN response is returned. """ target_id = "abc12345a" - with pytest.raises(expected_exception=ProjectInactive) as exc: + with pytest.raises(expected_exception=ProjectInactiveError) as exc: inactive_vws_client.delete_target(target_id=target_id) assert_vws_failure( diff --git a/tests/mock_vws/test_get_duplicates.py b/tests/mock_vws/test_get_duplicates.py index 2661d903a..ffa3ae9ef 100644 --- a/tests/mock_vws/test_get_duplicates.py +++ b/tests/mock_vws/test_get_duplicates.py @@ -9,7 +9,7 @@ import pytest from PIL import Image from vws import VWS -from vws.exceptions.vws_exceptions import ProjectInactive +from vws.exceptions.vws_exceptions import ProjectInactiveError from vws.reports import TargetStatuses @@ -254,7 +254,7 @@ def test_processing( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -264,7 +264,7 @@ def test_inactive_project(inactive_vws_client: VWS) -> None: """ If the project is inactive, a FORBIDDEN response is returned. """ - with pytest.raises(expected_exception=ProjectInactive): + with pytest.raises(expected_exception=ProjectInactiveError): inactive_vws_client.get_duplicate_targets( target_id=uuid.uuid4().hex, ) diff --git a/tests/mock_vws/test_get_target.py b/tests/mock_vws/test_get_target.py index 9b9dcf04f..be137c478 100644 --- a/tests/mock_vws/test_get_target.py +++ b/tests/mock_vws/test_get_target.py @@ -9,7 +9,7 @@ import pytest from vws import VWS -from vws.exceptions.vws_exceptions import UnknownTarget +from vws.exceptions.vws_exceptions import UnknownTargetError from vws.reports import TargetRecord, TargetStatuses @@ -172,7 +172,7 @@ def test_target_quality( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -182,5 +182,5 @@ def test_inactive_project(inactive_vws_client: VWS) -> None: """ The project's active state does not affect getting a target. """ - with pytest.raises(expected_exception=UnknownTarget): + with pytest.raises(expected_exception=UnknownTargetError): inactive_vws_client.get_target_record(target_id=uuid.uuid4().hex) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index eab124550..055655c87 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -30,11 +30,11 @@ from urllib3.filepost import encode_multipart_formdata from vws import VWS, CloudRecoService from vws.exceptions.cloud_reco_exceptions import ( - BadImage, - InactiveProject, - MaxNumResultsOutOfRange, + BadImageError, + InactiveProjectError, + MaxNumResultsOutOfRangeError, ) -from vws.exceptions.custom_exceptions import RequestEntityTooLarge +from vws.exceptions.custom_exceptions import RequestEntityTooLargeError from vws.reports import TargetStatuses from vws_auth_tools import authorization_header, rfc_1123_date @@ -853,7 +853,7 @@ def test_out_of_range( maximum. """ with pytest.raises( - expected_exception=MaxNumResultsOutOfRange, + expected_exception=MaxNumResultsOutOfRangeError, ) as exc_info: cloud_reco_client.query( image=high_quality_image, @@ -1245,7 +1245,7 @@ def test_inactive( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestBadImage: +class TestBadImageError: """ Tests for bad images. """ @@ -1269,7 +1269,7 @@ def test_not_image(cloud_reco_client: CloudRecoService) -> None: """ not_image_data = b"not_image_data" - with pytest.raises(expected_exception=BadImage) as exc_info: + with pytest.raises(expected_exception=BadImageError) as exc_info: cloud_reco_client.query( image=io.BytesIO(initial_bytes=not_image_data) ) @@ -1292,7 +1292,7 @@ def test_not_image(cloud_reco_client: CloudRecoService) -> None: expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImage"' + f'"result_code":"BadImageError"' "}" ) assert response.text == expected_text @@ -1367,7 +1367,7 @@ def test_png( assert (image_content_size * 0.95) < max_bytes with pytest.raises( - expected_exception=RequestEntityTooLarge + expected_exception=RequestEntityTooLargeError ) as exc_info: cloud_reco_client.query(image=png_too_large) @@ -1446,7 +1446,7 @@ def test_jpeg( assert (image_content_size * 0.95) < max_bytes with pytest.raises( - expected_exception=RequestEntityTooLarge + expected_exception=RequestEntityTooLargeError ) as exc_info: cloud_reco_client.query(image=jpeg_too_large) @@ -1497,7 +1497,7 @@ def test_max_height( height=max_height + 1, ) - with pytest.raises(expected_exception=BadImage) as exc_info: + with pytest.raises(expected_exception=BadImageError) as exc_info: cloud_reco_client.query(image=png_too_tall) response = exc_info.value.response @@ -1520,7 +1520,7 @@ def test_max_height( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImage"' + f'"result_code":"BadImageError"' "}" ) assert response.text == expected_text @@ -1550,7 +1550,7 @@ def test_max_width(cloud_reco_client: CloudRecoService) -> None: height=height, ) - with pytest.raises(expected_exception=BadImage) as exc_info: + with pytest.raises(expected_exception=BadImageError) as exc_info: result = cloud_reco_client.query(image=png_too_wide) response = exc_info.value.response @@ -1572,7 +1572,7 @@ def test_max_width(cloud_reco_client: CloudRecoService) -> None: expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImage"' + f'"result_code":"BadImageError"' "}" ) assert response.text == expected_text @@ -1634,7 +1634,7 @@ def test_unsupported( pil_image.save(image_buffer, file_format) image_content = image_buffer.getvalue() - with pytest.raises(expected_exception=BadImage) as exc_info: + with pytest.raises(expected_exception=BadImageError) as exc_info: cloud_reco_client.query( image=io.BytesIO(initial_bytes=image_content) ) @@ -1657,7 +1657,7 @@ def test_unsupported( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImage"' + f'"result_code":"BadImageError"' "}" ) assert response.text == expected_text @@ -1964,7 +1964,7 @@ def test_date_formats( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -1977,7 +1977,9 @@ def test_inactive_project( """ If the project is inactive, a FORBIDDEN response is returned. """ - with pytest.raises(expected_exception=InactiveProject) as exc_info: + with pytest.raises( + expected_exception=InactiveProjectError + ) as exc_info: inactive_cloud_reco_client.query(image=high_quality_image) response = exc_info.value.response @@ -2000,7 +2002,7 @@ def test_inactive_project( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"InactiveProject"' + f'"result_code":"InactiveProjectError"' "}" ) assert response.text == expected_text diff --git a/tests/mock_vws/test_target_list.py b/tests/mock_vws/test_target_list.py index 3cc4ea27d..0def2e7fa 100644 --- a/tests/mock_vws/test_target_list.py +++ b/tests/mock_vws/test_target_list.py @@ -36,7 +36,7 @@ def test_deleted( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_target_summary.py b/tests/mock_vws/test_target_summary.py index 4a87d73ac..1d2f920af 100644 --- a/tests/mock_vws/test_target_summary.py +++ b/tests/mock_vws/test_target_summary.py @@ -9,7 +9,7 @@ import pytest from vws import VWS, CloudRecoService -from vws.exceptions.vws_exceptions import UnknownTarget +from vws.exceptions.vws_exceptions import UnknownTargetError from vws.reports import TargetStatuses from mock_vws.database import VuforiaDatabase @@ -158,7 +158,7 @@ def test_recognition( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -168,7 +168,7 @@ def test_inactive_project(inactive_vws_client: VWS) -> None: """ The project's active state does not affect getting a target. """ - with pytest.raises(expected_exception=UnknownTarget): + with pytest.raises(expected_exception=UnknownTargetError): inactive_vws_client.get_target_summary_report( target_id=uuid.uuid4().hex, ) diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 93cc176b3..6193f8fbf 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -14,12 +14,12 @@ import requests from vws import VWS from vws.exceptions.vws_exceptions import ( - BadImage, - Fail, - ImageTooLarge, - MetadataTooLarge, - ProjectInactive, - TargetNameExist, + BadImageError, + FailError, + ImageTooLargeError, + MetadataTooLargeError, + ProjectInactiveError, + TargetNameExistError, ) from vws.reports import TargetStatuses from vws_auth_tools import authorization_header, rfc_1123_date @@ -434,7 +434,7 @@ def test_not_base64_encoded_not_processable( """ vws_client.wait_for_target_processed(target_id=target_id) - with pytest.raises(expected_exception=Fail) as exc: + with pytest.raises(expected_exception=FailError) as exc: vws_client.update_target( target_id=target_id, application_metadata=not_base64_encoded_not_processable, @@ -456,7 +456,7 @@ def test_metadata_too_large(vws_client: VWS, target_id: str) -> None: metadata_encoded = base64.b64encode(s=metadata).decode("ascii") vws_client.wait_for_target_processed(target_id=target_id) - with pytest.raises(expected_exception=MetadataTooLarge) as exc: + with pytest.raises(expected_exception=MetadataTooLargeError) as exc: vws_client.update_target( target_id=target_id, application_metadata=metadata_encoded, @@ -594,7 +594,7 @@ def test_existing_target_name( vws_client.wait_for_target_processed(target_id=first_target_id) vws_client.wait_for_target_processed(target_id=second_target_id) - with pytest.raises(expected_exception=TargetNameExist) as exc: + with pytest.raises(expected_exception=TargetNameExistError) as exc: vws_client.update_target( target_id=second_target_id, name=first_target_name, @@ -667,7 +667,7 @@ def test_bad_image_format_or_color_space( RGB color space. """ vws_client.wait_for_target_processed(target_id=target_id) - with pytest.raises(expected_exception=BadImage) as exc: + with pytest.raises(expected_exception=BadImageError) as exc: vws_client.update_target(target_id=target_id, image=bad_image_file) status_code = exc.value.response.status_code @@ -691,8 +691,8 @@ def test_corrupted( @staticmethod def test_image_too_large(target_id: str, vws_client: VWS) -> None: """ - An `ImageTooLarge` result is returned if the image is above a certain - threshold. + An `ImageTooLargeError` result is returned if the image is above a + certain threshold. """ max_bytes = 2.3 * 1024 * 1024 width = height = 886 @@ -738,7 +738,7 @@ def test_image_too_large(target_id: str, vws_client: VWS) -> None: assert image_content_size < max_bytes assert (image_content_size * 1.05) > max_bytes - with pytest.raises(expected_exception=ImageTooLarge) as exc: + with pytest.raises(expected_exception=ImageTooLargeError) as exc: vws_client.update_target(target_id=target_id, image=png_too_large) assert_vws_failure( @@ -803,12 +803,12 @@ def test_not_base64_encoded_not_processable( @staticmethod def test_not_image(target_id: str, vws_client: VWS) -> None: """ - If the given image is not an image file then a `BadImage` result is - returned. + If the given image is not an image file then a `BadImageError` result + is returned. """ vws_client.wait_for_target_processed(target_id=target_id) - with pytest.raises(expected_exception=BadImage) as exc: + with pytest.raises(expected_exception=BadImageError) as exc: vws_client.update_target( target_id=target_id, image=io.BytesIO(initial_bytes=b"not_image_data"), @@ -888,7 +888,7 @@ def test_rating_can_change( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProject: +class TestInactiveProjectError: """ Tests for inactive projects. """ @@ -898,5 +898,5 @@ def test_inactive_project(inactive_vws_client: VWS) -> None: """ If the project is inactive, a FORBIDDEN response is returned. """ - with pytest.raises(expected_exception=ProjectInactive): + with pytest.raises(expected_exception=ProjectInactiveError): inactive_vws_client.update_target(target_id=uuid.uuid4().hex) diff --git a/tests/mock_vws/utils/retries.py b/tests/mock_vws/utils/retries.py index f909459a3..02e980e0b 100644 --- a/tests/mock_vws/utils/retries.py +++ b/tests/mock_vws/utils/retries.py @@ -5,10 +5,10 @@ from tenacity.wait import wait_fixed from vws.exceptions.custom_exceptions import ServerError from vws.exceptions.vws_exceptions import ( - TooManyRequests, + TooManyRequestsError, ) -RETRY_EXCEPTIONS = (TooManyRequests, ServerError) +RETRY_EXCEPTIONS = (TooManyRequestsError, ServerError) # We rely on pytest-retry for exceptions *during* tests. # We use tenacity for exceptions *before* tests. diff --git a/tests/mock_vws/utils/too_many_requests.py b/tests/mock_vws/utils/too_many_requests.py index 2648751aa..cc2113ebe 100644 --- a/tests/mock_vws/utils/too_many_requests.py +++ b/tests/mock_vws/utils/too_many_requests.py @@ -8,7 +8,7 @@ from beartype import beartype from vws.exceptions.custom_exceptions import ServerError from vws.exceptions.response import Response -from vws.exceptions.vws_exceptions import TooManyRequests +from vws.exceptions.vws_exceptions import TooManyRequestsError @beartype @@ -18,7 +18,8 @@ def handle_server_errors(*, response: requests.Response) -> None: This is useful for retrying tests based on the exceptions they raise. Raises: - vws.exceptions.vws_exceptions.TooManyRequests: The response is a 429. + vws.exceptions.vws_exceptions.TooManyRequestsError: The response is a + 429. vws.exceptions.custom_exceptions.ServerError: The response is a 5xx. """ vws_response = Response( @@ -35,7 +36,7 @@ def handle_server_errors(*, response: requests.Response) -> None: ): # pragma: no cover # The Vuforia API returns a 429 response with no JSON body. # We raise this here to prompt a retry at a higher level. - raise TooManyRequests(response=vws_response) + raise TooManyRequestsError(response=vws_response) # We do not cover this because in some test runs we will not hit the # error. From dad50a707860947c59d6860825a390e42f9e53b1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 09:53:16 +0100 Subject: [PATCH 006/331] Fix a changed class name --- docs/source/differences-to-vws.rst | 2 +- src/mock_vws/_constants.py | 22 ++++++------- src/mock_vws/_flask_server/vws.py | 8 ++--- .../_query_validators/auth_validators.py | 10 +++--- .../content_length_validators.py | 6 ++-- src/mock_vws/_query_validators/exceptions.py | 20 ++++++------ .../_query_validators/image_validators.py | 23 +++++++------ .../num_results_validators.py | 8 ++--- .../project_state_validators.py | 6 ++-- .../mock_web_services_api.py | 8 ++--- .../_services_validators/auth_validators.py | 12 +++---- .../content_length_validators.py | 8 ++--- .../content_type_validators.py | 10 +++--- .../_services_validators/exceptions.py | 32 +++++++++---------- .../_services_validators/image_validators.py | 23 +++++++------ .../metadata_validators.py | 6 ++-- .../_services_validators/name_validators.py | 18 +++++------ .../project_state_validators.py | 8 ++--- .../_services_validators/target_validators.py | 8 ++--- tests/mock_vws/test_add_target.py | 2 +- tests/mock_vws/test_database_summary.py | 2 +- tests/mock_vws/test_delete_target.py | 2 +- tests/mock_vws/test_get_duplicates.py | 2 +- tests/mock_vws/test_get_target.py | 2 +- tests/mock_vws/test_query.py | 4 +-- tests/mock_vws/test_target_list.py | 2 +- tests/mock_vws/test_target_summary.py | 2 +- tests/mock_vws/test_update_target.py | 2 +- 28 files changed, 127 insertions(+), 131 deletions(-) diff --git a/docs/source/differences-to-vws.rst b/docs/source/differences-to-vws.rst index 4794b2048..86218f4eb 100644 --- a/docs/source/differences-to-vws.rst +++ b/docs/source/differences-to-vws.rst @@ -96,7 +96,7 @@ These are: * ``ProjectSuspended`` * ``RequestQuotaReached`` * ``TargetQuotaReached`` -* ``TooManyRequestsError`` +* ``TooManyRequests`` ``Content-Length`` headers -------------------------- diff --git a/src/mock_vws/_constants.py b/src/mock_vws/_constants.py index 131bbb670..dc964520d 100644 --- a/src/mock_vws/_constants.py +++ b/src/mock_vws/_constants.py @@ -20,24 +20,24 @@ class ResultCodes(Enum): SUCCESS = "Success" TARGET_CREATED = "TargetCreated" - AUTHENTICATION_FAILURE = "AuthenticationFailureError" + AUTHENTICATION_FAILURE = "AuthenticationFailure" REQUEST_TIME_TOO_SKEWED = "RequestTimeTooSkewed" - TARGET_NAME_EXIST = "TargetNameExistError" - UNKNOWN_TARGET = "UnknownTargetError" - BAD_IMAGE = "BadImageError" - IMAGE_TOO_LARGE = "ImageTooLargeError" - METADATA_TOO_LARGE = "MetadataTooLargeError" + TARGET_NAME_EXIST = "TargetNameExist" + UNKNOWN_TARGET = "UnknownTarget" + BAD_IMAGE = "BadImage" + IMAGE_TOO_LARGE = "ImageTooLarge" + METADATA_TOO_LARGE = "MetadataTooLarge" # The documentation says "Start date is after the end date" but, at the # time of writing, I do not know how to trigger that, therefore this is not # tested. DATE_RANGE_ERROR = "DateRangeError" FAIL = "Fail" - TARGET_STATUS_PROCESSING = "TargetStatusProcessingError" + TARGET_STATUS_PROCESSING = "TargetStatusProcessing" REQUEST_QUOTA_REACHED = "RequestQuotaReached" - TARGET_STATUS_NOT_SUCCESS = "TargetStatusNotSuccessError" - PROJECT_INACTIVE = "ProjectInactiveError" - INACTIVE_PROJECT = "InactiveProjectError" - TOO_MANY_REQUESTS = "TooManyRequestsError" + TARGET_STATUS_NOT_SUCCESS = "TargetStatusNotSuccess" + PROJECT_INACTIVE = "ProjectInactive" + INACTIVE_PROJECT = "InactiveProject" + TOO_MANY_REQUESTS = "TooManyRequests" @beartype diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index db0fbd2b2..d5913f479 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -24,8 +24,8 @@ from mock_vws._services_validators import run_services_validators from mock_vws._services_validators.exceptions import ( FailError, - TargetStatusNotSuccessErrorError, - TargetStatusProcessingErrorError, + TargetStatusNotSuccessError, + TargetStatusProcessingError, ValidatorError, ) from mock_vws.database import VuforiaDatabase @@ -306,7 +306,7 @@ def delete_target(target_id: str) -> Response: ) if target.status == TargetStatuses.PROCESSING.value: - raise TargetStatusProcessingErrorError + raise TargetStatusProcessingError databases_url = f"{settings.target_manager_base_url}/databases" requests.delete( @@ -572,7 +572,7 @@ def update_target(target_id: str) -> Response: ) if target.status != TargetStatuses.SUCCESS.value: - raise TargetStatusNotSuccessErrorError + raise TargetStatusNotSuccessError update_values: dict[str, str | int | float | bool | None] = {} if "width" in request_json: diff --git a/src/mock_vws/_query_validators/auth_validators.py b/src/mock_vws/_query_validators/auth_validators.py index 6ddaed862..054a82a78 100644 --- a/src/mock_vws/_query_validators/auth_validators.py +++ b/src/mock_vws/_query_validators/auth_validators.py @@ -9,7 +9,7 @@ from mock_vws._database_matchers import get_database_matching_client_keys from mock_vws._query_validators.exceptions import ( - AuthenticationFailureErrorError, + AuthenticationFailureError, AuthHeaderMissingError, MalformedAuthHeaderError, ) @@ -75,7 +75,7 @@ def validate_client_key_exists( databases: All Vuforia databases. Raises: - AuthenticationFailureErrorError: The client key is unknown. + AuthenticationFailureError: The client key is unknown. """ header = request_headers["Authorization"] first_part, _ = header.split(sep=":") @@ -85,7 +85,7 @@ def validate_client_key_exists( return _LOGGER.warning(msg="The client key is unknown.") - raise AuthenticationFailureErrorError + raise AuthenticationFailureError @beartype @@ -129,7 +129,7 @@ def validate_authorization( databases: All Vuforia databases. Raises: - AuthenticationFailureErrorError: The "Authorization" header is not as + AuthenticationFailureError: The "Authorization" header is not as expected. """ try: @@ -144,4 +144,4 @@ def validate_authorization( _LOGGER.warning( msg="The authorization header does not match any databases.", ) - raise AuthenticationFailureErrorError from exc + raise AuthenticationFailureError from exc diff --git a/src/mock_vws/_query_validators/content_length_validators.py b/src/mock_vws/_query_validators/content_length_validators.py index 933a73d2b..4abbf6bf0 100644 --- a/src/mock_vws/_query_validators/content_length_validators.py +++ b/src/mock_vws/_query_validators/content_length_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._query_validators.exceptions import ( - AuthenticationFailureErrorGoodFormattingError, + AuthenticationFailureGoodFormattingError, ContentLengthHeaderNotIntError, ContentLengthHeaderTooLargeError, ) @@ -81,7 +81,7 @@ def validate_content_length_header_not_too_small( request_body: The body of the request. Raises: - AuthenticationFailureErrorGoodFormattingError: The given content length + AuthenticationFailureGoodFormattingError: The given content length header says that the content length is smaller than the body length. """ @@ -92,4 +92,4 @@ def validate_content_length_header_not_too_small( if given_content_length_value < body_length: _LOGGER.warning(msg="The Content-Length header is too small.") - raise AuthenticationFailureErrorGoodFormattingError + raise AuthenticationFailureGoodFormattingError diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index a0a6f0213..8a39d468b 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -125,10 +125,10 @@ def __init__(self) -> None: @beartype -class BadImageErrorError(ValidatorError): +class BadImageError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'BadImageError'. + 'BadImage'. """ def __init__(self) -> None: @@ -168,10 +168,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureErrorError(ValidatorError): +class AuthenticationFailureError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailureError'. + 'AuthenticationFailure'. """ def __init__(self) -> None: @@ -211,10 +211,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureErrorGoodFormattingError(ValidatorError): +class AuthenticationFailureGoodFormattingError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailureError' with a standard JSON formatting. + 'AuthenticationFailure' with a standard JSON formatting. """ def __init__(self) -> None: @@ -380,10 +380,10 @@ def __init__(self) -> None: @beartype -class InactiveProjectErrorError(ValidatorError): +class InactiveProjectError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'InactiveProjectError'. + 'InactiveProject'. """ def __init__(self) -> None: @@ -459,7 +459,7 @@ def __init__(self, given_value: str) -> None: @beartype -class MaxNumResultsOutOfRangeErrorError(ValidatorError): +class MaxNumResultsOutOfRangeError(ValidatorError): """ Exception raised when an integer value is given as the "max_num_results" field which is out of range. @@ -679,7 +679,7 @@ def __init__(self) -> None: @beartype -class RequestEntityTooLargeErrorError(ValidatorError): +class RequestEntityTooLargeError(ValidatorError): """ Exception raised when the given image file size is too large. """ diff --git a/src/mock_vws/_query_validators/image_validators.py b/src/mock_vws/_query_validators/image_validators.py index 299a836cc..7c5d2e1d8 100644 --- a/src/mock_vws/_query_validators/image_validators.py +++ b/src/mock_vws/_query_validators/image_validators.py @@ -12,9 +12,9 @@ from werkzeug.formparser import MultiPartParser from mock_vws._query_validators.exceptions import ( - BadImageErrorError, + BadImageError, ImageNotGivenError, - RequestEntityTooLargeErrorError, + RequestEntityTooLargeError, ) _LOGGER = logging.getLogger(name=__name__) @@ -66,7 +66,7 @@ def validate_image_file_size( request_body: The body of the request. Raises: - RequestEntityTooLargeErrorError: The image file size is too large. + RequestEntityTooLargeError: The image file size is too large. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -90,7 +90,7 @@ def validate_image_file_size( # See https://github.com/urllib3/urllib3/issues/2733. if len(image_value) > max_bytes: # pragma: no cover _LOGGER.warning(msg="The image file size is too large.") - raise RequestEntityTooLargeErrorError + raise RequestEntityTooLargeError @beartype @@ -107,8 +107,8 @@ def validate_image_dimensions( request_body: The body of the request. Raises: - BadImageErrorError: The image is given and is not within the maximum - width and height limits. + BadImageError: The image is given and is not within the maximum width + and height limits. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -129,7 +129,7 @@ def validate_image_dimensions( return _LOGGER.warning(msg="The image dimensions are too large.") - raise BadImageErrorError + raise BadImageError @beartype @@ -146,8 +146,7 @@ def validate_image_format( request_body: The body of the request. Raises: - BadImageErrorError: The image is given and is not either a PNG or a - JPEG. + BadImageError: The image is given and is not either a PNG or a JPEG. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -165,7 +164,7 @@ def validate_image_format( return _LOGGER.warning(msg="The image format is not PNG or JPEG.") - raise BadImageErrorError + raise BadImageError @beartype @@ -181,7 +180,7 @@ def validate_image_is_image( request_body: The body of the request. Raises: - BadImageErrorError: Image data is given and it is not an image file. + BadImageError: Image data is given and it is not an image file. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -199,4 +198,4 @@ def validate_image_is_image( Image.open(fp=image_file) except OSError as exc: _LOGGER.warning(msg="The image is not an image file.") - raise BadImageErrorError from exc + raise BadImageError from exc diff --git a/src/mock_vws/_query_validators/num_results_validators.py b/src/mock_vws/_query_validators/num_results_validators.py index e4fce4a92..65705ae33 100644 --- a/src/mock_vws/_query_validators/num_results_validators.py +++ b/src/mock_vws/_query_validators/num_results_validators.py @@ -12,7 +12,7 @@ from mock_vws._query_validators.exceptions import ( InvalidMaxNumResultsError, - MaxNumResultsOutOfRangeErrorError, + MaxNumResultsOutOfRangeError, ) _LOGGER = logging.getLogger(name=__name__) @@ -35,8 +35,8 @@ def validate_max_num_results( Raises: InvalidMaxNumResultsError: The ``max_num_results`` given is not an integer less than or equal to the max integer in Java. - MaxNumResultsOutOfRangeErrorError: The ``max_num_results`` given is - not in range. + MaxNumResultsOutOfRangeError: The ``max_num_results`` given is not in + range. """ email_message = EmailMessage() email_message["Content-Type"] = request_headers["Content-Type"] @@ -63,4 +63,4 @@ def validate_max_num_results( max_allowed_results = 50 if max_num_results_int < 1 or max_num_results_int > max_allowed_results: _LOGGER.warning(msg="The max_num_results field is out of range.") - raise MaxNumResultsOutOfRangeErrorError(given_value=max_num_results) + raise MaxNumResultsOutOfRangeError(given_value=max_num_results) diff --git a/src/mock_vws/_query_validators/project_state_validators.py b/src/mock_vws/_query_validators/project_state_validators.py index 187f3c718..dccf202fc 100644 --- a/src/mock_vws/_query_validators/project_state_validators.py +++ b/src/mock_vws/_query_validators/project_state_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_client_keys -from mock_vws._query_validators.exceptions import InactiveProjectErrorError +from mock_vws._query_validators.exceptions import InactiveProjectError from mock_vws.database import VuforiaDatabase from mock_vws.states import States @@ -34,7 +34,7 @@ def validate_project_state( databases: All Vuforia databases. Raises: - InactiveProjectErrorError: The project is inactive. + InactiveProjectError: The project is inactive. """ database = get_database_matching_client_keys( request_headers=request_headers, @@ -48,4 +48,4 @@ def validate_project_state( return _LOGGER.warning(msg="The project is inactive.") - raise InactiveProjectErrorError + raise InactiveProjectError diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index ce68e653b..36936c034 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -25,8 +25,8 @@ from mock_vws._services_validators import run_services_validators from mock_vws._services_validators.exceptions import ( FailError, - TargetStatusNotSuccessErrorError, - TargetStatusProcessingErrorError, + TargetStatusNotSuccessError, + TargetStatusProcessingError, ValidatorError, ) from mock_vws.image_matchers import ImageMatcher @@ -244,7 +244,7 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: target = database.get_target(target_id=target_id) if target.status == TargetStatuses.PROCESSING.value: - target_processing_exception = TargetStatusProcessingErrorError() + target_processing_exception = TargetStatusProcessingError() return ( target_processing_exception.status_code, target_processing_exception.headers, @@ -577,7 +577,7 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: ) if target.status != TargetStatuses.SUCCESS.value: - exception = TargetStatusNotSuccessErrorError() + exception = TargetStatusNotSuccessError() return ( exception.status_code, exception.headers, diff --git a/src/mock_vws/_services_validators/auth_validators.py b/src/mock_vws/_services_validators/auth_validators.py index f0d4bb45b..e3ec36d23 100644 --- a/src/mock_vws/_services_validators/auth_validators.py +++ b/src/mock_vws/_services_validators/auth_validators.py @@ -10,7 +10,7 @@ from mock_vws._database_matchers import get_database_matching_server_keys from mock_vws._services_validators.exceptions import ( - AuthenticationFailureErrorError, + AuthenticationFailureError, FailError, ) from mock_vws.database import VuforiaDatabase @@ -27,11 +27,11 @@ def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None: request_headers: The headers sent with the request. Raises: - AuthenticationFailureErrorError: There is no "Authorization" header. + AuthenticationFailureError: There is no "Authorization" header. """ if "Authorization" not in request_headers: _LOGGER.warning(msg="There is no authorization header.") - raise AuthenticationFailureErrorError + raise AuthenticationFailureError @beartype @@ -108,8 +108,8 @@ def validate_authorization( databases: All Vuforia databases. Raises: - AuthenticationFailureErrorError: No database matches the given - authorization header. + AuthenticationFailureError: No database matches the given authorization + header. """ try: get_database_matching_server_keys( @@ -123,4 +123,4 @@ def validate_authorization( _LOGGER.warning( msg="No database matches the given authorization header.", ) - raise AuthenticationFailureErrorError from exc + raise AuthenticationFailureError from exc diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index 80b3eb603..88f3e451d 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._services_validators.exceptions import ( - AuthenticationFailureErrorError, + AuthenticationFailureError, ContentLengthHeaderNotIntError, ContentLengthHeaderTooLargeError, ) @@ -83,8 +83,8 @@ def validate_content_length_header_not_too_small( request_body: The body of the request. Raises: - AuthenticationFailureErrorError: The given content length header says - that the content length is smaller than the body length. + AuthenticationFailureError: The given content length header says that + the content length is smaller than the body length. """ body_length = len(request_body) given_content_length = request_headers.get("Content-Length", body_length) @@ -92,4 +92,4 @@ def validate_content_length_header_not_too_small( if given_content_length_value < body_length: _LOGGER.warning(msg="The Content-Length header is too small.") - raise AuthenticationFailureErrorError + raise AuthenticationFailureError diff --git a/src/mock_vws/_services_validators/content_type_validators.py b/src/mock_vws/_services_validators/content_type_validators.py index ad01448c4..6afa606dc 100644 --- a/src/mock_vws/_services_validators/content_type_validators.py +++ b/src/mock_vws/_services_validators/content_type_validators.py @@ -8,9 +8,7 @@ from beartype import beartype -from mock_vws._services_validators.exceptions import ( - AuthenticationFailureErrorError, -) +from mock_vws._services_validators.exceptions import AuthenticationFailureError _LOGGER = logging.getLogger(name=__name__) @@ -29,8 +27,8 @@ def validate_content_type_header_given( request_method: The HTTP method of the request. Raises: - AuthenticationFailureErrorError: No ``Content-Type`` header is given - and the request requires one. + AuthenticationFailureError: No ``Content-Type`` header is given and the + request requires one. """ request_needs_content_type = bool( request_method in {HTTPMethod.POST, HTTPMethod.PUT}, @@ -39,4 +37,4 @@ def validate_content_type_header_given( return _LOGGER.warning(msg="No Content-Type header is given.") - raise AuthenticationFailureErrorError + raise AuthenticationFailureError diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index 3b9947825..f528f1bf0 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -26,10 +26,10 @@ class ValidatorError(Exception): @beartype -class UnknownTargetErrorError(ValidatorError): +class UnknownTargetError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'UnknownTargetError'. + 'UnknownTarget'. """ def __init__(self) -> None: @@ -66,10 +66,10 @@ def __init__(self) -> None: @beartype -class ProjectInactiveErrorError(ValidatorError): +class ProjectInactiveError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'ProjectInactiveError'. + 'ProjectInactive'. """ def __init__(self) -> None: @@ -106,10 +106,10 @@ def __init__(self) -> None: @beartype -class AuthenticationFailureErrorError(ValidatorError): +class AuthenticationFailureError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'AuthenticationFailureError'. + 'AuthenticationFailure'. """ def __init__(self) -> None: @@ -185,10 +185,10 @@ def __init__(self, *, status_code: HTTPStatus) -> None: @beartype -class MetadataTooLargeErrorError(ValidatorError): +class MetadataTooLargeError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'MetadataTooLargeError'. + 'MetadataTooLarge'. """ def __init__(self) -> None: @@ -225,10 +225,10 @@ def __init__(self) -> None: @beartype -class TargetNameExistErrorError(ValidatorError): +class TargetNameExistError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'TargetNameExistError'. + 'TargetNameExist'. """ def __init__(self) -> None: @@ -307,10 +307,10 @@ def __init__(self) -> None: @beartype -class BadImageErrorError(ValidatorError): +class BadImageError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'BadImageError'. + 'BadImage'. """ def __init__(self) -> None: @@ -347,10 +347,10 @@ def __init__(self) -> None: @beartype -class ImageTooLargeErrorError(ValidatorError): +class ImageTooLargeError(ValidatorError): """ Exception raised when Vuforia returns a response with a result code - 'ImageTooLargeError'. + 'ImageTooLarge'. """ def __init__(self) -> None: @@ -529,7 +529,7 @@ def __init__(self) -> None: @beartype -class TargetStatusNotSuccessErrorError(ValidatorError): +class TargetStatusNotSuccessError(ValidatorError): """ Exception raised when trying to update a target that does not have a success status. @@ -569,7 +569,7 @@ def __init__(self) -> None: @beartype -class TargetStatusProcessingErrorError(ValidatorError): +class TargetStatusProcessingError(ValidatorError): """ Exception raised when trying to delete a target which is processing. """ diff --git a/src/mock_vws/_services_validators/image_validators.py b/src/mock_vws/_services_validators/image_validators.py index 2847af218..8927b7986 100644 --- a/src/mock_vws/_services_validators/image_validators.py +++ b/src/mock_vws/_services_validators/image_validators.py @@ -13,9 +13,9 @@ from mock_vws._base64_decoding import decode_base64 from mock_vws._services_validators.exceptions import ( - BadImageErrorError, + BadImageError, FailError, - ImageTooLargeErrorError, + ImageTooLargeError, ) _LOGGER = logging.getLogger(name=__name__) @@ -30,8 +30,7 @@ def validate_image_format(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageErrorError: The image is given and is not either a PNG or a - JPEG. + BadImageError: The image is given and is not either a PNG or a JPEG. """ if not request_body: return @@ -50,7 +49,7 @@ def validate_image_format(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The image is not a PNG or JPEG.") - raise BadImageErrorError + raise BadImageError @beartype @@ -62,7 +61,7 @@ def validate_image_color_space(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageErrorError: The image is given and is not in either the RGB or + BadImageError: The image is given and is not in either the RGB or greyscale color space. """ if not request_body: @@ -84,7 +83,7 @@ def validate_image_color_space(*, request_body: bytes) -> None: _LOGGER.warning( msg="The image is not in the RGB or greyscale color space.", ) - raise BadImageErrorError + raise BadImageError @beartype @@ -96,8 +95,8 @@ def validate_image_size(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - ImageTooLargeErrorError: The image is given and is not under a - certain file size threshold. + ImageTooLargeError: The image is given and is not under a certain file + size threshold. """ if not request_body: return @@ -115,7 +114,7 @@ def validate_image_size(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The image is too large.") - raise ImageTooLargeErrorError + raise ImageTooLargeError @beartype @@ -127,7 +126,7 @@ def validate_image_is_image(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - BadImageErrorError: Image data is given and it is not an image file. + BadImageError: Image data is given and it is not an image file. """ if not request_body: return @@ -144,7 +143,7 @@ def validate_image_is_image(*, request_body: bytes) -> None: try: Image.open(fp=image_file) except OSError as exc: - raise BadImageErrorError from exc + raise BadImageError from exc @beartype diff --git a/src/mock_vws/_services_validators/metadata_validators.py b/src/mock_vws/_services_validators/metadata_validators.py index 9d90df0a1..b8b81deb1 100644 --- a/src/mock_vws/_services_validators/metadata_validators.py +++ b/src/mock_vws/_services_validators/metadata_validators.py @@ -12,7 +12,7 @@ from mock_vws._base64_decoding import decode_base64 from mock_vws._services_validators.exceptions import ( FailError, - MetadataTooLargeErrorError, + MetadataTooLargeError, ) _LOGGER = logging.getLogger(name=__name__) @@ -28,7 +28,7 @@ def validate_metadata_size(*, request_body: bytes) -> None: request_body: The body of the request. Raises: - MetadataTooLargeErrorError: Application metadata is given and it is too + MetadataTooLargeError: Application metadata is given and it is too large. """ if not request_body: @@ -46,7 +46,7 @@ def validate_metadata_size(*, request_body: bytes) -> None: return _LOGGER.warning(msg="The application metadata is too large.") - raise MetadataTooLargeErrorError + raise MetadataTooLargeError @beartype diff --git a/src/mock_vws/_services_validators/name_validators.py b/src/mock_vws/_services_validators/name_validators.py index 09dee37b4..f11de3cd6 100644 --- a/src/mock_vws/_services_validators/name_validators.py +++ b/src/mock_vws/_services_validators/name_validators.py @@ -13,7 +13,7 @@ from mock_vws._services_validators.exceptions import ( FailError, OopsErrorOccurredResponseError, - TargetNameExistErrorError, + TargetNameExistError, ) from mock_vws.database import VuforiaDatabase @@ -38,8 +38,8 @@ def validate_name_characters_in_range( Raises: OopsErrorOccurredResponseError: Characters are out of range and the request is trying to make a new target. - TargetNameExistErrorError: Characters are out of range and the request - is for another endpoint. + TargetNameExistError: Characters are out of range and the request is + for another endpoint. """ if not request_body: return @@ -59,7 +59,7 @@ def validate_name_characters_in_range( raise OopsErrorOccurredResponseError _LOGGER.warning(msg="Characters are out of range.") - raise TargetNameExistErrorError + raise TargetNameExistError @beartype @@ -138,7 +138,7 @@ def validate_name_does_not_exist_new_target( request_path: The path to the endpoint. Raises: - TargetNameExistErrorError: The target name already exists. + TargetNameExistError: The target name already exists. """ if not request_body: return @@ -172,7 +172,7 @@ def validate_name_does_not_exist_new_target( return _LOGGER.warning(msg="Target name already exists.") - raise TargetNameExistErrorError + raise TargetNameExistError @beartype @@ -196,8 +196,8 @@ def validate_name_does_not_exist_existing_target( request_path: The path to the endpoint. Raises: - TargetNameExistErrorError: The target name is not the same as the name - of the target being updated but it is the same as another target. + TargetNameExistError: The target name is not the same as the name of + the target being updated but it is the same as another target. """ if not request_body: return @@ -236,4 +236,4 @@ def validate_name_does_not_exist_existing_target( return _LOGGER.warning(msg="Name already exists for another target.") - raise TargetNameExistErrorError + raise TargetNameExistError diff --git a/src/mock_vws/_services_validators/project_state_validators.py b/src/mock_vws/_services_validators/project_state_validators.py index 2ebca78a3..cd21bebee 100644 --- a/src/mock_vws/_services_validators/project_state_validators.py +++ b/src/mock_vws/_services_validators/project_state_validators.py @@ -9,7 +9,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_server_keys -from mock_vws._services_validators.exceptions import ProjectInactiveErrorError +from mock_vws._services_validators.exceptions import ProjectInactiveError from mock_vws.database import VuforiaDatabase from mock_vws.states import States @@ -36,8 +36,8 @@ def validate_project_state( databases: All Vuforia databases. Raises: - ProjectInactiveErrorError: The project is inactive and this endpoint - does not work with inactive projects. + ProjectInactiveError: The project is inactive and this endpoint does + not work with inactive projects. """ database = get_database_matching_server_keys( request_headers=request_headers, @@ -54,4 +54,4 @@ def validate_project_state( return _LOGGER.warning(msg="The project is inactive.") - raise ProjectInactiveErrorError + raise ProjectInactiveError diff --git a/src/mock_vws/_services_validators/target_validators.py b/src/mock_vws/_services_validators/target_validators.py index d078f122c..11bb4df9c 100644 --- a/src/mock_vws/_services_validators/target_validators.py +++ b/src/mock_vws/_services_validators/target_validators.py @@ -8,7 +8,7 @@ from beartype import beartype from mock_vws._database_matchers import get_database_matching_server_keys -from mock_vws._services_validators.exceptions import UnknownTargetErrorError +from mock_vws._services_validators.exceptions import UnknownTargetError from mock_vws.database import VuforiaDatabase _LOGGER = logging.getLogger(name=__name__) @@ -35,8 +35,8 @@ def validate_target_id_exists( databases: All Vuforia databases. Raises: - UnknownTargetErrorError: There are no matching targets for a given - target ID. + UnknownTargetError: There are no matching targets for a given target + ID. """ split_path = request_path.split(sep="/") @@ -61,4 +61,4 @@ def validate_target_id_exists( ) except ValueError as exc: _LOGGER.warning('The target ID "%s" does not exist.', target_id) - raise UnknownTargetErrorError from exc + raise UnknownTargetError from exc diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 45fda5753..37cc11c6c 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -1029,7 +1029,7 @@ def test_metadata_too_large( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_database_summary.py b/tests/mock_vws/test_database_summary.py index a75a900f7..3862e1a72 100644 --- a/tests/mock_vws/test_database_summary.py +++ b/tests/mock_vws/test_database_summary.py @@ -410,7 +410,7 @@ def test_query_request( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_delete_target.py b/tests/mock_vws/test_delete_target.py index 8516d5d6a..3eaa8ab68 100644 --- a/tests/mock_vws/test_delete_target.py +++ b/tests/mock_vws/test_delete_target.py @@ -57,7 +57,7 @@ def test_processed(target_id: str, vws_client: VWS) -> None: @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_get_duplicates.py b/tests/mock_vws/test_get_duplicates.py index ffa3ae9ef..b6427afba 100644 --- a/tests/mock_vws/test_get_duplicates.py +++ b/tests/mock_vws/test_get_duplicates.py @@ -254,7 +254,7 @@ def test_processing( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_get_target.py b/tests/mock_vws/test_get_target.py index be137c478..cbc17474f 100644 --- a/tests/mock_vws/test_get_target.py +++ b/tests/mock_vws/test_get_target.py @@ -172,7 +172,7 @@ def test_target_quality( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 055655c87..aa3998e94 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -1245,7 +1245,7 @@ def test_inactive( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestBadImageError: +class TestBadImage: """ Tests for bad images. """ @@ -1964,7 +1964,7 @@ def test_date_formats( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_target_list.py b/tests/mock_vws/test_target_list.py index 0def2e7fa..3cc4ea27d 100644 --- a/tests/mock_vws/test_target_list.py +++ b/tests/mock_vws/test_target_list.py @@ -36,7 +36,7 @@ def test_deleted( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_target_summary.py b/tests/mock_vws/test_target_summary.py index 1d2f920af..1dc751d1d 100644 --- a/tests/mock_vws/test_target_summary.py +++ b/tests/mock_vws/test_target_summary.py @@ -158,7 +158,7 @@ def test_recognition( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 6193f8fbf..a4e12922e 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -888,7 +888,7 @@ def test_rating_can_change( @pytest.mark.usefixtures("verify_mock_vuforia") -class TestInactiveProjectError: +class TestInactiveProject: """ Tests for inactive projects. """ From fdb8e3320b75bf1c817db617afa5ccef51be73d3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 11:26:49 +0100 Subject: [PATCH 007/331] Use more keyword arguments - better typecheck errors --- admin/create_secrets_files.py | 6 ++++-- ci/custom_linters.py | 2 +- src/mock_vws/_services_validators/key_validators.py | 2 +- src/mock_vws/image_matchers.py | 4 ++-- src/mock_vws/target_raters.py | 2 +- tests/mock_vws/test_content_length.py | 2 +- tests/mock_vws/test_flask_app_usage.py | 8 ++++---- tests/mock_vws/test_get_duplicates.py | 2 +- tests/mock_vws/test_query.py | 6 +++--- tests/mock_vws/test_requests_mock_usage.py | 12 ++++++------ tests/mock_vws/test_update_target.py | 2 +- tests/mock_vws/utils/__init__.py | 4 ++-- tests/mock_vws/utils/assertions.py | 2 +- 13 files changed, 28 insertions(+), 26 deletions(-) diff --git a/admin/create_secrets_files.py b/admin/create_secrets_files.py index 51930f58b..aaac649b4 100644 --- a/admin/create_secrets_files.py +++ b/admin/create_secrets_files.py @@ -48,7 +48,9 @@ driver = webdriver.Chrome() file = files_to_create[-1] sys.stdout.write(f"Creating database {file.name}\n") - time = datetime.datetime.now(tz=datetime.UTC).strftime("%Y-%m-%d-%H-%M-%S") + time = datetime.datetime.now(tz=datetime.UTC).strftime( + format="%Y-%m-%d-%H-%M-%S", + ) license_name = f"my-license-{time}" database_name = f"my-database-{time}" @@ -85,7 +87,7 @@ driver = None file_contents = textwrap.dedent( - f"""\ + text=f"""\ VUFORIA_TARGET_MANAGER_DATABASE_NAME={database_details["database_name"]} VUFORIA_SERVER_ACCESS_KEY={database_details["server_access_key"]} VUFORIA_SERVER_SECRET_KEY={database_details["server_secret_key"]} diff --git a/ci/custom_linters.py b/ci/custom_linters.py index 784c8cac5..cac363803 100644 --- a/ci/custom_linters.py +++ b/ci/custom_linters.py @@ -15,7 +15,7 @@ def _ci_patterns(*, repository_root: Path) -> set[str]: Return the CI patterns given in the CI configuration file. """ ci_file = repository_root / ".github" / "workflows" / "ci.yml" - github_workflow_config = yaml.safe_load(ci_file.read_text()) + github_workflow_config = yaml.safe_load(stream=ci_file.read_text()) matrix = github_workflow_config["jobs"]["build"]["strategy"]["matrix"] ci_pattern_list = matrix["ci_pattern"] ci_patterns = set(ci_pattern_list) diff --git a/src/mock_vws/_services_validators/key_validators.py b/src/mock_vws/_services_validators/key_validators.py index 0f823956d..dc2bc3063 100644 --- a/src/mock_vws/_services_validators/key_validators.py +++ b/src/mock_vws/_services_validators/key_validators.py @@ -139,7 +139,7 @@ def validate_keys( route for route in routes if re.match( - pattern=re.compile(f"{route.path_pattern}$"), + pattern=re.compile(pattern=f"{route.path_pattern}$"), string=request_path, ) and request_method in route.http_methods diff --git a/src/mock_vws/image_matchers.py b/src/mock_vws/image_matchers.py index 5768ad8b7..b194b457e 100644 --- a/src/mock_vws/image_matchers.py +++ b/src/mock_vws/image_matchers.py @@ -98,12 +98,12 @@ def __call__( 2, 0, 1, - ).unsqueeze(0) + ).unsqueeze(dim=0) second_image_tensor_batch_dimension = second_image_tensor.permute( 2, 0, 1, - ).unsqueeze(0) + ).unsqueeze(dim=0) ssim = StructuralSimilarityIndexMeasure(data_range=1.0) ssim_value = ssim( diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index dc7542f4e..2131bd34c 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -35,7 +35,7 @@ def _get_brisque_target_tracking_rating(*, image_content: bytes) -> int: image.size[0], len(image.getbands()), ) - image_tensor = image_tensor.permute(2, 0, 1).unsqueeze(0) + image_tensor = image_tensor.permute(2, 0, 1).unsqueeze(dim=0) try: brisque_score = piq.brisque(x=image_tensor, data_range=255) except (AssertionError, IndexError): diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index c7db1f235..783149f92 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -90,7 +90,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover An error is given if the given content length is too large. """ if not endpoint.prepared_request.headers.get("Content-Type"): - pytest.skip("No Content-Type header for this request") + pytest.skip(reason="No Content-Type header for this request") url = endpoint.prepared_request.url or "" netloc = urlparse(url=url).netloc diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 08f00f170..657cb172c 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -266,7 +266,7 @@ def test_exact_match( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" requests.post(url=databases_url, json=database.to_dict(), timeout=30) @@ -311,7 +311,7 @@ def test_structural_similarity_matcher( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" requests.post(url=databases_url, json=database.to_dict(), timeout=30) @@ -358,7 +358,7 @@ def test_exact_match( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" requests.post(url=databases_url, json=database.to_dict(), timeout=30) @@ -410,7 +410,7 @@ def test_structural_similarity_matcher( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" requests.post(url=databases_url, json=database.to_dict(), timeout=30) diff --git a/tests/mock_vws/test_get_duplicates.py b/tests/mock_vws/test_get_duplicates.py index 2661d903a..2f8242010 100644 --- a/tests/mock_vws/test_get_duplicates.py +++ b/tests/mock_vws/test_get_duplicates.py @@ -74,7 +74,7 @@ def test_duplicates_not_same( Target IDs of similar targets are returned. """ image_data = high_quality_image - similar_image_data = copy.copy(image_data) + similar_image_data = copy.copy(x=image_data) similar_image_buffer = io.BytesIO() pil_similar_image = Image.open(fp=similar_image_data) # Re-save means similar but not identical. diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index eab124550..65439d10b 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -603,7 +603,7 @@ def test_match_similar( vws_client.wait_for_target_processed(target_id=target_id_not_matching) similar_image_buffer = io.BytesIO() - similar_image_data = copy.copy(high_quality_image) + similar_image_data = copy.copy(x=high_quality_image) pil_similar_image = Image.open(fp=similar_image_data) # Re-save means similar but not identical. pil_similar_image.save(similar_image_buffer, format="JPEG") @@ -1613,7 +1613,7 @@ def test_supported( """ image_buffer = io.BytesIO() pil_image = Image.open(fp=high_quality_image) - pil_image.save(image_buffer, file_format) + pil_image.save(fp=image_buffer, format=file_format) image_content = image_buffer.getvalue() results = cloud_reco_client.query( image=io.BytesIO(initial_bytes=image_content) @@ -1631,7 +1631,7 @@ def test_unsupported( file_format = "tiff" image_buffer = io.BytesIO() pil_image = Image.open(fp=high_quality_image) - pil_image.save(image_buffer, file_format) + pil_image.save(fp=image_buffer, format=file_format) image_content = image_buffer.getvalue() with pytest.raises(expected_exception=BadImage) as exc_info: diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index c09311e2e..404bc2ac6 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -469,7 +469,7 @@ def test_exact_match(high_quality_image: io.BytesIO) -> None: pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS(query_match_checker=ExactMatcher()) as mock: mock.add_database(database=database) @@ -505,7 +505,7 @@ def test_custom_matcher(high_quality_image: io.BytesIO) -> None: pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS(query_match_checker=_not_exact_matcher) as mock: mock.add_database(database=database) @@ -544,7 +544,7 @@ def test_structural_similarity_matcher( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS( query_match_checker=StructuralSimilarityMatcher(), @@ -587,7 +587,7 @@ def test_exact_match(high_quality_image: io.BytesIO) -> None: pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS(duplicate_match_checker=ExactMatcher()) as mock: mock.add_database(database=database) @@ -631,7 +631,7 @@ def test_custom_matcher(high_quality_image: io.BytesIO) -> None: pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS(duplicate_match_checker=_not_exact_matcher) as mock: mock.add_database(database=database) @@ -677,7 +677,7 @@ def test_structural_similarity_matcher( pil_image = Image.open(fp=high_quality_image) re_exported_image = io.BytesIO() - pil_image.save(re_exported_image, format="PNG") + pil_image.save(fp=re_exported_image, format="PNG") with MockVWS( duplicate_match_checker=StructuralSimilarityMatcher(), diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 93cc176b3..36b767823 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -79,7 +79,7 @@ def _update_target( response = requests.request( method=HTTPMethod.PUT, - url=urljoin("https://vws.vuforia.com/", request_path), + url=urljoin(base="https://vws.vuforia.com/", url=request_path), headers=headers, data=content, timeout=30, diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 5b5e0615a..b71601728 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -86,7 +86,7 @@ def make_image_file( An image file in the given format and color space. """ image_buffer = io.BytesIO() - image = Image.new(color_space, (width, height)) + image = Image.new(mode=color_space, size=(width, height)) for row_index in range(height): for column_index in range(width): red = secrets.choice(seq=range(255)) @@ -97,6 +97,6 @@ def make_image_file( value=(red, green, blue), ) - image.save(image_buffer, file_format) + image.save(fp=image_buffer, format=file_format) image_buffer.seek(0) return image_buffer diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index 2a0dd2375..6f7a9f476 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -273,7 +273,7 @@ def assert_vwq_failure( # Sometimes the "transfer-encoding" is given. # It is not given by the mock. - response_header_keys_chunked = copy.copy(response_header_keys) + response_header_keys_chunked = copy.copy(x=response_header_keys) response_header_keys_chunked.remove("Content-Length") response_header_keys_chunked.add("transfer-encoding") From beb43dfc3580845f1a0fa15bc7bac7bfddb8d505 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 11:43:24 +0100 Subject: [PATCH 008/331] Use more kwargs --- src/mock_vws/_query_tools.py | 6 +++--- src/mock_vws/_query_validators/fields_validators.py | 2 +- src/mock_vws/_query_validators/image_validators.py | 10 +++++----- .../include_target_data_validators.py | 2 +- .../_query_validators/num_results_validators.py | 2 +- tests/mock_vws/test_query.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mock_vws/_query_tools.py b/src/mock_vws/_query_tools.py index f5acdb014..2f2936f4b 100644 --- a/src/mock_vws/_query_tools.py +++ b/src/mock_vws/_query_tools.py @@ -50,7 +50,7 @@ def get_query_match_response_text( parser = MultiPartParser() fields, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) @@ -103,8 +103,8 @@ def get_query_match_response_text( application_metadata = None else: application_metadata = base64.b64encode( - decode_base64(encoded_data=target.application_metadata), - ).decode("ascii") + s=decode_base64(encoded_data=target.application_metadata), + ).decode(encoding="ascii") target_data = { "target_timestamp": int(target_timestamp), "name": target.name, diff --git a/src/mock_vws/_query_validators/fields_validators.py b/src/mock_vws/_query_validators/fields_validators.py index 2f281aca5..0ab9f2260 100644 --- a/src/mock_vws/_query_validators/fields_validators.py +++ b/src/mock_vws/_query_validators/fields_validators.py @@ -37,7 +37,7 @@ def validate_extra_fields( parser = MultiPartParser() fields, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) parsed_keys = fields.keys() | files.keys() diff --git a/src/mock_vws/_query_validators/image_validators.py b/src/mock_vws/_query_validators/image_validators.py index 7c5d2e1d8..fe8998b44 100644 --- a/src/mock_vws/_query_validators/image_validators.py +++ b/src/mock_vws/_query_validators/image_validators.py @@ -42,7 +42,7 @@ def validate_image_field_given( parser = MultiPartParser() _, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) if files.get("image") is not None: @@ -74,7 +74,7 @@ def validate_image_file_size( parser = MultiPartParser() _, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) image_part = files["image"] @@ -116,7 +116,7 @@ def validate_image_dimensions( parser = MultiPartParser() _, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) image_part = files["image"] @@ -154,7 +154,7 @@ def validate_image_format( parser = MultiPartParser() _, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) image_part = files["image"] @@ -188,7 +188,7 @@ def validate_image_is_image( parser = MultiPartParser() _, files = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) image_part = files["image"] diff --git a/src/mock_vws/_query_validators/include_target_data_validators.py b/src/mock_vws/_query_validators/include_target_data_validators.py index b89fd0775..31f1c5d50 100644 --- a/src/mock_vws/_query_validators/include_target_data_validators.py +++ b/src/mock_vws/_query_validators/include_target_data_validators.py @@ -38,7 +38,7 @@ def validate_include_target_data( parser = MultiPartParser() fields, _ = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) include_target_data = fields.get("include_target_data", "top") diff --git a/src/mock_vws/_query_validators/num_results_validators.py b/src/mock_vws/_query_validators/num_results_validators.py index 65705ae33..9eb49a6a0 100644 --- a/src/mock_vws/_query_validators/num_results_validators.py +++ b/src/mock_vws/_query_validators/num_results_validators.py @@ -44,7 +44,7 @@ def validate_max_num_results( parser = MultiPartParser() fields, _ = parser.parse( stream=io.BytesIO(initial_bytes=request_body), - boundary=boundary.encode("utf-8"), + boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) max_num_results = fields.get("max_num_results", "1") diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 65439d10b..36bfa0692 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -658,7 +658,7 @@ def test_not_base64_encoded_processable( len(not_base64_encoded_processable) % 4 ] expected_metadata = base64.b64encode( - base64.b64decode(s=expected_metadata_original), + s=base64.b64decode(s=expected_metadata_original), ) assert query_metadata == expected_metadata.decode() From d692d6abcc8666fb134d9b7fb6a2863d319a6371 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 16:39:18 +0100 Subject: [PATCH 009/331] Avoid beartype issue on new VWS Python --- tests/mock_vws/test_add_target.py | 221 +++++++++++++----------------- 1 file changed, 92 insertions(+), 129 deletions(-) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 37cc11c6c..2f738ad8e 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -8,10 +8,8 @@ from http import HTTPMethod, HTTPStatus from string import hexdigits from typing import Any, Final -from urllib.parse import urljoin import pytest -import requests from beartype import beartype from dirty_equals import IsInstance from requests.structures import CaseInsensitiveDict @@ -21,6 +19,7 @@ ) from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import ( + AuthenticationFailureError, BadImageError, FailError, ImageTooLargeError, @@ -28,17 +27,14 @@ ProjectInactiveError, TargetNameExistError, ) -from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes -from mock_vws.database import VuforiaDatabase from tests.mock_vws.utils import make_image_file from tests.mock_vws.utils.assertions import ( assert_valid_date_header, assert_vws_failure, assert_vws_response, ) -from tests.mock_vws.utils.too_many_requests import handle_server_errors _MAX_METADATA_BYTES: Final[int] = 1024 * 1024 - 1 @@ -46,53 +42,30 @@ @beartype def _add_target_to_vws( *, - vuforia_database: VuforiaDatabase, + vws_client: VWS, data: dict[str, Any], content_type: str = "application/json", -) -> requests.Response: +) -> Response: """ Return a response from a request to the endpoint to add a target. Args: - vuforia_database: The credentials to use to connect to Vuforia. + vws_client: The client to use to connect to Vuforia. data: The data to send, in JSON format, to the endpoint. content_type: The `Content-Type` header to use. Returns: The response returned by the API. """ - date = rfc_1123_date() - request_path = "/targets" - content = json.dumps(obj=data).encode(encoding="utf-8") - - authorization_string = authorization_header( - access_key=vuforia_database.server_access_key, - secret_key=vuforia_database.server_secret_key, - method=HTTPMethod.POST, - content=content, - content_type=content_type, - date=date, - request_path=request_path, - ) - - headers = { - "Authorization": authorization_string, - "Date": date, - "Content-Type": content_type, - } - - response = requests.request( + return vws_client.make_request( method=HTTPMethod.POST, - url=urljoin(base="https://vws.vuforia.com/", url=request_path), - headers=headers, data=content, - timeout=30, + request_path="/targets", + expected_result_code=ResultCodes.TARGET_CREATED.value, + content_type=content_type, ) - handle_server_errors(response=response) - return response - @beartype def _assert_oops_response(response: Response) -> None: @@ -123,7 +96,7 @@ def _assert_oops_response(response: Response) -> None: assert response.headers == expected_headers -def assert_success(response: requests.Response) -> None: +def assert_success(response: Response) -> None: """ Assert that the given response is a success response for adding a target. @@ -138,8 +111,10 @@ def assert_success(response: requests.Response) -> None: result_code=ResultCodes.TARGET_CREATED, ) expected_keys = {"result_code", "transaction_id", "target_id"} - assert response.json().keys() == expected_keys - target_id = response.json()["target_id"] + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == expected_keys + target_id = response_json["target_id"] expected_target_id_length = 32 assert len(target_id) == expected_target_id_length assert all(char in hexdigits for char in target_id) @@ -166,7 +141,7 @@ class TestContentTypes: ], ) def test_content_types( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, content_type: str, ) -> None: @@ -183,7 +158,7 @@ def test_content_types( } response = _add_target_to_vws( - vuforia_database=vuforia_database, + vws_client=vws_client, data=data, content_type=content_type, ) @@ -192,7 +167,7 @@ def test_content_types( @staticmethod def test_empty_content_type( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: """ @@ -208,14 +183,17 @@ def test_empty_content_type( "image": image_data_encoded, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - content_type="", - ) + with pytest.raises( + expected_exception=AuthenticationFailureError, + ) as exc: + _add_target_to_vws( + vws_client=vws_client, + data=data, + content_type="", + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNAUTHORIZED, result_code=ResultCodes.AUTHENTICATION_FAILURE, ) @@ -230,7 +208,7 @@ class TestMissingData: @staticmethod @pytest.mark.parametrize("data_to_remove", ["name", "width", "image"]) def test_missing_data( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, data_to_remove: str, ) -> None: @@ -238,7 +216,9 @@ def test_missing_data( `name`, `width` and `image` are all required. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii", + ) data = { "name": "example_name", @@ -247,13 +227,11 @@ def test_missing_data( } data.pop(data_to_remove) - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -272,7 +250,7 @@ class TestWidth: ids=["Negative", "Wrong Type", "None", "Zero"], ) def test_width_invalid( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, width: int | str | None, ) -> None: @@ -288,13 +266,11 @@ def test_width_invalid( "image": image_data_encoded, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -387,29 +363,30 @@ def test_name_invalid( A target's name must be a string of length 0 < N < 65, with characters in a particular range. """ + image_data = image_file_failed_state.read() + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii", + ) + data = { + "name": name, + "width": 1, + "image": image_data_encoded, + "application_metadata": None, + "active_flag": True, + } + if status_code == HTTPStatus.INTERNAL_SERVER_ERROR: with pytest.raises( expected_exception=OopsAnErrorOccurredPossiblyBadNameError, ) as oops_exc: - vws_client.add_target( - name=name, # type: ignore[arg-type] - width=1, - image=image_file_failed_state, - application_metadata=None, - active_flag=True, - ) + _add_target_to_vws(vws_client=vws_client, data=data) assert oops_exc.value.response.status_code == status_code _assert_oops_response(response=oops_exc.value.response) return with pytest.raises(expected_exception=FailError) as exc: - vws_client.add_target( - name=name, # type: ignore[arg-type] - width=1, - image=image_file_failed_state, - application_metadata=None, - active_flag=True, - ) + _add_target_to_vws(vws_client=vws_client, data=data) + assert_vws_failure( response=exc.value.response, status_code=status_code, @@ -609,7 +586,7 @@ def test_image_file_size_too_large(vws_client: VWS) -> None: @staticmethod def test_not_base64_encoded_processable( - vuforia_database: VuforiaDatabase, + vws_client: VWS, not_base64_encoded_processable: str, ) -> None: """ @@ -624,20 +601,18 @@ def test_not_base64_encoded_processable( "image": not_base64_encoded_processable, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=BadImageError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNPROCESSABLE_ENTITY, result_code=ResultCodes.BAD_IMAGE, ) @staticmethod def test_not_base64_encoded_not_processable( - vuforia_database: VuforiaDatabase, + vws_client: VWS, not_base64_encoded_not_processable: str, ) -> None: """ @@ -651,13 +626,11 @@ def test_not_base64_encoded_not_processable( "image": not_base64_encoded_not_processable, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNPROCESSABLE_ENTITY, result_code=ResultCodes.FAIL, ) @@ -687,7 +660,7 @@ def test_not_image(vws_client: VWS) -> None: @pytest.mark.parametrize("invalid_type_image", [1, None]) def test_invalid_type( invalid_type_image: int | None, - vuforia_database: VuforiaDatabase, + vws_client: VWS, ) -> None: """ If the given image is not a string, a `Fail` result is returned. @@ -698,13 +671,11 @@ def test_invalid_type( "image": invalid_type_image, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -721,13 +692,15 @@ class TestActiveFlag: def test_valid( active_flag: bool | None, image_file_failed_state: io.BytesIO, - vuforia_database: VuforiaDatabase, + vws_client: VWS, ) -> None: """ Boolean values and NULL are valid active flags. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii", + ) content_type = "application/json" data = { @@ -738,7 +711,7 @@ def test_valid( } response = _add_target_to_vws( - vuforia_database=vuforia_database, + vws_client=vws_client, data=data, content_type=content_type, ) @@ -748,7 +721,7 @@ def test_valid( @staticmethod def test_invalid( image_file_failed_state: io.BytesIO, - vuforia_database: VuforiaDatabase, + vws_client: VWS, ) -> None: """ Values which are not Boolean values or NULL are not valid active flags. @@ -765,21 +738,21 @@ def test_invalid( "active_flag": active_flag, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - content_type=content_type, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws( + vws_client=vws_client, + data=data, + content_type=content_type, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @staticmethod def test_not_set( - vuforia_database: VuforiaDatabase, vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: @@ -795,18 +768,14 @@ def test_not_set( "image": image_data_encoded, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) - - target_id = response.json()["target_id"] + response = _add_target_to_vws(vws_client=vws_client, data=data) + response_json = json.loads(s=response.text) + target_id = response_json["target_id"] target_details = vws_client.get_target_record(target_id=target_id) assert target_details.target_record.active_flag is True @staticmethod def test_set_to_none( - vuforia_database: VuforiaDatabase, vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: @@ -823,12 +792,10 @@ def test_set_to_none( "active_flag": None, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + response = _add_target_to_vws(vws_client=vws_client, data=data) - target_id = response.json()["target_id"] + response_json = json.loads(s=response.text) + target_id = response_json["target_id"] target_details = vws_client.get_target_record(target_id=target_id) assert target_details.target_record.active_flag is True @@ -841,7 +808,7 @@ class TestUnexpectedData: @staticmethod def test_invalid_extra_data( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: """ @@ -857,13 +824,11 @@ def test_invalid_extra_data( "extra_thing": 1, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -904,7 +869,7 @@ def test_base64_encoded( @staticmethod def test_null( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: """ @@ -921,7 +886,7 @@ def test_null( } response = _add_target_to_vws( - vuforia_database=vuforia_database, + vws_client=vws_client, data=request_data, ) @@ -929,7 +894,7 @@ def test_null( @staticmethod def test_invalid_type( - vuforia_database: VuforiaDatabase, + vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: """ @@ -946,13 +911,11 @@ def test_invalid_type( "application_metadata": 1, } - response = _add_target_to_vws( - vuforia_database=vuforia_database, - data=data, - ) + with pytest.raises(expected_exception=FailError) as exc: + _add_target_to_vws(vws_client=vws_client, data=data) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) From c926cf65ed82ba8fa8bd213ae7bf2cf302accb0a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 16:50:45 +0100 Subject: [PATCH 010/331] Move things around to satisfy type checkers --- tests/mock_vws/test_add_target.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 2f738ad8e..90227eddd 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -112,12 +112,12 @@ def assert_success(response: Response) -> None: ) expected_keys = {"result_code", "transaction_id", "target_id"} response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) - assert response_json.keys() == expected_keys target_id = response_json["target_id"] expected_target_id_length = 32 assert len(target_id) == expected_target_id_length assert all(char in hexdigits for char in target_id) + assert isinstance(response_json, dict) + assert response_json.keys() == expected_keys @pytest.mark.usefixtures("verify_mock_vuforia") From 801693c7f0492e43bea2a4f52f7cc923dd215945 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 18:27:38 +0100 Subject: [PATCH 011/331] Change update target tests to make the most of the new VWS Python --- pyproject.toml | 2 +- .../active_flag_validators.py | 2 +- tests/mock_vws/test_update_target.py | 204 ++++++++---------- 3 files changed, 94 insertions(+), 114 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 377b64475..0035db5b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ optional-dependencies.dev = [ "types-requests==2.32.0.20240712", "urllib3==2.2.2", "vulture==2.11", - "vws-python==2024.9.2", + "vws-python==2024.9.3.1", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] diff --git a/src/mock_vws/_services_validators/active_flag_validators.py b/src/mock_vws/_services_validators/active_flag_validators.py index a84ec1fc4..1f444d3c1 100644 --- a/src/mock_vws/_services_validators/active_flag_validators.py +++ b/src/mock_vws/_services_validators/active_flag_validators.py @@ -39,7 +39,7 @@ def validate_active_flag(*, request_body: bytes) -> None: _LOGGER.warning( msg=( - 'The value of "active_flag" is not a Boolean or NULL.' + 'The value of "active_flag" is not a Boolean or NULL. ' "This is not allowed." ), ) diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 2f37ffe55..6413da395 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -8,47 +8,45 @@ import uuid from http import HTTPMethod, HTTPStatus from typing import Any, Final -from urllib.parse import urljoin import pytest -import requests from vws import VWS +from vws.exceptions.base_exceptions import VWSError +from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import ( + AuthenticationFailureError, BadImageError, FailError, ImageTooLargeError, MetadataTooLargeError, ProjectInactiveError, TargetNameExistError, + TargetStatusNotSuccessError, ) from vws.reports import TargetStatuses -from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes -from mock_vws.database import VuforiaDatabase from tests.mock_vws.utils import make_image_file from tests.mock_vws.utils.assertions import ( assert_vws_failure, assert_vws_response, ) -from tests.mock_vws.utils.too_many_requests import handle_server_errors _MAX_METADATA_BYTES: Final[int] = 1024 * 1024 - 1 def _update_target( *, - vuforia_database: VuforiaDatabase, + vws_client: VWS, data: dict[str, Any], target_id: str, content_type: str = "application/json", -) -> requests.Response: +) -> Response: """ Make a request to the endpoint to update a target. Args: - vuforia_database: The credentials to use to connect to - Vuforia. + vws_client: The client to use to connect to Vuforia. data: The data to send, in JSON format, to the endpoint. target_id: The ID of the target to update. content_type: The `Content-Type` header to use. @@ -56,38 +54,15 @@ def _update_target( Returns: The response returned by the API. """ - date = rfc_1123_date() - request_path = "/targets/" + target_id - content = json.dumps(obj=data).encode(encoding="utf-8") - - authorization_string = authorization_header( - access_key=vuforia_database.server_access_key, - secret_key=vuforia_database.server_secret_key, + return vws_client.make_request( method=HTTPMethod.PUT, - content=content, - content_type=content_type, - date=date, - request_path=request_path, - ) - - headers = { - "Authorization": authorization_string, - "Date": date, - "Content-Type": content_type, - } - - response = requests.request( - method=HTTPMethod.PUT, - url=urljoin(base="https://vws.vuforia.com/", url=request_path), - headers=headers, data=content, - timeout=30, + request_path=f"/targets/{target_id}", + expected_result_code=ResultCodes.SUCCESS.value, + content_type=content_type, ) - handle_server_errors(response=response) - return response - @pytest.mark.usefixtures("verify_mock_vuforia") class TestUpdate: @@ -107,7 +82,6 @@ class TestUpdate: ids=["Documented Content-Type", "Undocumented Content-Type"], ) def test_content_types( - vuforia_database: VuforiaDatabase, vws_client: VWS, image_file_failed_state: io.BytesIO, content_type: str, @@ -124,23 +98,25 @@ def test_content_types( application_metadata=None, ) - response = _update_target( - vuforia_database=vuforia_database, - data={"name": "Adam"}, - target_id=target_id, - content_type=content_type, - ) + with pytest.raises( + expected_exception=TargetStatusNotSuccessError + ) as exc: + _update_target( + vws_client=vws_client, + data={"name": "Adam"}, + target_id=target_id, + content_type=content_type, + ) # Code is FORBIDDEN because the target is processing. assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.FORBIDDEN, result_code=ResultCodes.TARGET_STATUS_NOT_SUCCESS, ) @staticmethod def test_empty_content_type( - vuforia_database: VuforiaDatabase, vws_client: VWS, image_file_failed_state: io.BytesIO, ) -> None: @@ -156,22 +132,24 @@ def test_empty_content_type( application_metadata=None, ) - response = _update_target( - vuforia_database=vuforia_database, - data={"name": "Adam"}, - target_id=target_id, - content_type="", - ) + with pytest.raises( + expected_exception=AuthenticationFailureError + ) as exc: + _update_target( + vws_client=vws_client, + data={"name": "Adam"}, + target_id=target_id, + content_type="", + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNAUTHORIZED, result_code=ResultCodes.AUTHENTICATION_FAILURE, ) @staticmethod def test_no_fields_given( - vuforia_database: VuforiaDatabase, vws_client: VWS, target_id: str, ) -> None: @@ -181,7 +159,7 @@ def test_no_fields_given( vws_client.wait_for_target_processed(target_id=target_id) response = _update_target( - vuforia_database=vuforia_database, + vws_client=vws_client, data={}, target_id=target_id, ) @@ -192,7 +170,9 @@ def test_no_fields_given( result_code=ResultCodes.SUCCESS, ) - assert response.json().keys() == {"result_code", "transaction_id"} + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == {"result_code", "transaction_id"} target_details = vws_client.get_target_record(target_id=target_id) # Targets go back to processing after being updated. @@ -212,7 +192,6 @@ class TestUnexpectedData: @staticmethod def test_invalid_extra_data( - vuforia_database: VuforiaDatabase, vws_client: VWS, target_id: str, ) -> None: @@ -221,14 +200,15 @@ def test_invalid_extra_data( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"extra_thing": 1}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"extra_thing": 1}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -247,7 +227,6 @@ class TestWidth: ids=["Negative", "Wrong Type", "None", "Zero"], ) def test_width_invalid( - vuforia_database: VuforiaDatabase, vws_client: VWS, width: int | str | None, target_id: str, @@ -260,14 +239,15 @@ def test_width_invalid( target_details = vws_client.get_target_record(target_id=target_id) original_width = target_details.target_record.width - response = _update_target( - vuforia_database=vuforia_database, - data={"width": width}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"width": width}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -327,7 +307,6 @@ def test_active_flag( @staticmethod @pytest.mark.parametrize("desired_active_flag", ["string", None]) def test_invalid( - vuforia_database: VuforiaDatabase, vws_client: VWS, target_id: str, desired_active_flag: str | None, @@ -337,14 +316,15 @@ def test_invalid( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"active_flag": desired_active_flag}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"active_flag": desired_active_flag}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -383,7 +363,6 @@ def test_base64_encoded( @staticmethod @pytest.mark.parametrize("invalid_metadata", [1, None]) def test_invalid_type( - vuforia_database: VuforiaDatabase, vws_client: VWS, target_id: str, invalid_metadata: int | None, @@ -393,14 +372,15 @@ def test_invalid_type( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"application_metadata": invalid_metadata}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"application_metadata": invalid_metadata}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) @@ -542,7 +522,6 @@ def test_name_valid( def test_name_invalid( name: str | int | None, target_id: str, - vuforia_database: VuforiaDatabase, vws_client: VWS, status_code: int, result_code: ResultCodes, @@ -552,14 +531,15 @@ def test_name_invalid( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"name": name}, - target_id=target_id, - ) + with pytest.raises(expected_exception=VWSError) as exc: + _update_target( + vws_client=vws_client, + data={"name": name}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=status_code, result_code=result_code, ) @@ -749,10 +729,9 @@ def test_image_too_large(target_id: str, vws_client: VWS) -> None: @staticmethod def test_not_base64_encoded_processable( - vuforia_database: VuforiaDatabase, + vws_client: VWS, target_id: str, not_base64_encoded_processable: str, - vws_client: VWS, ) -> None: """ Some strings which are not valid base64 encoded strings are allowed as @@ -762,21 +741,21 @@ def test_not_base64_encoded_processable( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"image": not_base64_encoded_processable}, - target_id=target_id, - ) + with pytest.raises(expected_exception=BadImageError) as exc: + _update_target( + vws_client=vws_client, + data={"image": not_base64_encoded_processable}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNPROCESSABLE_ENTITY, result_code=ResultCodes.BAD_IMAGE, ) @staticmethod def test_not_base64_encoded_not_processable( - vuforia_database: VuforiaDatabase, vws_client: VWS, target_id: str, not_base64_encoded_not_processable: str, @@ -788,14 +767,15 @@ def test_not_base64_encoded_not_processable( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"image": not_base64_encoded_not_processable}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"image": not_base64_encoded_not_processable}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.UNPROCESSABLE_ENTITY, result_code=ResultCodes.FAIL, ) @@ -825,7 +805,6 @@ def test_not_image(target_id: str, vws_client: VWS) -> None: def test_invalid_type( invalid_type_image: int | None, target_id: str, - vuforia_database: VuforiaDatabase, vws_client: VWS, ) -> None: """ @@ -833,14 +812,15 @@ def test_invalid_type( """ vws_client.wait_for_target_processed(target_id=target_id) - response = _update_target( - vuforia_database=vuforia_database, - data={"image": invalid_type_image}, - target_id=target_id, - ) + with pytest.raises(expected_exception=FailError) as exc: + _update_target( + vws_client=vws_client, + data={"image": invalid_type_image}, + target_id=target_id, + ) assert_vws_failure( - response=response, + response=exc.value.response, status_code=HTTPStatus.BAD_REQUEST, result_code=ResultCodes.FAIL, ) From 394baa6a115fc3d9eb1b42437a66171127cd128f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 18:34:03 +0100 Subject: [PATCH 012/331] Fix a few bad changes --- tests/mock_vws/test_query.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 2496b6a5f..28f7c5cf6 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -1292,7 +1292,7 @@ def test_not_image(cloud_reco_client: CloudRecoService) -> None: expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImageError"' + f'"result_code":"BadImage"' "}" ) assert response.text == expected_text @@ -1520,7 +1520,7 @@ def test_max_height( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImageError"' + f'"result_code":"BadImage"' "}" ) assert response.text == expected_text @@ -1572,7 +1572,7 @@ def test_max_width(cloud_reco_client: CloudRecoService) -> None: expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImageError"' + f'"result_code":"BadImage"' "}" ) assert response.text == expected_text @@ -1657,7 +1657,7 @@ def test_unsupported( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"BadImageError"' + f'"result_code":"BadImage"' "}" ) assert response.text == expected_text @@ -2002,7 +2002,7 @@ def test_inactive_project( expected_text = ( '{"transaction_id": ' f'"{response_json["transaction_id"]}",' - f'"result_code":"InactiveProjectError"' + f'"result_code":"InactiveProject"' "}" ) assert response.text == expected_text From b64952a0495be4423287f17f0ad89f469d2f34d7 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 19:10:04 +0100 Subject: [PATCH 013/331] Remove unnecessary use of CaseInsensitiveDict from tests --- tests/mock_vws/test_add_target.py | 25 +++++++--------- tests/mock_vws/test_content_length.py | 41 +++++++++++---------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 90227eddd..6aceea55e 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -12,7 +12,6 @@ import pytest from beartype import beartype from dirty_equals import IsInstance -from requests.structures import CaseInsensitiveDict from vws import VWS from vws.exceptions.custom_exceptions import ( OopsAnErrorOccurredPossiblyBadNameError, @@ -80,19 +79,17 @@ def _assert_oops_response(response: Response) -> None: assert "Oops, an error occurred" in response.text assert "This exception has been logged with id" in response.text - expected_headers = CaseInsensitiveDict( - data={ - "Connection": "keep-alive", - "Content-Type": "text/html; charset=UTF-8", - "Date": response.headers["Date"], - "server": "envoy", - "Content-Length": "1190", - "x-envoy-upstream-service-time": IsInstance(expected_type=str), - "strict-transport-security": "max-age=31536000", - "x-aws-region": IsInstance(expected_type=str), - "x-content-type-options": "nosniff", - }, - ) + expected_headers = { + "Connection": "keep-alive", + "Content-Type": "text/html; charset=UTF-8", + "Date": response.headers["Date"], + "server": "envoy", + "Content-Length": "1190", + "x-envoy-upstream-service-time": IsInstance(expected_type=str), + "strict-transport-security": "max-age=31536000", + "x-aws-region": IsInstance(expected_type=str), + "x-content-type-options": "nosniff", + } assert response.headers == expected_headers diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index 783149f92..c98a78d97 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -8,7 +8,6 @@ import pytest import requests -from requests.structures import CaseInsensitiveDict from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -52,12 +51,10 @@ def test_not_integer(endpoint: Endpoint) -> None: netloc = urlparse(url=url).netloc if netloc == "cloudreco.vuforia.com": assert not response.text - assert response.headers == CaseInsensitiveDict( - data={ - "Content-Length": str(len(response.text)), - "Connection": "Close", - }, - ) + assert response.headers == { + "Content-Length": str(len(response.text)), + "Connection": "Close", + } return assert_valid_date_header(response=response) @@ -72,15 +69,13 @@ def test_not_integer(endpoint: Endpoint) -> None: """, ) assert response.text == expected_response_text - expected_headers = CaseInsensitiveDict( - data={ - "Content-Length": str(len(response.text)), - "Content-Type": "text/html", - "Connection": "close", - "server": "awselb/2.0", - "Date": response.headers["Date"], - }, - ) + expected_headers = { + "Content-Length": str(len(response.text)), + "Content-Type": "text/html", + "Connection": "close", + "server": "awselb/2.0", + "Date": response.headers["Date"], + } assert response.headers == expected_headers @staticmethod @@ -108,12 +103,10 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover if netloc == "cloudreco.vuforia.com": assert response.status_code == HTTPStatus.GATEWAY_TIMEOUT assert not response.text - assert response.headers == CaseInsensitiveDict( - data={ - "Content-Length": str(len(response.text)), - "Connection": "keep-alive", - }, - ) + assert response.headers == { + "Content-Length": str(len(response.text)), + "Connection": "keep-alive", + } return handle_server_errors(response=response) @@ -127,9 +120,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover "server": "envoy", "Date": response.headers["Date"], } - assert response.headers == CaseInsensitiveDict( - data=expected_headers, - ) + assert response.headers == expected_headers assert response.status_code == HTTPStatus.REQUEST_TIMEOUT @staticmethod From f54e170f7ae712b59edde7346a3878ccec4d25ef Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 22:39:28 +0100 Subject: [PATCH 014/331] Remove class-level variables from Endpoint --- tests/mock_vws/utils/__init__.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index b71601728..456e632cf 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -17,13 +17,6 @@ class Endpoint: Details of endpoints to be called in tests. """ - prepared_request: requests.PreparedRequest - successful_headers_result_code: ResultCodes - successful_headers_status_code: int - auth_header_content_type: str - access_key: str - secret_key: str - def __init__( self, prepared_request: requests.PreparedRequest, From 7f24e069f647690247ebc971dd8101231276e622 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 22:45:33 +0100 Subject: [PATCH 015/331] Make Endpoint a dataclass - simpler, and easier to change upcoming --- tests/mock_vws/utils/__init__.py | 68 +++++++++++++++----------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 456e632cf..437063763 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -4,6 +4,7 @@ import io import secrets +from dataclasses import dataclass from typing import Literal import requests @@ -12,49 +13,44 @@ from mock_vws._constants import ResultCodes +@dataclass class Endpoint: """ Details of endpoints to be called in tests. + + Args: + prepared_request: A request to make which would be successful. + successful_headers_result_code: The expected result code if the + example path is requested with the method. + successful_headers_status_code: The expected status code if the + example path is requested with the method. + access_key: The access key used in the prepared request. + secret_key: The secret key used in the prepared request. + + Attributes: + prepared_request: A request to make which would be successful. + successful_headers_result_code: The expected result code if the + example path is requested with the method. + successful_headers_status_code: The expected status code if the + example path is requested with the method. + access_key: The access key used in the prepared request. + secret_key: The secret key used in the prepared request. """ - def __init__( - self, - prepared_request: requests.PreparedRequest, - successful_headers_result_code: ResultCodes, - successful_headers_status_code: int, - access_key: str, - secret_key: str, - ) -> None: - """ - Args: - prepared_request: A request to make which would be successful. - successful_headers_result_code: The expected result code if the - example path is requested with the method. - successful_headers_status_code: The expected status code if the - example path is requested with the method. - access_key: The access key used in the prepared request. - secret_key: The secret key used in the prepared request. + prepared_request: requests.PreparedRequest + successful_headers_result_code: ResultCodes + successful_headers_status_code: int + access_key: str + secret_key: str - Attributes: - prepared_request: A request to make which would be successful. - successful_headers_result_code: The expected result code if the - example path is requested with the method. - successful_headers_status_code: The expected status code if the - example path is requested with the method. - auth_header_content_type: The content type to use for the - `Authorization` header. - access_key: The access key used in the prepared request. - secret_key: The secret key used in the prepared request. + @property + def auth_header_content_type(self) -> str: + """ + The content type to use for the `Authorization` header. """ - self.prepared_request = prepared_request - self.successful_headers_status_code = successful_headers_status_code - self.successful_headers_result_code = successful_headers_result_code - headers = prepared_request.headers - content_type = headers.get("Content-Type", "") - content_type = content_type.split(sep=";")[0] - self.auth_header_content_type: str = content_type - self.access_key = access_key - self.secret_key = secret_key + headers = self.prepared_request.headers + full_content_type = headers.get("Content-Type", "") + return full_content_type.split(sep=";")[0] def make_image_file( From 87490cf15a0543fbe9540f355b34ebf0fd250014 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 3 Sep 2024 22:49:40 +0100 Subject: [PATCH 016/331] Make Endpoint frozen - immutable means less potential for bugs --- tests/mock_vws/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 437063763..017371c9c 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -13,7 +13,7 @@ from mock_vws._constants import ResultCodes -@dataclass +@dataclass(frozen=True) class Endpoint: """ Details of endpoints to be called in tests. From a16d944543341c134f4574f545dc9273e67dd8ac Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 00:11:16 +0100 Subject: [PATCH 017/331] Move the only prepared request work to Endpoint class --- tests/mock_vws/fixtures/prepared_requests.py | 135 +++++-------- tests/mock_vws/test_authorization_header.py | 99 +++++++--- tests/mock_vws/test_content_length.py | 91 ++++++--- tests/mock_vws/test_date_header.py | 197 +++++++++++++------ tests/mock_vws/test_invalid_given_id.py | 6 +- tests/mock_vws/test_invalid_json.py | 65 ++++-- tests/mock_vws/test_requests_mock_usage.py | 22 ++- tests/mock_vws/test_unexpected_json.py | 39 ++-- tests/mock_vws/utils/__init__.py | 30 ++- 9 files changed, 428 insertions(+), 256 deletions(-) diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index 019b77c88..d9905dd6d 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -7,10 +7,8 @@ import json from http import HTTPMethod, HTTPStatus from typing import Any -from urllib.parse import urljoin import pytest -import requests from beartype import beartype from urllib3.filepost import encode_multipart_formdata from vws import VWS @@ -76,22 +74,18 @@ def add_target( headers = { "Authorization": authorization_string, "Date": date, + "Content-Length": str(len(content)), "Content-Type": content_type, } - request = requests.Request( - method=method, - url=urljoin(base=VWS_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.CREATED, successful_headers_result_code=ResultCodes.TARGET_CREATED, - prepared_request=prepared_request, + base_url=VWS_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) @@ -128,20 +122,17 @@ def delete_target( headers = { "Authorization": authorization_string, "Date": date, + "Content-Length": str(len(content)), } - request = requests.Request( + return Endpoint( + base_url=VWS_HOST, + path_url=request_path, method=method, - url=urljoin(base=VWS_HOST, url=request_path), headers=headers, data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, access_key=access_key, secret_key=secret_key, ) @@ -173,22 +164,18 @@ def database_summary(vuforia_database: VuforiaDatabase) -> Endpoint: headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, } - request = requests.Request( + return Endpoint( + base_url=VWS_HOST, + path_url=request_path, method=method, - url=urljoin(base=VWS_HOST, url=request_path), headers=headers, data=content, - ) - - prepared_request = request.prepare() - - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, access_key=access_key, secret_key=secret_key, ) @@ -226,22 +213,18 @@ def get_duplicates( headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, } - request = requests.Request( + return Endpoint( + base_url=VWS_HOST, + path_url=request_path, method=method, - url=urljoin(base=VWS_HOST, url=request_path), headers=headers, data=content, - ) - - prepared_request = request.prepare() - - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, access_key=access_key, secret_key=secret_key, ) @@ -278,22 +261,18 @@ def get_target( headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, } - request = requests.Request( - method=method, - url=urljoin(base=VWS_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, + base_url=VWS_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) @@ -325,22 +304,18 @@ def target_list(vuforia_database: VuforiaDatabase) -> Endpoint: headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, } - request = requests.Request( - method=method, - url=urljoin(base=VWS_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, + base_url=VWS_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) @@ -377,22 +352,18 @@ def target_summary( headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, } - request = requests.Request( - method=method, - url=urljoin(base=VWS_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, + base_url=VWS_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) @@ -431,23 +402,19 @@ def update_target( headers = { "Authorization": authorization_string, - "Date": date, + "Content-Length": str(len(content)), "Content-Type": content_type, + "Date": date, } - request = requests.Request( - method=method, - url=urljoin(base=VWS_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, + base_url=VWS_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) @@ -485,23 +452,19 @@ def query( headers = { "Authorization": authorization_string, + "Content-Length": str(len(content)), "Date": date, "Content-Type": content_type_header, } - request = requests.Request( - method=method, - url=urljoin(base=VWQ_HOST, url=request_path), - headers=headers, - data=content, - ) - - prepared_request = request.prepare() - return Endpoint( successful_headers_status_code=HTTPStatus.OK, successful_headers_result_code=ResultCodes.SUCCESS, - prepared_request=prepared_request, + base_url=VWQ_HOST, + path_url=request_path, + method=method, + headers=headers, + data=content, access_key=access_key, secret_key=secret_key, ) diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index 3dc966840..f3b89ebf8 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -9,7 +9,6 @@ from urllib.parse import urlparse import pytest -import requests from vws import VWS, CloudRecoService from vws.exceptions import cloud_reco_exceptions from vws.exceptions.vws_exceptions import AuthenticationFailureError, FailError @@ -39,15 +38,29 @@ def test_missing(endpoint: Endpoint) -> None: is given. """ date = rfc_1123_date() - endpoint.prepared_request.headers.update({"Date": date}) - endpoint.prepared_request.headers.pop("Authorization", None) + new_headers = { + **endpoint.headers, + "Date": date, + } + new_headers.pop("Authorization", None) + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, + ) + + response = new_endpoint.send() - session = requests.Session() - response = session.send(request=endpoint.prepared_request) handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, @@ -86,16 +99,28 @@ def test_one_part_no_space(endpoint: Endpoint) -> None: # string, but really any string which is not two parts when split on a # space will do. authorization_string = "VWS" - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, @@ -123,17 +148,28 @@ def test_one_part_with_space(endpoint: Endpoint) -> None: """ authorization_string = "VWS " date = rfc_1123_date() + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, @@ -161,16 +197,29 @@ def test_missing_signature(endpoint: Endpoint) -> None: date = rfc_1123_date() authorization_string = "VWS foobar:" - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index c98a78d97..f822055cd 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -7,7 +7,6 @@ from urllib.parse import urlparse import pytest -import requests from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -35,20 +34,34 @@ def test_not_integer(endpoint: Endpoint) -> None: A ``BAD_REQUEST`` error is given when the given ``Content-Length`` is not an integer. """ - if not endpoint.prepared_request.headers.get("Content-Type"): + if not endpoint.headers.get("Content-Type"): return content_length = "0.4" - endpoint.prepared_request.headers.update( - {"Content-Length": content_length}, + + new_headers = { + **endpoint.headers, + "Content-Length": content_length, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + + response = new_endpoint.send() + handle_server_errors(response=response) assert response.status_code == HTTPStatus.BAD_REQUEST - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert not response.text assert response.headers == { @@ -84,20 +97,31 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover """ An error is given if the given content length is too large. """ - if not endpoint.prepared_request.headers.get("Content-Type"): + if not endpoint.headers.get("Content-Type"): pytest.skip(reason="No Content-Type header for this request") - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc - content_length = str( - int(endpoint.prepared_request.headers["Content-Length"]) + 1 - ) - endpoint.prepared_request.headers.update( - {"Content-Length": content_length} + netloc = urlparse(url=endpoint.base_url).netloc + content_length = str(int(endpoint.headers["Content-Length"]) + 1) + + new_headers = { + **endpoint.headers, + "Content-Length": content_length, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + # We do not use ``handle_server_errors`` here because we do not want to # retry on the Gateway Timeout. if netloc == "cloudreco.vuforia.com": @@ -129,22 +153,33 @@ def test_too_small(endpoint: Endpoint) -> None: An ``UNAUTHORIZED`` response is given if the given content length is too small. """ - if not endpoint.prepared_request.headers.get("Content-Type"): + if not endpoint.headers.get("Content-Type"): return - content_length = str( - int(endpoint.prepared_request.headers["Content-Length"]) - 1 - ) - endpoint.prepared_request.headers.update( - {"Content-Length": content_length} + real_content_length = len(endpoint.data) + content_length = real_content_length - 1 + + new_headers = { + **endpoint.headers, + "Content-Length": str(content_length), + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 3a27d9110..4d2ed3391 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -8,7 +8,6 @@ from zoneinfo import ZoneInfo import pytest -import requests from freezegun import freeze_time from vws_auth_tools import authorization_header, rfc_1123_date @@ -42,23 +41,36 @@ def test_no_date_header(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date="", - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string} + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + } + new_headers.pop("Date", None) + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - endpoint.prepared_request.headers.pop("Date", None) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + + response = new_endpoint.send() + handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": expected_content_type = "text/plain;charset=iso-8859-1" @@ -103,26 +115,34 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date=date_incorrect_format, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - { - "Authorization": authorization_string, - "Date": date_incorrect_format, - }, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date_incorrect_format, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert response.text == "Malformed date header." assert_vwq_failure( @@ -159,8 +179,7 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: Because there is a small delay in sending requests and Vuforia isn't consistent, some leeway is given. """ - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc skew = { "vws.vuforia.com": _VWS_MAX_TIME_SKEW, "cloudreco.vuforia.com": _VWQ_MAX_TIME_SKEW, @@ -175,19 +194,33 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date} + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) # Even with the query endpoint, we get a JSON response. @@ -221,8 +254,7 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: Because there is a small delay in sending requests and Vuforia isn't consistent, some leeway is given. """ - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc skew = { "vws.vuforia.com": _VWS_MAX_TIME_SKEW, "cloudreco.vuforia.com": _VWQ_MAX_TIME_SKEW, @@ -237,19 +269,33 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) # Even with the query endpoint, we get a JSON response. @@ -282,8 +328,7 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: Because there is a small delay in sending requests and Vuforia isn't consistent, some leeway is given. """ - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc skew = { "vws.vuforia.com": _VWS_MAX_TIME_SKEW, "cloudreco.vuforia.com": _VWQ_MAX_TIME_SKEW, @@ -298,23 +343,35 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_query_success(response=response) return @@ -334,8 +391,7 @@ def test_date_in_range_before(endpoint: Endpoint) -> None: Because there is a small delay in sending requests and Vuforia isn't consistent, some leeway is given. """ - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc skew = { "vws.vuforia.com": _VWS_MAX_TIME_SKEW, "cloudreco.vuforia.com": _VWQ_MAX_TIME_SKEW, @@ -350,23 +406,36 @@ def test_date_in_range_before(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", - content=endpoint.prepared_request.body, + method=endpoint.method, + content=endpoint.data, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=endpoint.data, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_query_success(response=response) return diff --git a/tests/mock_vws/test_invalid_given_id.py b/tests/mock_vws/test_invalid_given_id.py index 364a66f7f..17117f983 100644 --- a/tests/mock_vws/test_invalid_given_id.py +++ b/tests/mock_vws/test_invalid_given_id.py @@ -6,7 +6,6 @@ from http import HTTPStatus import pytest -import requests from vws import VWS from mock_vws._constants import ResultCodes @@ -32,14 +31,13 @@ def test_not_real_id( A `NOT_FOUND` error is returned when an endpoint is given a target ID of a target which does not exist. """ - if not endpoint.prepared_request.path_url.endswith(target_id): + if not endpoint.path_url.endswith(target_id): return vws_client.wait_for_target_processed(target_id=target_id) vws_client.delete_target(target_id=target_id) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = endpoint.send() handle_server_errors(response=response) assert_vws_failure( diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index d5a48dab3..f97cd23e1 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -8,7 +8,6 @@ from zoneinfo import ZoneInfo import pytest -import requests from freezegun import freeze_time from vws_auth_tools import authorization_header, rfc_1123_date @@ -44,21 +43,34 @@ def test_invalid_json(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", + method=endpoint.method, content=content, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date} + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + "Content-Length": str(len(content)), + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=content, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - endpoint.prepared_request.body = content - endpoint.prepared_request.prepare_content_length(body=content) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) takes_json_data = ( @@ -75,8 +87,7 @@ def test_invalid_json(endpoint: Endpoint) -> None: ) return - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert_vwq_failure( response=response, @@ -113,21 +124,34 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", + method=endpoint.method, content=content, content_type=endpoint.auth_header_content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - {"Authorization": authorization_string, "Date": date}, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Content-Length": str(len(content)), + "Date": date, + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=content, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - endpoint.prepared_request.body = content - endpoint.prepared_request.prepare_content_length(body=content) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() + handle_server_errors(response=response) takes_json_data = ( @@ -144,8 +168,7 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: ) return - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": assert response.json().keys() == { "transaction_id", diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index 404bc2ac6..ad0f817cd 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -716,18 +716,22 @@ def test_text(endpoint: Endpoint) -> None: """ It is possible to send strings to VWS endpoints. """ - session = requests.Session() - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc - if endpoint.prepared_request.body is None: - endpoint.prepared_request.body = b"" + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": pytest.skip() - assert isinstance(endpoint.prepared_request.body, bytes) - endpoint.prepared_request.body = endpoint.prepared_request.body.decode( - encoding="utf-8", + assert isinstance(endpoint.data, bytes) + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=endpoint.headers, + data=endpoint.data.decode(encoding="utf-8"), + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() response.raise_for_status() diff --git a/tests/mock_vws/test_unexpected_json.py b/tests/mock_vws/test_unexpected_json.py index 6ca01a0f7..1d5743006 100644 --- a/tests/mock_vws/test_unexpected_json.py +++ b/tests/mock_vws/test_unexpected_json.py @@ -7,7 +7,6 @@ from urllib.parse import urlparse import pytest -import requests from vws_auth_tools import authorization_header, rfc_1123_date from tests.mock_vws.utils import Endpoint @@ -28,7 +27,7 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: responses. """ if ( - endpoint.prepared_request.headers.get( + endpoint.headers.get( "Content-Type", ) == "application/json" @@ -41,29 +40,37 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: authorization_string = authorization_header( access_key=endpoint.access_key, secret_key=endpoint.secret_key, - method=endpoint.prepared_request.method or "", + method=endpoint.method, content=content, content_type=content_type, date=date, - request_path=endpoint.prepared_request.path_url, + request_path=endpoint.path_url, ) - endpoint.prepared_request.headers.update( - { - "Authorization": authorization_string, - "Date": date, - "Content-Type": content_type, - }, + new_headers = { + **endpoint.headers, + "Authorization": authorization_string, + "Date": date, + "Content-Type": content_type, + "Content-Length": str(len(content)), + } + + new_endpoint = Endpoint( + base_url=endpoint.base_url, + path_url=endpoint.path_url, + method=endpoint.method, + headers=new_headers, + data=content, + successful_headers_result_code=endpoint.successful_headers_result_code, + successful_headers_status_code=endpoint.successful_headers_status_code, + access_key=endpoint.access_key, + secret_key=endpoint.secret_key, ) - endpoint.prepared_request.body = content - endpoint.prepared_request.prepare_content_length(body=content) - session = requests.Session() - response = session.send(request=endpoint.prepared_request) + response = new_endpoint.send() handle_server_errors(response=response) - url = endpoint.prepared_request.url or "" - netloc = urlparse(url=url).netloc + netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": # The multipart/formdata boundary is no longer in the given # content. diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 017371c9c..cff3ca859 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -6,9 +6,11 @@ import secrets from dataclasses import dataclass from typing import Literal +from urllib.parse import urljoin import requests from PIL import Image +from requests.structures import CaseInsensitiveDict from mock_vws._constants import ResultCodes @@ -26,6 +28,8 @@ class Endpoint: example path is requested with the method. access_key: The access key used in the prepared request. secret_key: The secret key used in the prepared request. + path_url: The path of the endpoint. + base_url: The base URL of the endpoint. Attributes: prepared_request: A request to make which would be successful. @@ -35,21 +39,41 @@ class Endpoint: example path is requested with the method. access_key: The access key used in the prepared request. secret_key: The secret key used in the prepared request. + path_url: The path of the endpoint. + base_url: The base URL of the endpoint. """ - prepared_request: requests.PreparedRequest + base_url: str + path_url: str + method: str + headers: dict[str, str] + data: bytes | str successful_headers_result_code: ResultCodes successful_headers_status_code: int access_key: str secret_key: str + def send(self) -> requests.Response: + """ + Send the request. + """ + request = requests.Request( + method=self.method, + url=urljoin(base=self.base_url, url=self.path_url), + headers=self.headers, + data=self.data, + ) + prepared_request = request.prepare() + prepared_request.headers = CaseInsensitiveDict(data=self.headers) + session = requests.Session() + return session.send(request=prepared_request) + @property def auth_header_content_type(self) -> str: """ The content type to use for the `Authorization` header. """ - headers = self.prepared_request.headers - full_content_type = headers.get("Content-Type", "") + full_content_type = self.headers.get("Content-Type", "") return full_content_type.split(sep=";")[0] From badcdc4b303e1c2eda2f0dd45fdafb0dc32e435b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 00:53:16 +0100 Subject: [PATCH 018/331] Make helper functions take custom response type - isolating requests --- tests/mock_vws/test_date_header.py | 13 ++- tests/mock_vws/test_invalid_json.py | 7 +- tests/mock_vws/test_query.py | 123 +++++++++++++++++---- tests/mock_vws/test_requests_mock_usage.py | 2 +- tests/mock_vws/utils/__init__.py | 12 +- tests/mock_vws/utils/assertions.py | 17 ++- tests/mock_vws/utils/too_many_requests.py | 14 +-- 7 files changed, 139 insertions(+), 49 deletions(-) diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 4d2ed3391..4fd43d02c 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -2,6 +2,7 @@ Tests for the `Date` header. """ +import json from datetime import datetime, timedelta from http import HTTPStatus from urllib.parse import urlparse @@ -225,8 +226,10 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == {"transaction_id", "result_code"} - assert response.json()["result_code"] == "RequestTimeTooSkewed" + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == {"transaction_id", "result_code"} + assert response_json["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, @@ -300,8 +303,10 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == {"transaction_id", "result_code"} - assert response.json()["result_code"] == "RequestTimeTooSkewed" + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == {"transaction_id", "result_code"} + assert response_json["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index f97cd23e1..1509e452a 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -2,6 +2,7 @@ Tests for giving invalid JSON to endpoints. """ +import json from datetime import datetime, timedelta from http import HTTPStatus from urllib.parse import urlparse @@ -170,11 +171,13 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == { + response_json = json.loads(s=response.text) + assert response_json["result_code"] == "RequestTimeTooSkewed" + assert isinstance(response_json, dict) + assert response_json.keys() == { "transaction_id", "result_code", } - assert response.json()["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 28f7c5cf6..050fb4c1f 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -35,6 +35,7 @@ MaxNumResultsOutOfRangeError, ) from vws.exceptions.custom_exceptions import RequestEntityTooLargeError +from vws.exceptions.response import Response from vws.reports import TargetStatuses from vws_auth_tools import authorization_header, rfc_1123_date @@ -87,7 +88,7 @@ def _query( *, vuforia_database: VuforiaDatabase, body: dict[str, Any], -) -> requests.Response: +) -> Response: """ Make a request to the endpoint to make an image recognition query. @@ -124,7 +125,7 @@ def _query( } vwq_host = "https://cloudreco.vuforia.com" - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=vwq_host, url=request_path), headers=headers, @@ -132,6 +133,14 @@ def _query( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) return response @@ -229,7 +238,7 @@ def test_incorrect_no_boundary( "Content-Type": content_type, } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -237,6 +246,14 @@ def test_incorrect_no_boundary( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert response.text == resp_text @@ -289,7 +306,7 @@ def test_incorrect_with_boundary( "Content-Type": content_type, } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -297,6 +314,14 @@ def test_incorrect_with_boundary( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert not response.text assert_vwq_failure( @@ -351,7 +376,7 @@ def test_no_boundary( "Content-Type": content_type, } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -359,6 +384,14 @@ def test_no_boundary( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) expected_text = ( @@ -409,7 +442,7 @@ def test_bogus_boundary( "Content-Type": "multipart/form-data; boundary=example_boundary", } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -417,6 +450,14 @@ def test_bogus_boundary( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) expected_text = "No image." @@ -465,7 +506,7 @@ def test_extra_section( "Content-Type": content_type_header + "; extra=1", } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -473,9 +514,18 @@ def test_extra_section( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert response_json["results"] == [] @pytest.mark.usefixtures("verify_mock_vuforia") @@ -528,7 +578,8 @@ def test_match_exact( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - (result,) = response.json()["results"] + response_json = json.loads(s=response.text) + (result,) = response_json["results"] assert result == { "target_id": target_id, "target_data": { @@ -780,7 +831,8 @@ def test_default( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - assert len(response.json()["results"]) == 1 + response_json = json.loads(s=response.text) + assert len(response_json["results"]) == 1 @staticmethod @pytest.mark.parametrize("num_results", [1, b"1", 50]) @@ -811,7 +863,8 @@ def test_valid_accepted( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert response_json["results"] == [] @staticmethod def test_valid_works( @@ -967,7 +1020,8 @@ def test_default( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" not in result_2 @@ -998,7 +1052,8 @@ def test_top( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" not in result_2 @@ -1029,7 +1084,8 @@ def test_none( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" not in result_1 assert "target_data" not in result_2 @@ -1060,7 +1116,8 @@ def test_all( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" in result_2 @@ -1148,7 +1205,7 @@ def test_valid( "Content-Type": content_type_header, } | extra_headers - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -1156,9 +1213,18 @@ def test_valid( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert response_json["results"] == [] @staticmethod def test_invalid( @@ -1196,7 +1262,7 @@ def test_invalid( "Accept": "text/html", } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -1204,6 +1270,14 @@ def test_invalid( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert_vwq_failure( @@ -1950,7 +2024,7 @@ def test_date_formats( "Content-Type": content_type_header, } - response = requests.request( + requests_response = requests.request( method=method, url=urljoin(base=VWQ_HOST, url=request_path), headers=headers, @@ -1958,9 +2032,18 @@ def test_date_formats( timeout=30, ) + response = Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) + handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert response_json["results"] == [] @pytest.mark.usefixtures("verify_mock_vuforia") diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index ad0f817cd..90711f2b7 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -734,4 +734,4 @@ def test_text(endpoint: Endpoint) -> None: secret_key=endpoint.secret_key, ) response = new_endpoint.send() - response.raise_for_status() + assert response.status_code == endpoint.successful_headers_status_code diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index cff3ca859..1bb7ed849 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -11,6 +11,7 @@ import requests from PIL import Image from requests.structures import CaseInsensitiveDict +from vws.exceptions.response import Response from mock_vws._constants import ResultCodes @@ -53,7 +54,7 @@ class Endpoint: access_key: str secret_key: str - def send(self) -> requests.Response: + def send(self) -> Response: """ Send the request. """ @@ -66,7 +67,14 @@ def send(self) -> requests.Response: prepared_request = request.prepare() prepared_request.headers = CaseInsensitiveDict(data=self.headers) session = requests.Session() - return session.send(request=prepared_request) + requests_response = session.send(request=prepared_request) + return Response( + text=requests_response.text, + url=requests_response.url, + status_code=requests_response.status_code, + headers=dict(requests_response.headers), + request_body=requests_response.request.body, + ) @property def auth_header_content_type(self) -> str: diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index 6f7a9f476..f70e855ab 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -10,7 +10,6 @@ from string import hexdigits from zoneinfo import ZoneInfo -import requests from beartype import beartype from vws.exceptions.response import Response @@ -20,7 +19,7 @@ @beartype def assert_vws_failure( *, - response: requests.Response | Response, + response: Response, status_code: int, result_code: ResultCodes, ) -> None: @@ -50,7 +49,7 @@ def assert_vws_failure( @beartype def assert_valid_date_header( *, - response: requests.Response | Response, + response: Response, ) -> None: """ Assert that a response includes a `Date` header which is within two minutes @@ -85,7 +84,7 @@ def assert_valid_date_header( @beartype def assert_valid_transaction_id( *, - response: requests.Response | Response, + response: Response, ) -> None: """ Assert that a response includes a valid transaction ID. @@ -103,7 +102,7 @@ def assert_valid_transaction_id( @beartype -def assert_json_separators(*, response: requests.Response | Response) -> None: +def assert_json_separators(*, response: Response) -> None: """ Assert that a JSON response is formatted correctly. @@ -122,7 +121,7 @@ def assert_json_separators(*, response: requests.Response | Response) -> None: @beartype def assert_vws_response( *, - response: requests.Response | Response, + response: Response, status_code: int, result_code: ResultCodes, ) -> None: @@ -174,7 +173,7 @@ def assert_vws_response( @beartype -def assert_query_success(*, response: requests.Response) -> None: +def assert_query_success(*, response: Response) -> None: """ Assert that the given response is a success response for performing an image recognition query. @@ -208,7 +207,7 @@ def assert_query_success(*, response: requests.Response) -> None: expected_response_header_not_chunked = { "Connection": "keep-alive", - "Content-Length": str(response.raw.tell()), + "Content-Length": str(len(response.text)), "Content-Type": "application/json", "Server": "nginx", } @@ -229,7 +228,7 @@ def assert_query_success(*, response: requests.Response) -> None: def assert_vwq_failure( *, - response: requests.Response | Response, + response: Response, status_code: int, content_type: str | None, cache_control: str | None, diff --git a/tests/mock_vws/utils/too_many_requests.py b/tests/mock_vws/utils/too_many_requests.py index cc2113ebe..58bb3b749 100644 --- a/tests/mock_vws/utils/too_many_requests.py +++ b/tests/mock_vws/utils/too_many_requests.py @@ -4,7 +4,6 @@ from http import HTTPStatus -import requests from beartype import beartype from vws.exceptions.custom_exceptions import ServerError from vws.exceptions.response import Response @@ -12,7 +11,7 @@ @beartype -def handle_server_errors(*, response: requests.Response) -> None: +def handle_server_errors(*, response: Response) -> None: """ Raise errors if the response is a 429 or 5xx. This is useful for retrying tests based on the exceptions they raise. @@ -22,13 +21,6 @@ def handle_server_errors(*, response: requests.Response) -> None: 429. vws.exceptions.custom_exceptions.ServerError: The response is a 5xx. """ - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request.body, - ) # We do not cover this because in some test runs we will not hit the # error. if ( @@ -36,11 +28,11 @@ def handle_server_errors(*, response: requests.Response) -> None: ): # pragma: no cover # The Vuforia API returns a 429 response with no JSON body. # We raise this here to prompt a retry at a higher level. - raise TooManyRequestsError(response=vws_response) + raise TooManyRequestsError(response=response) # We do not cover this because in some test runs we will not hit the # error. if ( response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR ): # pragma: no cover - raise ServerError(response=vws_response) + raise ServerError(response=response) From e4d53fca5ff8cf89f7d8d1871d22188b2748448c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 00:58:00 +0100 Subject: [PATCH 019/331] Fix case on one test --- src/mock_vws/_services_validators/exceptions.py | 2 +- tests/mock_vws/test_content_length.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index f528f1bf0..cce50859f 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -493,7 +493,7 @@ def __init__(self) -> None: "Connection": "close", "Content-Length": str(len(self.response_text)), "Date": date, - "server": "awselb/2.0", + "Server": "awselb/2.0", "Content-Type": "text/html", } diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index f822055cd..d451a2b32 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -86,7 +86,7 @@ def test_not_integer(endpoint: Endpoint) -> None: "Content-Length": str(len(response.text)), "Content-Type": "text/html", "Connection": "close", - "server": "awselb/2.0", + "Server": "awselb/2.0", "Date": response.headers["Date"], } assert response.headers == expected_headers From be1c5ffc0bdb66badabbcb1ed29ceabfc3c753c8 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 02:30:14 +0100 Subject: [PATCH 020/331] Remove use of raise_for_status --- tests/mock_vws/test_requests_mock_usage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index ad0f817cd..90711f2b7 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -734,4 +734,4 @@ def test_text(endpoint: Endpoint) -> None: secret_key=endpoint.secret_key, ) response = new_endpoint.send() - response.raise_for_status() + assert response.status_code == endpoint.successful_headers_status_code From 24fae8c5336c7cbdc0b4d2b45ec6dbd57f02f475 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 02:39:05 +0100 Subject: [PATCH 021/331] Reduce reliance of requests-specific methods in tests This paves the way for HTTPX / other URL libraries --- tests/mock_vws/test_date_header.py | 13 +++++++--- tests/mock_vws/test_flask_app_usage.py | 5 ++-- tests/mock_vws/test_invalid_json.py | 7 ++++-- tests/mock_vws/test_query.py | 34 ++++++++++++++++++-------- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 4d2ed3391..4fd43d02c 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -2,6 +2,7 @@ Tests for the `Date` header. """ +import json from datetime import datetime, timedelta from http import HTTPStatus from urllib.parse import urlparse @@ -225,8 +226,10 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == {"transaction_id", "result_code"} - assert response.json()["result_code"] == "RequestTimeTooSkewed" + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == {"transaction_id", "result_code"} + assert response_json["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, @@ -300,8 +303,10 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == {"transaction_id", "result_code"} - assert response.json()["result_code"] == "RequestTimeTooSkewed" + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == {"transaction_id", "result_code"} + assert response_json["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 657cb172c..6d9f7e462 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -3,6 +3,7 @@ """ import io +import json import uuid from collections.abc import Iterator from http import HTTPStatus @@ -188,7 +189,7 @@ def test_give_no_details(high_quality_image: io.BytesIO) -> None: response = requests.post(url=databases_url, json={}, timeout=30) assert response.status_code == HTTPStatus.CREATED - data = response.json() + data = json.loads(s=response.text) assert data["targets"] == [] assert data["state_name"] == "WORKING" @@ -233,7 +234,7 @@ def test_delete_database() -> None: response = requests.post(url=databases_url, json={}, timeout=30) assert response.status_code == HTTPStatus.CREATED - data = response.json() + data = json.loads(s=response.text) delete_url = databases_url + "/" + data["database_name"] response = requests.delete(url=delete_url, json={}, timeout=30) assert response.status_code == HTTPStatus.OK diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index f97cd23e1..fd2d68110 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -2,6 +2,7 @@ Tests for giving invalid JSON to endpoints. """ +import json from datetime import datetime, timedelta from http import HTTPStatus from urllib.parse import urlparse @@ -170,11 +171,13 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": - assert response.json().keys() == { + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json.keys() == { "transaction_id", "result_code", } - assert response.json()["result_code"] == "RequestTimeTooSkewed" + assert response_json["result_code"] == "RequestTimeTooSkewed" assert_valid_transaction_id(response=response) assert_vwq_failure( response=response, diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 28f7c5cf6..ae05dc687 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -475,7 +475,9 @@ def test_extra_section( handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json["results"] == [] @pytest.mark.usefixtures("verify_mock_vuforia") @@ -528,7 +530,8 @@ def test_match_exact( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - (result,) = response.json()["results"] + response_json = json.loads(s=response.text) + (result,) = response_json["results"] assert result == { "target_id": target_id, "target_data": { @@ -780,7 +783,8 @@ def test_default( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - assert len(response.json()["results"]) == 1 + response_json = json.loads(s=response.text) + assert len(response_json["results"]) == 1 @staticmethod @pytest.mark.parametrize("num_results", [1, b"1", 50]) @@ -811,7 +815,9 @@ def test_valid_accepted( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json["results"] == [] @staticmethod def test_valid_works( @@ -967,7 +973,8 @@ def test_default( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" not in result_2 @@ -998,7 +1005,8 @@ def test_top( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" not in result_2 @@ -1029,7 +1037,8 @@ def test_none( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" not in result_1 assert "target_data" not in result_2 @@ -1060,7 +1069,8 @@ def test_all( response = _query(vuforia_database=vuforia_database, body=body) assert_query_success(response=response) - result_1, result_2 = response.json()["results"] + response_json = json.loads(s=response.text) + result_1, result_2 = response_json["results"] assert "target_data" in result_1 assert "target_data" in result_2 @@ -1158,7 +1168,9 @@ def test_valid( handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json["results"] == [] @staticmethod def test_invalid( @@ -1960,7 +1972,9 @@ def test_date_formats( handle_server_errors(response=response) assert_query_success(response=response) - assert response.json()["results"] == [] + response_json = json.loads(s=response.text) + assert isinstance(response_json, dict) + assert response_json["results"] == [] @pytest.mark.usefixtures("verify_mock_vuforia") From ae4f50557a0ea82514b576cc80367dcb8ba24867 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 02:55:07 +0100 Subject: [PATCH 022/331] Remove some isinstance checks --- tests/mock_vws/test_query.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index d7a16b90b..050fb4c1f 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -525,7 +525,6 @@ def test_extra_section( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @@ -865,7 +864,6 @@ def test_valid_accepted( assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @staticmethod @@ -1226,7 +1224,6 @@ def test_valid( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @staticmethod @@ -2046,7 +2043,6 @@ def test_date_formats( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] From 0363965903befd10d94691d7c573b21316cc12a0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 02:58:05 +0100 Subject: [PATCH 023/331] Remove unnecessary isinstance checks --- tests/mock_vws/test_query.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index ae05dc687..fb4881eae 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -476,7 +476,6 @@ def test_extra_section( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @@ -816,7 +815,6 @@ def test_valid_accepted( assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @staticmethod @@ -1169,7 +1167,6 @@ def test_valid( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] @staticmethod @@ -1525,7 +1522,6 @@ def test_max_height( response_json = json.loads(s=response.text) assert isinstance(response_json, dict) - assert response_json.keys() == {"transaction_id", "result_code"} assert_valid_transaction_id(response=response) # The separators are inconsistent and we test this. @@ -1973,7 +1969,6 @@ def test_date_formats( handle_server_errors(response=response) assert_query_success(response=response) response_json = json.loads(s=response.text) - assert isinstance(response_json, dict) assert response_json["results"] == [] From c379c324015cb5dc3d8372ece3b7c253764c31ee Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 03:12:13 +0100 Subject: [PATCH 024/331] Make handle_server_errors take new Response type Progress towards de-coupling test suite from requests --- tests/mock_vws/test_authorization_header.py | 37 +++++++++- tests/mock_vws/test_content_length.py | 28 ++++++- tests/mock_vws/test_date_header.py | 55 ++++++++++++-- tests/mock_vws/test_invalid_given_id.py | 10 ++- tests/mock_vws/test_invalid_json.py | 19 ++++- tests/mock_vws/test_query.py | 82 ++++++++++++++++++--- tests/mock_vws/test_unexpected_json.py | 10 ++- tests/mock_vws/utils/too_many_requests.py | 14 +--- 8 files changed, 218 insertions(+), 37 deletions(-) diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index f3b89ebf8..8b9b52e37 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -11,6 +11,7 @@ import pytest from vws import VWS, CloudRecoService from vws.exceptions import cloud_reco_exceptions +from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import AuthenticationFailureError, FailError from vws_auth_tools import rfc_1123_date @@ -58,7 +59,14 @@ def test_missing(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -118,7 +126,14 @@ def test_one_part_no_space(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -167,7 +182,14 @@ def test_one_part_with_space(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -216,8 +238,15 @@ def test_missing_signature(endpoint: Endpoint) -> None: ) response = new_endpoint.send() + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) - handle_server_errors(response=response) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index f822055cd..dfe1c34e7 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -7,6 +7,7 @@ from urllib.parse import urlparse import pytest +from vws.exceptions.response import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -58,7 +59,14 @@ def test_not_integer(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert response.status_code == HTTPStatus.BAD_REQUEST netloc = urlparse(url=endpoint.base_url).netloc @@ -133,7 +141,14 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover } return - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_valid_date_header(response=response) # We have seen both of these response texts. assert response.text in {"stream timeout", ""} @@ -177,7 +192,14 @@ def test_too_small(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 4fd43d02c..e184578e4 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -10,6 +10,7 @@ import pytest from freezegun import freeze_time +from vws.exceptions.response import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -69,7 +70,14 @@ def test_no_date_header(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc @@ -141,7 +149,14 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: secret_key=endpoint.secret_key, ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -222,7 +237,14 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": @@ -299,7 +321,14 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": @@ -374,7 +403,14 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -438,7 +474,14 @@ def test_date_in_range_before(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_invalid_given_id.py b/tests/mock_vws/test_invalid_given_id.py index 17117f983..a540f7844 100644 --- a/tests/mock_vws/test_invalid_given_id.py +++ b/tests/mock_vws/test_invalid_given_id.py @@ -7,6 +7,7 @@ import pytest from vws import VWS +from vws.exceptions.response import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -38,7 +39,14 @@ def test_not_real_id( vws_client.delete_target(target_id=target_id) response = endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_vws_failure( response=response, diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index fd2d68110..7b84826ff 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -10,6 +10,7 @@ import pytest from freezegun import freeze_time +from vws.exceptions.response import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -72,7 +73,14 @@ def test_invalid_json(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) takes_json_data = ( endpoint.auth_header_content_type == "application/json" @@ -153,7 +161,14 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) takes_json_data = ( endpoint.auth_header_content_type == "application/json" diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index fb4881eae..bb8981a96 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -35,6 +35,7 @@ MaxNumResultsOutOfRangeError, ) from vws.exceptions.custom_exceptions import RequestEntityTooLargeError +from vws.exceptions.response import Response from vws.reports import TargetStatuses from vws_auth_tools import authorization_header, rfc_1123_date @@ -132,7 +133,14 @@ def _query( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) return response @@ -237,7 +245,14 @@ def test_incorrect_no_boundary( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert response.text == resp_text assert_vwq_failure( @@ -297,7 +312,14 @@ def test_incorrect_with_boundary( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert not response.text assert_vwq_failure( response=response, @@ -359,7 +381,14 @@ def test_no_boundary( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) expected_text = ( "java.io.IOException: RESTEASY007550: " @@ -417,7 +446,14 @@ def test_bogus_boundary( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) expected_text = "No image." assert response.text == expected_text @@ -473,7 +509,14 @@ def test_extra_section( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_query_success(response=response) response_json = json.loads(s=response.text) assert response_json["results"] == [] @@ -1164,7 +1207,14 @@ def test_valid( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_query_success(response=response) response_json = json.loads(s=response.text) assert response_json["results"] == [] @@ -1213,7 +1263,14 @@ def test_invalid( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_vwq_failure( response=response, @@ -1966,7 +2023,14 @@ def test_date_formats( timeout=30, ) - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) assert_query_success(response=response) response_json = json.loads(s=response.text) assert response_json["results"] == [] diff --git a/tests/mock_vws/test_unexpected_json.py b/tests/mock_vws/test_unexpected_json.py index 1d5743006..d7abf3411 100644 --- a/tests/mock_vws/test_unexpected_json.py +++ b/tests/mock_vws/test_unexpected_json.py @@ -7,6 +7,7 @@ from urllib.parse import urlparse import pytest +from vws.exceptions.response import Response from vws_auth_tools import authorization_header, rfc_1123_date from tests.mock_vws.utils import Endpoint @@ -68,7 +69,14 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - handle_server_errors(response=response) + vws_response = Response( + text=response.text, + url=response.url, + status_code=response.status_code, + headers=dict(response.headers), + request_body=response.request.body, + ) + handle_server_errors(response=vws_response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/utils/too_many_requests.py b/tests/mock_vws/utils/too_many_requests.py index cc2113ebe..58bb3b749 100644 --- a/tests/mock_vws/utils/too_many_requests.py +++ b/tests/mock_vws/utils/too_many_requests.py @@ -4,7 +4,6 @@ from http import HTTPStatus -import requests from beartype import beartype from vws.exceptions.custom_exceptions import ServerError from vws.exceptions.response import Response @@ -12,7 +11,7 @@ @beartype -def handle_server_errors(*, response: requests.Response) -> None: +def handle_server_errors(*, response: Response) -> None: """ Raise errors if the response is a 429 or 5xx. This is useful for retrying tests based on the exceptions they raise. @@ -22,13 +21,6 @@ def handle_server_errors(*, response: requests.Response) -> None: 429. vws.exceptions.custom_exceptions.ServerError: The response is a 5xx. """ - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request.body, - ) # We do not cover this because in some test runs we will not hit the # error. if ( @@ -36,11 +28,11 @@ def handle_server_errors(*, response: requests.Response) -> None: ): # pragma: no cover # The Vuforia API returns a 429 response with no JSON body. # We raise this here to prompt a retry at a higher level. - raise TooManyRequestsError(response=vws_response) + raise TooManyRequestsError(response=response) # We do not cover this because in some test runs we will not hit the # error. if ( response.status_code >= HTTPStatus.INTERNAL_SERVER_ERROR ): # pragma: no cover - raise ServerError(response=vws_response) + raise ServerError(response=response) From ca76c1226ec5a8d98bf22c92521f8d27a21ecd89 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 04:41:06 +0100 Subject: [PATCH 025/331] Bump vws-python --- pyproject.toml | 2 +- tests/mock_vws/test_add_target.py | 2 +- tests/mock_vws/test_authorization_header.py | 6 +++++- tests/mock_vws/test_content_length.py | 5 ++++- tests/mock_vws/test_date_header.py | 8 +++++++- tests/mock_vws/test_invalid_given_id.py | 3 ++- tests/mock_vws/test_invalid_json.py | 4 +++- tests/mock_vws/test_query.py | 11 ++++++++++- tests/mock_vws/test_unexpected_json.py | 3 ++- tests/mock_vws/test_update_target.py | 2 +- tests/mock_vws/utils/assertions.py | 2 +- tests/mock_vws/utils/too_many_requests.py | 2 +- 12 files changed, 38 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 0035db5b6..e65651b2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ optional-dependencies.dev = [ "types-requests==2.32.0.20240712", "urllib3==2.2.2", "vulture==2.11", - "vws-python==2024.9.3.1", + "vws-python==2024.9.4", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 6aceea55e..d3947f68d 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -16,7 +16,6 @@ from vws.exceptions.custom_exceptions import ( OopsAnErrorOccurredPossiblyBadNameError, ) -from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import ( AuthenticationFailureError, BadImageError, @@ -26,6 +25,7 @@ ProjectInactiveError, TargetNameExistError, ) +from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import make_image_file diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index 8b9b52e37..f8286163c 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -11,8 +11,8 @@ import pytest from vws import VWS, CloudRecoService from vws.exceptions import cloud_reco_exceptions -from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import AuthenticationFailureError, FailError +from vws.types import Response from vws_auth_tools import rfc_1123_date from mock_vws._constants import ResultCodes @@ -65,6 +65,7 @@ def test_missing(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -132,6 +133,7 @@ def test_one_part_no_space(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -188,6 +190,7 @@ def test_one_part_with_space(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -244,6 +247,7 @@ def test_missing_signature(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index dfe1c34e7..0bf644e06 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse import pytest -from vws.exceptions.response import Response +from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -65,6 +65,7 @@ def test_not_integer(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert response.status_code == HTTPStatus.BAD_REQUEST @@ -147,6 +148,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert_valid_date_header(response=response) @@ -198,6 +200,7 @@ def test_too_small(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index e184578e4..ce02d1baf 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -10,7 +10,7 @@ import pytest from freezegun import freeze_time -from vws.exceptions.response import Response +from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -76,6 +76,7 @@ def test_no_date_header(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -155,6 +156,7 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -243,6 +245,7 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -327,6 +330,7 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -409,6 +413,7 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -480,6 +485,7 @@ def test_date_in_range_before(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_invalid_given_id.py b/tests/mock_vws/test_invalid_given_id.py index a540f7844..99ec327fd 100644 --- a/tests/mock_vws/test_invalid_given_id.py +++ b/tests/mock_vws/test_invalid_given_id.py @@ -7,7 +7,7 @@ import pytest from vws import VWS -from vws.exceptions.response import Response +from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -45,6 +45,7 @@ def test_not_real_id( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index 7b84826ff..e04215e68 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -10,7 +10,7 @@ import pytest from freezegun import freeze_time -from vws.exceptions.response import Response +from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -79,6 +79,7 @@ def test_invalid_json(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -167,6 +168,7 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index bb8981a96..b4df55556 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -35,8 +35,8 @@ MaxNumResultsOutOfRangeError, ) from vws.exceptions.custom_exceptions import RequestEntityTooLargeError -from vws.exceptions.response import Response from vws.reports import TargetStatuses +from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws.database import VuforiaDatabase @@ -139,6 +139,7 @@ def _query( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) return response @@ -251,6 +252,7 @@ def test_incorrect_no_boundary( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -318,6 +320,7 @@ def test_incorrect_with_boundary( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert not response.text @@ -387,6 +390,7 @@ def test_no_boundary( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -452,6 +456,7 @@ def test_bogus_boundary( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -515,6 +520,7 @@ def test_extra_section( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert_query_success(response=response) @@ -1213,6 +1219,7 @@ def test_valid( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert_query_success(response=response) @@ -1269,6 +1276,7 @@ def test_invalid( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) @@ -2029,6 +2037,7 @@ def test_date_formats( status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) assert_query_success(response=response) diff --git a/tests/mock_vws/test_unexpected_json.py b/tests/mock_vws/test_unexpected_json.py index d7abf3411..d3d4fd61b 100644 --- a/tests/mock_vws/test_unexpected_json.py +++ b/tests/mock_vws/test_unexpected_json.py @@ -7,7 +7,7 @@ from urllib.parse import urlparse import pytest -from vws.exceptions.response import Response +from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from tests.mock_vws.utils import Endpoint @@ -75,6 +75,7 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: status_code=response.status_code, headers=dict(response.headers), request_body=response.request.body, + raw=response.raw, ) handle_server_errors(response=vws_response) diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 6413da395..1b8fc64f5 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -12,7 +12,6 @@ import pytest from vws import VWS from vws.exceptions.base_exceptions import VWSError -from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import ( AuthenticationFailureError, BadImageError, @@ -24,6 +23,7 @@ TargetStatusNotSuccessError, ) from vws.reports import TargetStatuses +from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import make_image_file diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index 6f7a9f476..bb7718cba 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -12,7 +12,7 @@ import requests from beartype import beartype -from vws.exceptions.response import Response +from vws.types import Response from mock_vws._constants import ResultCodes diff --git a/tests/mock_vws/utils/too_many_requests.py b/tests/mock_vws/utils/too_many_requests.py index 58bb3b749..c08063dd2 100644 --- a/tests/mock_vws/utils/too_many_requests.py +++ b/tests/mock_vws/utils/too_many_requests.py @@ -6,8 +6,8 @@ from beartype import beartype from vws.exceptions.custom_exceptions import ServerError -from vws.exceptions.response import Response from vws.exceptions.vws_exceptions import TooManyRequestsError +from vws.types import Response @beartype From 6915cda8760d4e88921450e72353c5ddc4b84d57 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 05:51:43 +0100 Subject: [PATCH 026/331] Bump VWS-Python and use tell position --- pyproject.toml | 2 +- tests/mock_vws/test_authorization_header.py | 42 ++------------ tests/mock_vws/test_content_length.py | 33 ++--------- tests/mock_vws/test_date_header.py | 63 +++------------------ tests/mock_vws/test_invalid_given_id.py | 12 +--- tests/mock_vws/test_invalid_json.py | 21 +------ tests/mock_vws/test_query.py | 18 +++--- tests/mock_vws/test_unexpected_json.py | 12 +--- tests/mock_vws/utils/__init__.py | 2 +- tests/mock_vws/utils/assertions.py | 2 +- 10 files changed, 34 insertions(+), 173 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e65651b2b..ae8f41a52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -95,7 +95,7 @@ optional-dependencies.dev = [ "types-requests==2.32.0.20240712", "urllib3==2.2.2", "vulture==2.11", - "vws-python==2024.9.4", + "vws-python==2024.9.4.1", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index c79b171f4..c0a710aff 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -12,7 +12,6 @@ from vws import VWS, CloudRecoService from vws.exceptions import cloud_reco_exceptions from vws.exceptions.vws_exceptions import AuthenticationFailureError, FailError -from vws.types import Response from vws_auth_tools import rfc_1123_date from mock_vws._constants import ResultCodes @@ -59,15 +58,7 @@ def test_missing(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -127,15 +118,7 @@ def test_one_part_no_space(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -184,15 +167,7 @@ def test_one_part_with_space(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -241,16 +216,7 @@ def test_missing_signature(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index cc057b496..65e0e6770 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -7,7 +7,6 @@ from urllib.parse import urlparse import pytest -from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -58,16 +57,7 @@ def test_not_integer(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) assert response.status_code == HTTPStatus.BAD_REQUEST netloc = urlparse(url=endpoint.base_url).netloc @@ -142,15 +132,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover } return - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) assert_valid_date_header(response=response) # We have seen both of these response texts. assert response.text in {"stream timeout", ""} @@ -194,15 +176,8 @@ def test_too_small(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index b1771d1b8..827d2379e 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -10,7 +10,6 @@ import pytest from freezegun import freeze_time -from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -70,15 +69,7 @@ def test_no_date_header(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc @@ -150,15 +141,8 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: secret_key=endpoint.secret_key, ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -239,15 +223,7 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": @@ -324,15 +300,7 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) # Even with the query endpoint, we get a JSON response. if netloc == "cloudreco.vuforia.com": @@ -407,15 +375,8 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": @@ -479,15 +440,7 @@ def test_date_in_range_before(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/test_invalid_given_id.py b/tests/mock_vws/test_invalid_given_id.py index 2f528139d..ed16bb2f1 100644 --- a/tests/mock_vws/test_invalid_given_id.py +++ b/tests/mock_vws/test_invalid_given_id.py @@ -7,7 +7,6 @@ import pytest from vws import VWS -from vws.types import Response from mock_vws._constants import ResultCodes from tests.mock_vws.utils import Endpoint @@ -39,15 +38,8 @@ def test_not_real_id( vws_client.delete_target(target_id=target_id) response = endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + + handle_server_errors(response=response) assert_vws_failure( response=response, diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index 9072c7f7b..fd2d68110 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -10,7 +10,6 @@ import pytest from freezegun import freeze_time -from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from mock_vws._constants import ResultCodes @@ -73,15 +72,7 @@ def test_invalid_json(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) takes_json_data = ( endpoint.auth_header_content_type == "application/json" @@ -162,15 +153,7 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + handle_server_errors(response=response) takes_json_data = ( endpoint.auth_header_content_type == "application/json" diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 7875b1b0f..0ac5ed95d 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -139,7 +139,7 @@ def _query( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) return vws_response @@ -252,7 +252,7 @@ def test_incorrect_no_boundary( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) @@ -320,7 +320,7 @@ def test_incorrect_with_boundary( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) assert not requests_response.text @@ -390,7 +390,7 @@ def test_no_boundary( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) @@ -456,7 +456,7 @@ def test_bogus_boundary( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) @@ -520,7 +520,7 @@ def test_extra_section( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) assert_query_success(response=vws_response) @@ -1219,7 +1219,7 @@ def test_valid( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) assert_query_success(response=vws_response) @@ -1276,7 +1276,7 @@ def test_invalid( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) @@ -2037,7 +2037,7 @@ def test_date_formats( status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) handle_server_errors(response=vws_response) assert_query_success(response=vws_response) diff --git a/tests/mock_vws/test_unexpected_json.py b/tests/mock_vws/test_unexpected_json.py index 14928fe6d..beaac61f9 100644 --- a/tests/mock_vws/test_unexpected_json.py +++ b/tests/mock_vws/test_unexpected_json.py @@ -7,7 +7,6 @@ from urllib.parse import urlparse import pytest -from vws.types import Response from vws_auth_tools import authorization_header, rfc_1123_date from tests.mock_vws.utils import Endpoint @@ -69,15 +68,8 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: ) response = new_endpoint.send() - vws_response = Response( - text=response.text, - url=response.url, - status_code=response.status_code, - headers=dict(response.headers), - request_body=response.request_body, - raw=response.raw, - ) - handle_server_errors(response=vws_response) + + handle_server_errors(response=response) netloc = urlparse(url=endpoint.base_url).netloc if netloc == "cloudreco.vuforia.com": diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 3a916bf3e..4519b350a 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -74,7 +74,7 @@ def send(self) -> Response: status_code=requests_response.status_code, headers=dict(requests_response.headers), request_body=requests_response.request.body, - raw=requests_response.raw, + tell_position=requests_response.raw.tell(), ) @property diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index bacb9aeb4..76deda009 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -207,7 +207,7 @@ def assert_query_success(*, response: Response) -> None: expected_response_header_not_chunked = { "Connection": "keep-alive", - "Content-Length": str(len(response.text)), + "Content-Length": str(response.tell_position), "Content-Type": "application/json", "Server": "nginx", } From 2b21c6e4b3a654ef791f151315b2aea7b7d6ad9a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 06:13:17 +0100 Subject: [PATCH 027/331] Use kwarg for .decode( --- tests/mock_vws/fixtures/prepared_requests.py | 4 +- tests/mock_vws/test_add_target.py | 44 +++++++++++++++----- tests/mock_vws/test_query.py | 20 ++++++--- tests/mock_vws/test_update_target.py | 8 +++- 4 files changed, 57 insertions(+), 19 deletions(-) diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index d9905dd6d..ab0ec04d3 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -46,7 +46,9 @@ def add_target( Return details of the endpoint for adding a target. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) date = rfc_1123_date() data: dict[str, Any] = { "name": "example_name", diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index d3947f68d..30a32f10f 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -146,7 +146,9 @@ def test_content_types( Any non-empty ``Content-Type`` header is allowed. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "example", @@ -172,7 +174,9 @@ def test_empty_content_type( header is given. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "example", @@ -255,7 +259,9 @@ def test_width_invalid( The width must be a number greater than zero. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "example_name", @@ -725,7 +731,9 @@ def test_invalid( """ active_flag = "string" image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) content_type = "application/json" data = { @@ -757,7 +765,9 @@ def test_not_set( The active flag defaults to True if it is not set. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "my_example_name", @@ -780,7 +790,9 @@ def test_set_to_none( The active flag defaults to True if it is set to NULL. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "my_example_name", @@ -812,7 +824,9 @@ def test_invalid_extra_data( A `BAD_REQUEST` response is returned when unexpected data is given. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "example_name", @@ -854,7 +868,9 @@ def test_base64_encoded( """ A base64 encoded string is valid application metadata. """ - metadata_encoded = base64.b64encode(s=metadata).decode("ascii") + metadata_encoded = base64.b64encode(s=metadata).decode( + encoding="ascii" + ) vws_client.add_target( name="example", @@ -873,7 +889,9 @@ def test_null( NULL is valid application metadata. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) request_data = { "name": "example_name", @@ -899,7 +917,9 @@ def test_invalid_type( metadata. """ image_data = image_file_failed_state.read() - image_data_encoded = base64.b64encode(s=image_data).decode("ascii") + image_data_encoded = base64.b64encode(s=image_data).decode( + encoding="ascii" + ) data = { "name": "example_name", @@ -970,7 +990,9 @@ def test_metadata_too_large( for application metadata. """ metadata = b"a" * (_MAX_METADATA_BYTES + 1) - metadata_encoded = base64.b64encode(s=metadata).decode("ascii") + metadata_encoded = base64.b64encode(s=metadata).decode( + encoding="ascii" + ) with pytest.raises(expected_exception=MetadataTooLargeError) as exc: vws_client.add_target( diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 0ac5ed95d..d8b299a25 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -558,7 +558,9 @@ def test_match_exact( """ image_file = high_quality_image image_content = image_file.getvalue() - metadata_encoded = base64.b64encode(s=b"example").decode("ascii") + metadata_encoded = base64.b64encode(s=b"example").decode( + encoding="ascii" + ) name = "example_name" target_id = vws_client.add_target( @@ -604,7 +606,9 @@ def test_low_quality_image( results are returned. """ image_file = image_file_success_state_low_rating - metadata_encoded = base64.b64encode(s=b"example").decode("ascii") + metadata_encoded = base64.b64encode(s=b"example").decode( + encoding="ascii" + ) name = "example_name" target_id = vws_client.add_target( @@ -630,7 +634,9 @@ def test_match_similar( If a similar image to one that was added is queried for, target data is shown. """ - metadata_encoded = base64.b64encode(s=b"example").decode("ascii") + metadata_encoded = base64.b64encode(s=b"example").decode( + encoding="ascii" + ) name_matching = "example_name_matching" name_not_matching = "example_name_not_matching" @@ -1801,7 +1807,9 @@ def test_updated_target( metadata. """ metadata = b"example_metadata" - metadata_encoded = base64.b64encode(s=metadata).decode("ascii") + metadata_encoded = base64.b64encode(s=metadata).decode( + encoding="ascii" + ) name = "example_name" target_id = vws_client.add_target( name=name, @@ -1817,7 +1825,9 @@ def test_updated_target( new_name = name + "2" new_metadata = metadata + b"2" - new_metadata_encoded = base64.b64encode(s=new_metadata).decode("ascii") + new_metadata_encoded = base64.b64encode(s=new_metadata).decode( + encoding="ascii" + ) results = cloud_reco_client.query(image=high_quality_image) (result,) = results diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index 1b8fc64f5..bffb2da26 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -353,7 +353,9 @@ def test_base64_encoded( """ A base64 encoded string is valid application metadata. """ - metadata_encoded = base64.b64encode(s=metadata).decode("ascii") + metadata_encoded = base64.b64encode(s=metadata).decode( + encoding="ascii" + ) vws_client.wait_for_target_processed(target_id=target_id) vws_client.update_target( target_id=target_id, @@ -433,7 +435,9 @@ def test_metadata_too_large(vws_client: VWS, target_id: str) -> None: for application metadata. """ metadata = b"a" * (_MAX_METADATA_BYTES + 1) - metadata_encoded = base64.b64encode(s=metadata).decode("ascii") + metadata_encoded = base64.b64encode(s=metadata).decode( + encoding="ascii" + ) vws_client.wait_for_target_processed(target_id=target_id) with pytest.raises(expected_exception=MetadataTooLargeError) as exc: From cf0841d82595bf5129b435be4591f076613e87f0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 06:20:36 +0100 Subject: [PATCH 028/331] Use keyword arguments for parametrize calls --- tests/mock_vws/test_add_target.py | 31 +++++++++++------- tests/mock_vws/test_query.py | 46 +++++++++++++++++---------- tests/mock_vws/test_target_raters.py | 2 +- tests/mock_vws/test_target_summary.py | 2 +- tests/mock_vws/test_update_target.py | 38 ++++++++++++++-------- 5 files changed, 76 insertions(+), 43 deletions(-) diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index 30a32f10f..cb751d9ed 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -125,8 +125,8 @@ class TestContentTypes: @staticmethod @pytest.mark.parametrize( - "content_type", - [ + argnames="content_type", + argvalues=[ # This is the documented required content type: "application/json", # Other content types also work. @@ -207,7 +207,10 @@ class TestMissingData: """ @staticmethod - @pytest.mark.parametrize("data_to_remove", ["name", "width", "image"]) + @pytest.mark.parametrize( + argnames="data_to_remove", + argvalues=["name", "width", "image"], + ) def test_missing_data( vws_client: VWS, image_file_failed_state: io.BytesIO, @@ -246,8 +249,8 @@ class TestWidth: @staticmethod @pytest.mark.parametrize( - "width", - [-1, "10", None, 0], + argnames="width", + argvalues=[-1, "10", None, 0], ids=["Negative", "Wrong Type", "None", "Zero"], ) def test_width_invalid( @@ -306,8 +309,8 @@ class TestTargetName: @staticmethod @pytest.mark.parametrize( - "name", - [ + argnames="name", + argvalues=[ "á", # We test just below the max character value. # This is because targets with the max character value in their @@ -660,7 +663,10 @@ def test_not_image(vws_client: VWS) -> None: ) @staticmethod - @pytest.mark.parametrize("invalid_type_image", [1, None]) + @pytest.mark.parametrize( + argnames="invalid_type_image", + argvalues=[1, None], + ) def test_invalid_type( invalid_type_image: int | None, vws_client: VWS, @@ -691,7 +697,10 @@ class TestActiveFlag: """ @staticmethod - @pytest.mark.parametrize("active_flag", [True, False, None]) + @pytest.mark.parametrize( + argnames="active_flag", + argvalues=[True, False, None], + ) def test_valid( active_flag: bool | None, image_file_failed_state: io.BytesIO, @@ -853,8 +862,8 @@ class TestApplicationMetadata: @staticmethod @pytest.mark.parametrize( - "metadata", - [ + argnames="metadata", + argvalues=[ b"a", b"a" * _MAX_METADATA_BYTES, ], diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index d8b299a25..65c2c1d54 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -335,8 +335,8 @@ def test_incorrect_with_boundary( @staticmethod @pytest.mark.parametrize( - "content_type", - [ + argnames="content_type", + argvalues=[ "multipart/form-data", "multipart/form-data; extra", "multipart/form-data; extra=1", @@ -841,7 +841,7 @@ def test_default( assert len(response_json["results"]) == 1 @staticmethod - @pytest.mark.parametrize("num_results", [1, b"1", 50]) + @pytest.mark.parametrize(argnames="num_results", argvalues=[1, b"1", 50]) def test_valid_accepted( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, @@ -896,7 +896,7 @@ def test_valid_works( assert len(result) == max_num_results @staticmethod - @pytest.mark.parametrize("num_results", [-1, 0, 51]) + @pytest.mark.parametrize(argnames="num_results", argvalues=[-1, 0, 51]) def test_out_of_range( high_quality_image: io.BytesIO, num_results: int, @@ -935,8 +935,8 @@ def test_out_of_range( @staticmethod @pytest.mark.parametrize( - "num_results", - [b"0.1", b"1.1", b"a", b"2147483648"], + argnames="num_results", + argvalues=[b"0.1", b"1.1", b"a", b"2147483648"], ) def test_invalid_type( high_quality_image: io.BytesIO, @@ -1032,7 +1032,10 @@ def test_default( assert "target_data" not in result_2 @staticmethod - @pytest.mark.parametrize("include_target_data", ["top", "TOP"]) + @pytest.mark.parametrize( + argnames="include_target_data", + argvalues=["top", "TOP"], + ) def test_top( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, @@ -1064,7 +1067,10 @@ def test_top( assert "target_data" not in result_2 @staticmethod - @pytest.mark.parametrize("include_target_data", ["none", "NONE"]) + @pytest.mark.parametrize( + argnames="include_target_data", + argvalues=["none", "NONE"], + ) def test_none( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, @@ -1096,7 +1102,10 @@ def test_none( assert "target_data" not in result_2 @staticmethod - @pytest.mark.parametrize("include_target_data", ["all", "ALL"]) + @pytest.mark.parametrize( + argnames="include_target_data", + argvalues=["all", "ALL"], + ) def test_all( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, @@ -1128,7 +1137,10 @@ def test_all( assert "target_data" in result_2 @staticmethod - @pytest.mark.parametrize("include_target_data", ["a", True, 0]) + @pytest.mark.parametrize( + argnames="include_target_data", + argvalues=["a", True, 0], + ) def test_invalid_value( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, @@ -1170,8 +1182,8 @@ class TestAcceptHeader: @staticmethod @pytest.mark.parametrize( - "extra_headers", - [ + argnames="extra_headers", + argvalues=[ { "Accept": "application/json", }, @@ -1681,7 +1693,7 @@ class TestImageFormats: """ @staticmethod - @pytest.mark.parametrize("file_format", ["png", "jpeg"]) + @pytest.mark.parametrize(argnames="file_format", argvalues=["png", "jpeg"]) def test_supported( high_quality_image: io.BytesIO, file_format: str, @@ -1749,7 +1761,7 @@ class TestProcessing: """ @staticmethod - @pytest.mark.parametrize("active_flag", [True, False]) + @pytest.mark.parametrize(argnames="active_flag", argvalues=[True, False]) def test_processing( high_quality_image: io.BytesIO, vws_client: VWS, @@ -1980,15 +1992,15 @@ class TestDateFormats: @staticmethod @pytest.mark.parametrize( - "datetime_format", - [ + argnames="datetime_format", + argvalues=[ "%a, %b %d %H:%M:%S %Y", "%a %b %d %H:%M:%S %Y", "%a, %d %b %Y %H:%M:%S", "%a %d %b %Y %H:%M:%S", ], ) - @pytest.mark.parametrize("include_tz", [True, False]) + @pytest.mark.parametrize(argnames="include_tz", argvalues=[True, False]) def test_date_formats( high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, diff --git a/tests/mock_vws/test_target_raters.py b/tests/mock_vws/test_target_raters.py index b2120955c..dda0859df 100644 --- a/tests/mock_vws/test_target_raters.py +++ b/tests/mock_vws/test_target_raters.py @@ -33,7 +33,7 @@ def test_random_target_tracking_rater() -> None: assert lowest_rating != highest_rating -@pytest.mark.parametrize("rating", range(-10, 10)) +@pytest.mark.parametrize(argnames="rating", argvalues=range(-10, 10)) def test_hardcoded_target_tracking_rater(rating: int) -> None: """ Test that the hardcoded target tracking rater returns the hardcoded number. diff --git a/tests/mock_vws/test_target_summary.py b/tests/mock_vws/test_target_summary.py index 1dc751d1d..f9c1a3b98 100644 --- a/tests/mock_vws/test_target_summary.py +++ b/tests/mock_vws/test_target_summary.py @@ -22,7 +22,7 @@ class TestTargetSummary: """ @staticmethod - @pytest.mark.parametrize("active_flag", [True, False]) + @pytest.mark.parametrize(argnames="active_flag", argvalues=[True, False]) def test_target_summary( vws_client: VWS, vuforia_database: VuforiaDatabase, diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index bffb2da26..cd587ba60 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -72,8 +72,8 @@ class TestUpdate: @staticmethod @pytest.mark.parametrize( - "content_type", - [ + argnames="content_type", + argvalues=[ # This is the documented required content type: "application/json", # Other content types also work. @@ -222,8 +222,8 @@ class TestWidth: @staticmethod @pytest.mark.parametrize( - "width", - [-1, "10", None, 0], + argnames="width", + argvalues=[-1, "10", None, 0], ids=["Negative", "Wrong Type", "None", "Zero"], ) def test_width_invalid( @@ -275,8 +275,14 @@ class TestActiveFlag: """ @staticmethod - @pytest.mark.parametrize("initial_active_flag", [True, False]) - @pytest.mark.parametrize("desired_active_flag", [True, False]) + @pytest.mark.parametrize( + argnames="initial_active_flag", + argvalues=[True, False], + ) + @pytest.mark.parametrize( + argnames="desired_active_flag", + argvalues=[True, False], + ) def test_active_flag( vws_client: VWS, image_file_success_state_low_rating: io.BytesIO, @@ -305,7 +311,10 @@ def test_active_flag( assert target_details.target_record.active_flag == desired_active_flag @staticmethod - @pytest.mark.parametrize("desired_active_flag", ["string", None]) + @pytest.mark.parametrize( + argnames="desired_active_flag", + argvalues=["string", None], + ) def test_invalid( vws_client: VWS, target_id: str, @@ -338,8 +347,8 @@ class TestApplicationMetadata: @staticmethod @pytest.mark.parametrize( - "metadata", - [ + argnames="metadata", + argvalues=[ b"a", b"a" * _MAX_METADATA_BYTES, ], @@ -363,7 +372,7 @@ def test_base64_encoded( ) @staticmethod - @pytest.mark.parametrize("invalid_metadata", [1, None]) + @pytest.mark.parametrize(argnames="invalid_metadata", argvalues=[1, None]) def test_invalid_type( vws_client: VWS, target_id: str, @@ -464,8 +473,8 @@ class TestTargetName: @staticmethod @pytest.mark.parametrize( - "name", - [ + argnames="name", + argvalues=[ "á", # We test just below the max character value. # This is because targets with the max character value in their @@ -805,7 +814,10 @@ def test_not_image(target_id: str, vws_client: VWS) -> None: ) @staticmethod - @pytest.mark.parametrize("invalid_type_image", [1, None]) + @pytest.mark.parametrize( + argnames="invalid_type_image", + argvalues=[1, None], + ) def test_invalid_type( invalid_type_image: int | None, target_id: str, From 9b06cb09cc9b49715c333239ddbc5ef2efd6c631 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 4 Sep 2024 10:57:04 +0100 Subject: [PATCH 029/331] Untie error raised by decorator from `requests` --- docs/source/conf.py | 3 -- docs/source/mock-api-reference.rst | 4 +++ src/mock_vws/__init__.py | 6 +++- .../_requests_mock_server/decorators.py | 32 +++++++++++++------ tests/mock_vws/test_requests_mock_usage.py | 7 ++-- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 337869ef0..508f67d87 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -64,9 +64,6 @@ } nitpicky = True warning_is_error = True -nitpick_ignore = [ - ("py:exc", "requests.exceptions.MissingSchema"), -] html_theme = "furo" html_title = project diff --git a/docs/source/mock-api-reference.rst b/docs/source/mock-api-reference.rst index 0a2d4e180..ecb44f90b 100644 --- a/docs/source/mock-api-reference.rst +++ b/docs/source/mock-api-reference.rst @@ -7,6 +7,10 @@ API Reference :members: :undoc-members: +.. autoclass:: mock_vws.MissingSchemeError + :members: + :undoc-members: + .. Many parts of the VuforiaDatabase API are used for the Flask target .. database app, but Python users are not expected to use them. .. Therefore, they are not documented. diff --git a/src/mock_vws/__init__.py b/src/mock_vws/__init__.py index adb792a16..04d861f1a 100644 --- a/src/mock_vws/__init__.py +++ b/src/mock_vws/__init__.py @@ -2,8 +2,12 @@ Tools for using a fake implementation of Vuforia. """ -from mock_vws._requests_mock_server.decorators import MockVWS +from mock_vws._requests_mock_server.decorators import ( + MissingSchemeError, + MockVWS, +) __all__ = [ "MockVWS", + "MissingSchemeError", ] diff --git a/src/mock_vws/_requests_mock_server/decorators.py b/src/mock_vws/_requests_mock_server/decorators.py index 69f6c1497..8a2a00740 100644 --- a/src/mock_vws/_requests_mock_server/decorators.py +++ b/src/mock_vws/_requests_mock_server/decorators.py @@ -7,7 +7,6 @@ from typing import Literal, Self from urllib.parse import urljoin, urlparse -import requests from beartype import BeartypeConf, beartype from responses import RequestsMock @@ -29,6 +28,27 @@ _BRISQUE_TRACKING_RATER = BrisqueTargetTrackingRater() +class MissingSchemeError(Exception): + """ + Raised when a URL is missing a schema. + """ + + def __init__(self, url: str) -> None: + """ + Args: + url: The URL which is missing a scheme. + """ + super().__init__() + self.url = url + + def __str__(self) -> str: + """Give a string representation of this error with a suggestion.""" + return ( + f'Invalid URL "{self.url}": No scheme supplied. ' + f'Perhaps you meant "https://{self.url}".' + ) + + @beartype(conf=BeartypeConf(is_pep484_tower=True)) class MockVWS(ContextDecorator): """ @@ -66,8 +86,7 @@ def __init__( target_tracking_rater: A callable for rating targets for tracking. Raises: - requests.exceptions.MissingSchema: There is no schema in a given - URL. + MissingSchemeError: There is no scheme in a given URL. """ super().__init__() self._real_http = real_http @@ -76,15 +95,10 @@ def __init__( self._base_vws_url = base_vws_url self._base_vwq_url = base_vwq_url - missing_scheme_error = ( - 'Invalid URL "{url}": No scheme supplied. ' - 'Perhaps you meant "https://{url}".' - ) for url in (base_vwq_url, base_vws_url): parse_result = urlparse(url=url) if not parse_result.scheme: - error = missing_scheme_error.format(url=url) - raise requests.exceptions.MissingSchema(error) + raise MissingSchemeError(url=url) self._mock_vws_api = MockVuforiaWebServicesAPI( target_manager=self._target_manager, diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index 90711f2b7..5c3fb8928 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -14,11 +14,10 @@ from beartype import beartype from freezegun import freeze_time from PIL import Image -from requests.exceptions import MissingSchema from vws import VWS, CloudRecoService from vws_auth_tools import rfc_1123_date -from mock_vws import MockVWS +from mock_vws import MissingSchemeError, MockVWS from mock_vws.database import VuforiaDatabase from mock_vws.image_matchers import ExactMatcher, StructuralSimilarityMatcher from mock_vws.target import Target @@ -240,7 +239,7 @@ def test_no_scheme() -> None: """ An error if raised if a URL is given with no scheme. """ - with pytest.raises(expected_exception=MissingSchema) as vws_exc: + with pytest.raises(expected_exception=MissingSchemeError) as vws_exc: MockVWS(base_vws_url="vuforia.vws.example.com") expected = ( @@ -248,7 +247,7 @@ def test_no_scheme() -> None: 'Perhaps you meant "https://vuforia.vws.example.com".' ) assert str(vws_exc.value) == expected - with pytest.raises(expected_exception=MissingSchema) as vwq_exc: + with pytest.raises(expected_exception=MissingSchemeError) as vwq_exc: MockVWS(base_vwq_url="vuforia.vwq.example.com") expected = ( 'Invalid URL "vuforia.vwq.example.com": No scheme supplied. ' From bc07c95b50a5d37dedaf81c9dc18a3c8fff9e977 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 05:22:15 +0000 Subject: [PATCH 030/331] Bump types-requests from 2.32.0.20240712 to 2.32.0.20240905 Bumps [types-requests](https://github.com/python/typeshed) from 2.32.0.20240712 to 2.32.0.20240905. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-requests dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ae8f41a52..456e1dd8a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ optional-dependencies.dev = [ "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", "types-pyyaml==6.0.12.20240808", - "types-requests==2.32.0.20240712", + "types-requests==2.32.0.20240905", "urllib3==2.2.2", "vulture==2.11", "vws-python==2024.9.4.1", From 10635b1eb59dc224636c75268d4a9205d74fc892 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Sep 2024 05:22:20 +0000 Subject: [PATCH 031/331] Bump pyright from 1.1.378 to 1.1.379 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.378 to 1.1.379. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.378...v1.1.379) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ae8f41a52..859449da6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ optional-dependencies.dev = [ "pyenchant==3.2.2", "pylint==3.2.7", "pyproject-fmt==2.2.1", - "pyright==1.1.378", + "pyright==1.1.379", "pyroma==4.2", "pytest==8.3.2", "pytest-cov==5.0.0", From a81ecdb3d2981b925f891a257877fa59f6276f1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 05:45:16 +0000 Subject: [PATCH 032/331] Bump ruff from 0.6.3 to 0.6.4 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.3 to 0.6.4. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.3...0.6.4) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ae8f41a52..3b676e6aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.3", + "ruff==0.6.4", "sphinx==8.0.2", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", From 3f6c453520a06fd54147ae6f942916b69602e80a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 6 Sep 2024 18:59:38 +0100 Subject: [PATCH 033/331] Add format changes with diff --- .pre-commit-config.yaml | 51 +++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bd006349a..45bec456e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -104,6 +104,18 @@ repos: # want. entry: ghcr.io/hadolint/hadolint hadolint + - id: ruff-check + name: Ruff check + entry: ruff check + language: system + types_or: [python] + + - id: ruff-format-diff + name: Ruff format diff + entry: ruff format --diff + language: system + types_or: [python] + - id: ruff-check-fix name: Ruff check fix entry: ruff check --fix @@ -127,6 +139,14 @@ repos: entry: interrogate src/ tests/ ci/ language: system types_or: [python] + exclude_types: [executable] + + - id: pyproject-fmt-check + name: pyproject-fmt check + entry: pyproject-fmt --check + language: system + types_or: [toml] + files: pyproject.toml - id: pyproject-fmt-fix name: pyproject-fmt @@ -157,25 +177,36 @@ repos: language: system stages: [manual] pass_filenames: false + + - id: pyright-verifytypes + name: pyright-verifytypes + stages: [push] + entry: pyright --verifytypes vws_cli + language: system + pass_filenames: false + types_or: [python] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. ci: skip: - - custom-linters - actionlint - - mypy - check-manifest + - custom-linters + - deptry + - doc8 + - docs + - interrogate + - linkcheck + - mypy + - pylint + - pyproject-fmt-check + - pyproject-fmt-fix - pyright - pyright-verifytypes - - vulture - pyroma - - deptry - - pylint + - ruff-check - ruff-check-fix + - ruff-format-diff - ruff-format-fix - - doc8 - - interrogate - - pyproject-fmt-fix - - linkcheck - spelling - - docs + - vulture From f4a55ef7abce17b0153160d956c5b06c5d7dedc1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 7 Sep 2024 07:34:48 +0100 Subject: [PATCH 034/331] Remove bogus verifytypes --- .pre-commit-config.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45bec456e..1d4de6133 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -178,13 +178,6 @@ repos: stages: [manual] pass_filenames: false - - id: pyright-verifytypes - name: pyright-verifytypes - stages: [push] - entry: pyright --verifytypes vws_cli - language: system - pass_filenames: false - types_or: [python] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. ci: From 12115f388845653aeea5e22254bafdcff7c98cd1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 7 Sep 2024 12:53:38 +0100 Subject: [PATCH 035/331] Run documentation tests on CI --- .github/workflows/skip-tests.yml | 2 +- .github/workflows/windows-ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index 85d616821..7dbd9914d 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -59,7 +59,7 @@ jobs: --cov=src/ \ --cov=tests/ \ --cov-report=xml \ - tests/mock_vws/ + . - name: "Show coverage file" run: | diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index b73e0905f..f78ffde0a 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -48,7 +48,7 @@ jobs: run: | # We use pytest-xdist to make this run much faster. # The downside is that we cannot use -s / --capture=no. - pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml tests/mock_vws/ + pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . - name: "Show coverage file" run: | From c1299b60e318ca4233fcf9b933e62f2232db41dc Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 8 Sep 2024 02:00:20 +0100 Subject: [PATCH 036/331] Add shellcheck pre-commit hook --- .pre-commit-config.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1d4de6133..2e27ed8de 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,6 +19,11 @@ repos: files: spelling_private_dict\.txt$ - id: trailing-whitespace exclude: ^src/mock_vws/resources/ +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.10.0.1 + hooks: + - id: shellcheck + args: ["--shell", "bash"] - repo: local hooks: - id: custom-linters From 600181ff603d64f4ae9524a6f75c61c6743e5922 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 9 Sep 2024 00:15:46 +0100 Subject: [PATCH 037/331] Fix the GitHub workflow badge to refer to the right branch --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 0cc335f84..fb286ca8c 100644 --- a/README.rst +++ b/README.rst @@ -51,7 +51,7 @@ See the `full documentation `_ This includes details on how to use the mock, options, and details of the differences between the mock and the real Vuforia Web Services. -.. |Build Status| image:: https://github.com/VWS-Python/vws-python-mock/workflows/CI/badge.svg +.. |Build Status| image:: https://github.com/VWS-Python/vws-python-mock/actions/workflows/ci.yml/badge.svg?branch=main :target: https://github.com/VWS-Python/vws-python-mock/actions .. |codecov| image:: https://codecov.io/gh/VWS-Python/vws-python-mock/branch/main/graph/badge.svg :target: https://codecov.io/gh/VWS-Python/vws-python-mock From fef15a55313619e9d23b9472a2d2f6d84859c86e Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 9 Sep 2024 00:34:31 +0100 Subject: [PATCH 038/331] Specify Python module use in pre-commit hooks --- .pre-commit-config.yaml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2e27ed8de..e318c83e9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: hooks: - id: custom-linters name: custom-linters - entry: pytest ci/custom_linters.py + entry: python -m pytest ci/custom_linters.py stages: [push] language: system types_or: [yaml, python] @@ -36,7 +36,7 @@ repos: - id: actionlint name: actionlint - entry: actionlint + entry: python -m actionlint language: system pass_filenames: false types_or: [yaml] @@ -44,7 +44,7 @@ repos: - id: mypy name: mypy stages: [push] - entry: mypy . + entry: python -m mypy . language: system types_or: [python, toml] pass_filenames: false @@ -52,14 +52,14 @@ repos: - id: check-manifest name: check-manifest stages: [push] - entry: check-manifest . + entry: python -m check-manifest . language: system pass_filenames: false - id: pyright name: pyright stages: [push] - entry: pyright . + entry: python -m pyright . language: system types_or: [python, toml] pass_filenames: false @@ -67,33 +67,33 @@ repos: - id: pyright-verifytypes name: pyright-verifytypes stages: [push] - entry: pyright --verifytypes mock_vws + entry: python -m pyright --verifytypes mock_vws language: system pass_filenames: false types_or: [python] - id: vulture name: vulture - entry: vulture --min-confidence 100 --exclude .eggs + entry: python -m vulture --min-confidence 100 --exclude .eggs language: system types_or: [python] - id: pyroma name: pyroma - entry: pyroma --min 10 . + entry: python -m pyroma --min 10 . language: system pass_filenames: false types_or: [toml] - id: deptry name: deptry - entry: deptry src/ + entry: python -m deptry src/ language: system pass_filenames: false - id: pylint name: pylint - entry: pylint *.py src/ tests/ docs/ ci/ + entry: python -m pylint *.py src/ tests/ docs/ ci/ language: system stages: [manual] pass_filenames: false @@ -107,55 +107,55 @@ repos: # We choose not to use a Python wrapper or alternative to hadolint as none # appear to be well maintained, and they require more setup than we would # want. - entry: ghcr.io/hadolint/hadolint hadolint + entry: python -m ghcr.io/hadolint/hadolint hadolint - id: ruff-check name: Ruff check - entry: ruff check + entry: python -m ruff check language: system types_or: [python] - id: ruff-format-diff name: Ruff format diff - entry: ruff format --diff + entry: python -m ruff format --diff language: system types_or: [python] - id: ruff-check-fix name: Ruff check fix - entry: ruff check --fix + entry: python -m ruff check --fix language: system types_or: [python] - id: ruff-format-fix name: Ruff format - entry: ruff format + entry: python -m ruff format language: system types_or: [python] - id: doc8 name: doc8 - entry: doc8 + entry: python -m doc8 language: system types_or: [rst] - id: interrogate name: interrogate - entry: interrogate src/ tests/ ci/ + entry: python -m interrogate src/ tests/ ci/ language: system types_or: [python] exclude_types: [executable] - id: pyproject-fmt-check name: pyproject-fmt check - entry: pyproject-fmt --check + entry: python -m pyproject-fmt --check language: system types_or: [toml] files: pyproject.toml - id: pyproject-fmt-fix name: pyproject-fmt - entry: pyproject-fmt + entry: python -m pyproject-fmt language: system types_or: [toml] files: pyproject.toml From 4a4f57cc73238e26e5a22f0c6ec0bc21d4fd54f3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 9 Sep 2024 00:36:41 +0100 Subject: [PATCH 039/331] Specify Python module use in pre-commit hooks --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e318c83e9..dc7110334 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: actionlint name: actionlint - entry: python -m actionlint + entry: actionlint language: system pass_filenames: false types_or: [yaml] @@ -148,14 +148,14 @@ repos: - id: pyproject-fmt-check name: pyproject-fmt check - entry: python -m pyproject-fmt --check + entry: pyproject-fmt --check language: system types_or: [toml] files: pyproject.toml - id: pyproject-fmt-fix name: pyproject-fmt - entry: python -m pyproject-fmt + entry: pyproject-fmt language: system types_or: [toml] files: pyproject.toml From f4d461d4c46771299ef09f627982b4a6fbce328e Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 9 Sep 2024 00:40:33 +0100 Subject: [PATCH 040/331] Specify Python module use in pre-commit hooks --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dc7110334..ec1f4c6bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,7 +52,7 @@ repos: - id: check-manifest name: check-manifest stages: [push] - entry: python -m check-manifest . + entry: python -m check_manifest . language: system pass_filenames: false @@ -107,7 +107,7 @@ repos: # We choose not to use a Python wrapper or alternative to hadolint as none # appear to be well maintained, and they require more setup than we would # want. - entry: python -m ghcr.io/hadolint/hadolint hadolint + entry: ghcr.io/hadolint/hadolint hadolint - id: ruff-check name: Ruff check From 12879cd4eb5992c174c9de3cc1baf3cc30510414 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 06:02:12 +0000 Subject: [PATCH 041/331] Bump pyproject-fmt from 2.2.1 to 2.2.3 Bumps [pyproject-fmt](https://github.com/tox-dev/pyproject-fmt) from 2.2.1 to 2.2.3. - [Release notes](https://github.com/tox-dev/pyproject-fmt/releases) - [Commits](https://github.com/tox-dev/pyproject-fmt/compare/2.2.1...2.2.3) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cbdf8a37e..32b90042e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ optional-dependencies.dev = [ "pydocstyle==6.3", "pyenchant==3.2.2", "pylint==3.2.7", - "pyproject-fmt==2.2.1", + "pyproject-fmt==2.2.3", "pyright==1.1.379", "pyroma==4.2", "pytest==8.3.2", From c98b619e4c2b51813a0041afe03512711011f3ec Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 06:02:28 +0000 Subject: [PATCH 042/331] Bump types-requests from 2.32.0.20240905 to 2.32.0.20240907 Bumps [types-requests](https://github.com/python/typeshed) from 2.32.0.20240905 to 2.32.0.20240907. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-requests dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cbdf8a37e..885f25e0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ optional-dependencies.dev = [ "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", "types-pyyaml==6.0.12.20240808", - "types-requests==2.32.0.20240905", + "types-requests==2.32.0.20240907", "urllib3==2.2.2", "vulture==2.11", "vws-python==2024.9.4.1", From b0af0f00382ad802534b0d748ec82fe8f8d4eb0c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 11 Sep 2024 02:43:01 +0100 Subject: [PATCH 043/331] Switch from code to code-block, for consistency --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index fb286ca8c..4d5775f67 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo This requires Python 3.12+. -.. code:: sh +.. code-block:: sh pip install vws-python-mock From f75239088a356f846d9d5ac34833b3448fd88c47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 05:20:08 +0000 Subject: [PATCH 044/331] Bump pytest from 8.3.2 to 8.3.3 Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.2 to 8.3.3. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.3.2...8.3.3) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 67e25c575..f896f92bd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pyproject-fmt==2.2.3", "pyright==1.1.379", "pyroma==4.2", - "pytest==8.3.2", + "pytest==8.3.3", "pytest-cov==5.0.0", "pytest-retry==1.6.3", "pytest-xdist==3.6.1", From ceed1f6d39911e973433477b4a0af6a05a27a370 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 11 Sep 2024 10:37:20 +0100 Subject: [PATCH 045/331] Switch from code-block: sh to code-block: shell - get syntax highlighting --- README.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 4d5775f67..3fac472f4 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,7 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo This requires Python 3.12+. -.. code-block:: sh +.. code-block:: shell pip install vws-python-mock From e1de067566da9f330ec6e438556105907ec738b9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 11 Sep 2024 21:31:45 +0100 Subject: [PATCH 046/331] Remove outdated reference to DC/OS E2E --- docs/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/Makefile b/docs/Makefile index aae2ad2a1..ba501f6f5 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -4,7 +4,6 @@ # You can set these variables from the command line. SPHINXOPTS = SPHINXBUILD = sphinx-build -SPHINXPROJ = DCOSE2E SOURCEDIR = source BUILDDIR = build From 3d9cf00a5b0de076113e63769725963c450f9e88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 05:07:56 +0000 Subject: [PATCH 047/331] Bump pyright from 1.1.379 to 1.1.380 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.379 to 1.1.380. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.379...v1.1.380) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f896f92bd..d4c854176 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ optional-dependencies.dev = [ "pyenchant==3.2.2", "pylint==3.2.7", "pyproject-fmt==2.2.3", - "pyright==1.1.379", + "pyright==1.1.380", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 71cd94d95010d815d9902324d17e44ecb8107646 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 05:08:13 +0000 Subject: [PATCH 048/331] Bump pre-commit-ci/lite-action from 1.0.2 to 1.0.3 Bumps [pre-commit-ci/lite-action](https://github.com/pre-commit-ci/lite-action) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/pre-commit-ci/lite-action/releases) - [Commits](https://github.com/pre-commit-ci/lite-action/compare/v1.0.2...v1.0.3) --- updated-dependencies: - dependency-name: pre-commit-ci/lite-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f09270f0d..6084052c3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -40,5 +40,5 @@ jobs: pre-commit run --all-files --hook-stage push --verbose pre-commit run --all-files --hook-stage manual --verbose - - uses: pre-commit-ci/lite-action@v1.0.2 + - uses: pre-commit-ci/lite-action@v1.0.3 if: always() From 6f77d163a0a8a72d1cfbcf63fe6b7bb1b71b83d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:54:22 +0000 Subject: [PATCH 049/331] Bump urllib3 from 2.2.2 to 2.2.3 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.2.2 to 2.2.3. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.2.2...2.2.3) --- updated-dependencies: - dependency-name: urllib3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f896f92bd..db994a138 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "types-pillow==10.2.0.20240822", "types-pyyaml==6.0.12.20240808", "types-requests==2.32.0.20240907", - "urllib3==2.2.2", + "urllib3==2.2.3", "vulture==2.11", "vws-python==2024.9.4.1", "vws-test-fixtures==2023.3.5", From f5dbd276c864c465a0b3781b930c7cef71804965 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:54:38 +0000 Subject: [PATCH 050/331] Bump sybil from 6.1.1 to 7.0.0 Bumps [sybil](https://github.com/simplistix/sybil) from 6.1.1 to 7.0.0. - [Changelog](https://github.com/simplistix/sybil/blob/master/CHANGELOG.rst) - [Commits](https://github.com/simplistix/sybil/compare/6.1.1...7.0.0) --- updated-dependencies: - dependency-name: sybil dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f896f92bd..68788b0d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,7 +87,7 @@ optional-dependencies.dev = [ "sphinx-toolbox==3.8.0", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", - "sybil==6.1.1", + "sybil==7.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", From 289a07be19c774551a462756e9bc479bfda8da24 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 14 Sep 2024 09:07:28 +0100 Subject: [PATCH 051/331] Be careful when releasing to not accidentally commit to a file --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e5c4d5f2f..15eea7bca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -55,6 +55,7 @@ jobs: id: commit with: commit_message: Bump CHANGELOG + file_pattern: CHANGELOG.rst - name: Bump version and push tag id: tag_version From 385f808b69e352e22909c0760a07dd20d39f0dac Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 15 Sep 2024 12:31:40 +0100 Subject: [PATCH 052/331] Run linters against documentation source --- .pre-commit-config.yaml | 64 +++++++++++++++++++++++++++++++++++++++-- pyproject.toml | 1 + 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ec1f4c6bc..50d3cdecb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,13 @@ repos: types_or: [python, toml] pass_filenames: false + - id: mypy-docs + name: mypy-docs + stages: [push] + entry: doccmd --language=python --command="mypy" + language: system + types_or: [markdown, rst, python, toml] + - id: check-manifest name: check-manifest stages: [push] @@ -64,6 +71,13 @@ repos: types_or: [python, toml] pass_filenames: false + - id: pyright-docs + name: pyright-docs + stages: [push] + entry: doccmd --language=python --command="pyright" + language: system + types_or: [markdown, rst, python, toml] + - id: pyright-verifytypes name: pyright-verifytypes stages: [push] @@ -98,15 +112,22 @@ repos: stages: [manual] pass_filenames: false + - id: pylint-docs + name: pylint-docs + entry: doccmd --language=python --command="pylint" --lowercase-file-name + language: system + stages: [manual] + types_or: [markdown, rst, python, toml] + - id: hadolint-docker name: Lint Dockerfiles description: Runs hadolint Docker image to lint Dockerfiles language: docker_image types_or: [dockerfile] stages: [manual] # Requires Docker to be running - # We choose not to use a Python wrapper or alternative to hadolint as none - # appear to be well maintained, and they require more setup than we would - # want. + # We choose not to use a Python wrapper or alternative to hadolint as none + # appear to be well maintained, and they require more setup than we would + # want. entry: ghcr.io/hadolint/hadolint hadolint - id: ruff-check @@ -115,24 +136,48 @@ repos: language: system types_or: [python] + - id: ruff-check-docs + name: Ruff check docs + entry: doccmd --language=python --command="ruff check" + language: system + types_or: [markdown, rst] + - id: ruff-format-diff name: Ruff format diff entry: python -m ruff format --diff language: system types_or: [python] + - id: ruff-format-diff-docs + name: Ruff format diff docs + entry: doccmd --language=python --no-pad-file --command="ruff format --diff" + language: system + types_or: [markdown, rst] + - id: ruff-check-fix name: Ruff check fix entry: python -m ruff check --fix language: system types_or: [python] + - id: ruff-check-fix-docs + name: Ruff check fix docs + entry: doccmd --language=python --command="ruff check --fix" + language: system + types_or: [markdown, rst] + - id: ruff-format-fix name: Ruff format entry: python -m ruff format language: system types_or: [python] + - id: ruff-format-fix-docs + name: Ruff format docs + entry: doccmd --language=python --no-pad-file --command="ruff format" + language: system + types_or: [markdown, rst] + - id: doc8 name: doc8 entry: python -m doc8 @@ -146,6 +191,12 @@ repos: types_or: [python] exclude_types: [executable] + - id: interrogate-docs + name: interrogate docs + entry: doccmd --language=python --command="interrogate" + language: system + types_or: [markdown, rst] + - id: pyproject-fmt-check name: pyproject-fmt check entry: pyproject-fmt --check @@ -194,17 +245,24 @@ ci: - doc8 - docs - interrogate + - interrogate-docs - linkcheck - mypy + - mypy-docs - pylint - pyproject-fmt-check - pyproject-fmt-fix - pyright + - pyright-docs - pyright-verifytypes - pyroma - ruff-check + - ruff-check-docs - ruff-check-fix + - ruff-check-fix-docs - ruff-format-diff + - ruff-format-diff-docs - ruff-format-fix + - ruff-format-fix-docs - spelling - vulture diff --git a/pyproject.toml b/pyproject.toml index dca98acea..e0a3e9c6b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", + "doccmd==2024.9.15", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 34ce2fdc744529c6eea9aaedb04f8df5074da608 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 15 Sep 2024 12:34:26 +0100 Subject: [PATCH 053/331] Progress towards passing lint --- README.rst | 3 ++- docs/source/basic-example.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 3fac472f4..8ce9975de 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,7 @@ This requires Python 3.12+. .. code-block:: python import requests + from mock_vws import MockVWS from mock_vws.database import VuforiaDatabase @@ -29,7 +30,7 @@ This requires Python 3.12+. database = VuforiaDatabase() mock.add_database(database=database) # This will use the Vuforia mock. - requests.get('https://vws.vuforia.com/summary') + requests.get("https://vws.vuforia.com/summary", timeout=30) By default, an exception will be raised if any requests to unmocked addresses are made. diff --git a/docs/source/basic-example.rst b/docs/source/basic-example.rst index 2c385ac0e..fc6e28d6b 100644 --- a/docs/source/basic-example.rst +++ b/docs/source/basic-example.rst @@ -10,7 +10,7 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo database = VuforiaDatabase() mock.add_database(database=database) # This will use the Vuforia mock. - requests.get('https://vws.vuforia.com/summary') + requests.get("https://vws.vuforia.com/summary", timeout=30) By default, an exception will be raised if any requests to unmocked addresses are made. From b765ccbe3fd143f2b2f6d0eb54b3abfebf410e53 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 15 Sep 2024 12:35:19 +0100 Subject: [PATCH 054/331] Fix some lint issues --- README.rst | 2 ++ docs/source/basic-example.rst | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 8ce9975de..addc7b528 100644 --- a/README.rst +++ b/README.rst @@ -21,6 +21,8 @@ This requires Python 3.12+. .. code-block:: python + """Make a request to the Vuforia Web Services API mock.""" + import requests from mock_vws import MockVWS diff --git a/docs/source/basic-example.rst b/docs/source/basic-example.rst index fc6e28d6b..59df85bf5 100644 --- a/docs/source/basic-example.rst +++ b/docs/source/basic-example.rst @@ -2,6 +2,8 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo .. code-block:: python + """Make a request to the Vuforia Web Services API mock.""" + import requests from mock_vws import MockVWS from mock_vws.database import VuforiaDatabase From 1f936e48d01a65e9e8a31616d6b050681cd2d1a8 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 15 Sep 2024 17:33:28 +0100 Subject: [PATCH 055/331] Fix some lint issues --- .pre-commit-config.yaml | 2 +- docs/source/basic-example.rst | 2 +- pyproject.toml | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 50d3cdecb..7a5174706 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -114,7 +114,7 @@ repos: - id: pylint-docs name: pylint-docs - entry: doccmd --language=python --command="pylint" --lowercase-file-name + entry: doccmd --language=python --command="pylint" language: system stages: [manual] types_or: [markdown, rst, python, toml] diff --git a/docs/source/basic-example.rst b/docs/source/basic-example.rst index 59df85bf5..d7a28ed6b 100644 --- a/docs/source/basic-example.rst +++ b/docs/source/basic-example.rst @@ -5,6 +5,7 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo """Make a request to the Vuforia Web Services API mock.""" import requests + from mock_vws import MockVWS from mock_vws.database import VuforiaDatabase @@ -14,7 +15,6 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo # This will use the Vuforia mock. requests.get("https://vws.vuforia.com/summary", timeout=30) - By default, an exception will be raised if any requests to unmocked addresses are made. See :ref:`mock-api-reference` for details of what can be changed and how. diff --git a/pyproject.toml b/pyproject.toml index e0a3e9c6b..831065243 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.15", + "doccmd==2024.9.15.1", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", @@ -70,6 +70,7 @@ optional-dependencies.dev = [ "pydocstyle==6.3", "pyenchant==3.2.2", "pylint==3.2.7", + "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.3", "pyright==1.1.380", "pyroma==4.2", @@ -191,6 +192,7 @@ jobs = 0 # - pylint.extensions.while_used # as they seemed to get in the way. load-plugins = [ + "pylint_per_file_ignores", 'pylint.extensions.bad_builtin', 'pylint.extensions.comparison_placement', 'pylint.extensions.consider_refactoring_into_while_condition', @@ -208,6 +210,17 @@ load-plugins = [ 'pylint.extensions.typing', ] +# This format is described in the following issue: +# https://github.com/christopherpickering/pylint-per-file-ignores/issues/160 +# +# We ignore invalid names because: +# - We want to use generated module names, which may not be valid, but are never seen. +# - We want to use global variables in documentation, which may not be uppercase +per-file-ignores = """ +docs/:invalid-name +doccmd_README_rst.*.py:invalid-name +""" + [tool.pylint.'MESSAGES CONTROL'] # Enable the message, report, category or checker with the given id(s). You can From 0e26e5c192bbcf7362641f7cc0135fe5f750b506 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 15 Sep 2024 18:02:10 +0100 Subject: [PATCH 056/331] Remove pre-commit check-only hooks when we have an auto-fixer --- .pre-commit-config.yaml | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a5174706..450217371 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -130,30 +130,6 @@ repos: # want. entry: ghcr.io/hadolint/hadolint hadolint - - id: ruff-check - name: Ruff check - entry: python -m ruff check - language: system - types_or: [python] - - - id: ruff-check-docs - name: Ruff check docs - entry: doccmd --language=python --command="ruff check" - language: system - types_or: [markdown, rst] - - - id: ruff-format-diff - name: Ruff format diff - entry: python -m ruff format --diff - language: system - types_or: [python] - - - id: ruff-format-diff-docs - name: Ruff format diff docs - entry: doccmd --language=python --no-pad-file --command="ruff format --diff" - language: system - types_or: [markdown, rst] - - id: ruff-check-fix name: Ruff check fix entry: python -m ruff check --fix @@ -197,13 +173,6 @@ repos: language: system types_or: [markdown, rst] - - id: pyproject-fmt-check - name: pyproject-fmt check - entry: pyproject-fmt --check - language: system - types_or: [toml] - files: pyproject.toml - - id: pyproject-fmt-fix name: pyproject-fmt entry: pyproject-fmt @@ -250,18 +219,13 @@ ci: - mypy - mypy-docs - pylint - - pyproject-fmt-check - pyproject-fmt-fix - pyright - pyright-docs - pyright-verifytypes - pyroma - - ruff-check - - ruff-check-docs - ruff-check-fix - ruff-check-fix-docs - - ruff-format-diff - - ruff-format-diff-docs - ruff-format-fix - ruff-format-fix-docs - spelling From 47663672a5a099621e2d50ea65f163a68d99367c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 05:11:51 +0000 Subject: [PATCH 057/331] Bump doccmd from 2024.9.15.1 to 2024.9.16 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.15.1 to 2024.9.16. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.15.1...2024.09.16) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 831065243..f5fd22a0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.15.1", + "doccmd==2024.9.16", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 0a6178747ed2b20bdeaa4c6f5362921290018c54 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 05:12:04 +0000 Subject: [PATCH 058/331] Bump ruff from 0.6.4 to 0.6.5 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.4 to 0.6.5. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.4...0.6.5) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 831065243..0c8369c14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.4", + "ruff==0.6.5", "sphinx==8.0.2", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", From 29250e6b90e52afcf1101f6386c597bbc472bd8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 05:12:24 +0000 Subject: [PATCH 059/331] Bump types-requests from 2.32.0.20240907 to 2.32.0.20240914 Bumps [types-requests](https://github.com/python/typeshed) from 2.32.0.20240907 to 2.32.0.20240914. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-requests dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 831065243..a6e191e82 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,7 +94,7 @@ optional-dependencies.dev = [ "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", "types-pyyaml==6.0.12.20240808", - "types-requests==2.32.0.20240907", + "types-requests==2.32.0.20240914", "urllib3==2.2.3", "vulture==2.11", "vws-python==2024.9.4.1", From e92dcbbd8d3b1f0bd891664d1406bacc59224b3b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 17 Sep 2024 00:11:40 +0100 Subject: [PATCH 060/331] Add shellcheck-py so that GitHub workflow files get linted for shell issues --- .gitignore | 2 ++ pyproject.toml | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index ec1645423..0a4d3ec0c 100644 --- a/.gitignore +++ b/.gitignore @@ -109,3 +109,5 @@ secrets.tar # setuptools_scm src/*/_setuptools_scm_version.txt + +uv.lock diff --git a/pyproject.toml b/pyproject.toml index 58f799902..b58936cb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,10 @@ optional-dependencies.dev = [ "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", "ruff==0.6.5", + # We add shellcheck-py not only for shell scripts and shell code blocks, + # but also because having it installed means that ``actionlint-py`` will + # use it to lint shell commands in GitHub workflow files. + "shellcheck-py==0.10.0.1", "sphinx==8.0.2", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", From ff0645a2b3e50076e6b4fea5646c236547dc62c3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 05:56:35 +0000 Subject: [PATCH 061/331] Bump types-pyyaml from 6.0.12.20240808 to 6.0.12.20240917 Bumps [types-pyyaml](https://github.com/python/typeshed) from 6.0.12.20240808 to 6.0.12.20240917. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-pyyaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 58f799902..c55a18d4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", - "types-pyyaml==6.0.12.20240808", + "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20240914", "urllib3==2.2.3", "vulture==2.11", From c3bd9579dcd3f7dcc9706d7fc6aab9cd1ea1dd80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 05:56:51 +0000 Subject: [PATCH 062/331] Bump sybil from 7.0.0 to 7.1.1 Bumps [sybil](https://github.com/simplistix/sybil) from 7.0.0 to 7.1.1. - [Changelog](https://github.com/simplistix/sybil/blob/master/CHANGELOG.rst) - [Commits](https://github.com/simplistix/sybil/compare/7.0.0...7.1.1) --- updated-dependencies: - dependency-name: sybil dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 58f799902..239f4383b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ optional-dependencies.dev = [ "sphinx-toolbox==3.8.0", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", - "sybil==7.0.0", + "sybil==7.1.1", "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", From b702bf5a5efd95c9242f4ea5a42d51fbee9b7ed0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 17 Sep 2024 10:44:25 +0100 Subject: [PATCH 063/331] Remove no-longer-needed handling of .eggs directory in Vulture --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 450217371..8ff9d9c21 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -88,7 +88,7 @@ repos: - id: vulture name: vulture - entry: python -m vulture --min-confidence 100 --exclude .eggs + entry: python -m vulture --min-confidence 100 language: system types_or: [python] From bef384e817bd6ba882cf4440b2af831172fdfcca Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 17 Sep 2024 12:46:07 +0100 Subject: [PATCH 064/331] Replace `read` with `getvalue` where possible --- tests/mock_vws/fixtures/prepared_requests.py | 4 ++-- tests/mock_vws/test_add_target.py | 24 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index ab0ec04d3..3f949c5c0 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -45,7 +45,7 @@ def add_target( """ Return details of the endpoint for adding a target. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -431,7 +431,7 @@ def query( """ Return details of the endpoint for making an image recognition query. """ - image_content = high_quality_image.read() + image_content = high_quality_image.getvalue() date = rfc_1123_date() request_path = "/v1/query" files = {"image": ("image.jpeg", image_content, "image/jpeg")} diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index cb751d9ed..adf9695a0 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -145,7 +145,7 @@ def test_content_types( """ Any non-empty ``Content-Type`` header is allowed. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -173,7 +173,7 @@ def test_empty_content_type( An ``UNAUTHORIZED`` response is given if an empty ``Content-Type`` header is given. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -219,7 +219,7 @@ def test_missing_data( """ `name`, `width` and `image` are all required. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii", ) @@ -261,7 +261,7 @@ def test_width_invalid( """ The width must be a number greater than zero. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -369,7 +369,7 @@ def test_name_invalid( A target's name must be a string of length 0 < N < 65, with characters in a particular range. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii", ) @@ -709,7 +709,7 @@ def test_valid( """ Boolean values and NULL are valid active flags. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii", ) @@ -739,7 +739,7 @@ def test_invalid( Values which are not Boolean values or NULL are not valid active flags. """ active_flag = "string" - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -773,7 +773,7 @@ def test_not_set( """ The active flag defaults to True if it is not set. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -798,7 +798,7 @@ def test_set_to_none( """ The active flag defaults to True if it is set to NULL. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -832,7 +832,7 @@ def test_invalid_extra_data( """ A `BAD_REQUEST` response is returned when unexpected data is given. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -897,7 +897,7 @@ def test_null( """ NULL is valid application metadata. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) @@ -925,7 +925,7 @@ def test_invalid_type( Values which are not a string or NULL are not valid application metadata. """ - image_data = image_file_failed_state.read() + image_data = image_file_failed_state.getvalue() image_data_encoded = base64.b64encode(s=image_data).decode( encoding="ascii" ) From 82787aacff054b7411f83013331a51c08a7551f8 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 17 Sep 2024 21:03:43 +0100 Subject: [PATCH 065/331] Set Vulture to be more strict --- .pre-commit-config.yaml | 9 +- admin/create_secrets_files.py | 164 ++++++++++-------- ...stom_linters.py => test_custom_linters.py} | 0 pyproject.toml | 55 ++++++ src/mock_vws/_constants.py | 2 + tests/mock_vws/fixtures/vuforia_backends.py | 3 +- 6 files changed, 151 insertions(+), 82 deletions(-) rename ci/{custom_linters.py => test_custom_linters.py} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ff9d9c21..c8121da2b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: hooks: - id: custom-linters name: custom-linters - entry: python -m pytest ci/custom_linters.py + entry: python -m pytest ci/test_custom_linters.py stages: [push] language: system types_or: [yaml, python] @@ -88,9 +88,10 @@ repos: - id: vulture name: vulture - entry: python -m vulture --min-confidence 100 + entry: python -m vulture . language: system types_or: [python] + pass_filenames: false - id: pyroma name: pyroma @@ -107,7 +108,7 @@ repos: - id: pylint name: pylint - entry: python -m pylint *.py src/ tests/ docs/ ci/ + entry: python -m pylint *.py src/ tests/ docs/ ci/ admin/ language: system stages: [manual] pass_filenames: false @@ -162,7 +163,7 @@ repos: - id: interrogate name: interrogate - entry: python -m interrogate src/ tests/ ci/ + entry: python -m interrogate language: system types_or: [python] exclude_types: [executable] diff --git a/admin/create_secrets_files.py b/admin/create_secrets_files.py index aaac649b4..a236fe2f9 100644 --- a/admin/create_secrets_files.py +++ b/admin/create_secrets_files.py @@ -25,83 +25,93 @@ from selenium import webdriver from selenium.common.exceptions import TimeoutException -email_address = os.environ["VWS_EMAIL_ADDRESS"] -password = os.environ["VWS_PASSWORD"] -new_secrets_dir = Path(os.environ["NEW_SECRETS_DIR"]).expanduser() -existing_secrets_file = Path(os.environ["EXISTING_SECRETS_FILE"]).expanduser() -assert existing_secrets_file.exists(), existing_secrets_file -load_dotenv(dotenv_path=existing_secrets_file) -new_secrets_dir.mkdir(exist_ok=True) - -num_databases = 100 -required_files = [ - (new_secrets_dir / f"vuforia_secrets_{i}.env") - for i in range(num_databases) -] -files_to_create = [file for file in required_files if not file.exists()] -start_number = len(list(new_secrets_dir.glob("*"))) -driver = None - -while files_to_create: - if driver is None: - # With Safari we get a bunch of errors / timeouts. - driver = webdriver.Chrome() - file = files_to_create[-1] - sys.stdout.write(f"Creating database {file.name}\n") - time = datetime.datetime.now(tz=datetime.UTC).strftime( - format="%Y-%m-%d-%H-%M-%S", - ) - license_name = f"my-license-{time}" - database_name = f"my-database-{time}" - - vws_web_tools.log_in( - driver=driver, - email_address=email_address, - password=password, - ) - vws_web_tools.wait_for_logged_in(driver=driver) - try: - vws_web_tools.create_license(driver=driver, license_name=license_name) - except TimeoutException: - sys.stderr.write("Timed out waiting for license creation\n") - driver.quit() - driver = None - continue - - vws_web_tools.create_database( - driver=driver, - database_name=database_name, - license_name=license_name, - ) - - try: - database_details = vws_web_tools.get_database_details( + +def main() -> None: + """Create secrets files.""" + email_address = os.environ["VWS_EMAIL_ADDRESS"] + password = os.environ["VWS_PASSWORD"] + new_secrets_dir = Path(os.environ["NEW_SECRETS_DIR"]).expanduser() + existing_secrets_file = Path( + os.environ["EXISTING_SECRETS_FILE"] + ).expanduser() + assert existing_secrets_file.exists(), existing_secrets_file + load_dotenv(dotenv_path=existing_secrets_file) + new_secrets_dir.mkdir(exist_ok=True) + + num_databases = 100 + required_files = [ + (new_secrets_dir / f"vuforia_secrets_{i}.env") + for i in range(num_databases) + ] + files_to_create = [file for file in required_files if not file.exists()] + driver = None + + while files_to_create: + if driver is None: + # With Safari we get a bunch of errors / timeouts. + driver = webdriver.Chrome() + file = files_to_create[-1] + sys.stdout.write(f"Creating database {file.name}\n") + time = datetime.datetime.now(tz=datetime.UTC).strftime( + format="%Y-%m-%d-%H-%M-%S", + ) + license_name = f"my-license-{time}" + database_name = f"my-database-{time}" + + vws_web_tools.log_in( + driver=driver, + email_address=email_address, + password=password, + ) + vws_web_tools.wait_for_logged_in(driver=driver) + try: + vws_web_tools.create_license( + driver=driver, license_name=license_name + ) + except TimeoutException: + sys.stderr.write("Timed out waiting for license creation\n") + driver.quit() + driver = None + continue + + vws_web_tools.create_database( driver=driver, database_name=database_name, + license_name=license_name, ) - except TimeoutException: - sys.stderr.write("Timed out waiting for database to be created\n") - continue - finally: - driver.quit() - driver = None - - file_contents = textwrap.dedent( - text=f"""\ - VUFORIA_TARGET_MANAGER_DATABASE_NAME={database_details["database_name"]} - VUFORIA_SERVER_ACCESS_KEY={database_details["server_access_key"]} - VUFORIA_SERVER_SECRET_KEY={database_details["server_secret_key"]} - VUFORIA_CLIENT_ACCESS_KEY={database_details["client_access_key"]} - VUFORIA_CLIENT_SECRET_KEY={database_details["client_secret_key"]} - - INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME={os.environ["INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME"]} - INACTIVE_VUFORIA_SERVER_ACCESS_KEY={os.environ["INACTIVE_VUFORIA_SERVER_ACCESS_KEY"]} - INACTIVE_VUFORIA_SERVER_SECRET_KEY={os.environ["INACTIVE_VUFORIA_SERVER_SECRET_KEY"]} - INACTIVE_VUFORIA_CLIENT_ACCESS_KEY={os.environ["INACTIVE_VUFORIA_CLIENT_ACCESS_KEY"]} - INACTIVE_VUFORIA_CLIENT_SECRET_KEY={os.environ["INACTIVE_VUFORIA_CLIENT_SECRET_KEY"]} - """, - ) - - file.write_text(file_contents) - sys.stdout.write(f"Created database {file.name}\n") - files_to_create.pop() + + try: + database_details = vws_web_tools.get_database_details( + driver=driver, + database_name=database_name, + ) + except TimeoutException: + sys.stderr.write("Timed out waiting for database to be created\n") + continue + finally: + driver.quit() + driver = None + + file_contents = textwrap.dedent( + text=f"""\ + VUFORIA_TARGET_MANAGER_DATABASE_NAME={database_details["database_name"]} + VUFORIA_SERVER_ACCESS_KEY={database_details["server_access_key"]} + VUFORIA_SERVER_SECRET_KEY={database_details["server_secret_key"]} + VUFORIA_CLIENT_ACCESS_KEY={database_details["client_access_key"]} + VUFORIA_CLIENT_SECRET_KEY={database_details["client_secret_key"]} + + INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME={os.environ["INACTIVE_VUFORIA_TARGET_MANAGER_DATABASE_NAME"]} + INACTIVE_VUFORIA_SERVER_ACCESS_KEY={os.environ["INACTIVE_VUFORIA_SERVER_ACCESS_KEY"]} + INACTIVE_VUFORIA_SERVER_SECRET_KEY={os.environ["INACTIVE_VUFORIA_SERVER_SECRET_KEY"]} + INACTIVE_VUFORIA_CLIENT_ACCESS_KEY={os.environ["INACTIVE_VUFORIA_CLIENT_ACCESS_KEY"]} + INACTIVE_VUFORIA_CLIENT_SECRET_KEY={os.environ["INACTIVE_VUFORIA_CLIENT_SECRET_KEY"]} + """, + ) + + file.write_text(file_contents) + sys.stdout.write(f"Created database {file.name}\n") + files_to_create.pop() + + +if __name__ == "__main__": + main() diff --git a/ci/custom_linters.py b/ci/test_custom_linters.py similarity index 100% rename from ci/custom_linters.py rename to ci/test_custom_linters.py diff --git a/pyproject.toml b/pyproject.toml index 921748da3..61f8fe650 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -400,3 +400,58 @@ ignore_path = [ "./src/*.egg-info/", "./src/*/_setuptools_scm_version.txt", ] + +[tool.vulture] +# Ideally we would limit the paths to the source code where we want to ignore names, +# but Vulture does not enable this. +ignore_names = [ + # pytest configuration + "pytest_collect_file", + "pytest_collection_modifyitems", + "pytest_plugins", + "pytest_set_filtered_exceptions", + "pytest_addoption", + # pytest fixtures - we name fixtures like this for this purpose + "fixture_*", + # Sphinx + "autoclass_content", + "autoclass_content", + "autodoc_member_order", + "copybutton_exclude", + "extensions", + "html_show_copyright", + "html_show_sourcelink", + "html_show_sphinx", + "html_theme", + "html_theme_options", + "html_title", + "htmlhelp_basename", + "intersphinx_mapping", + "language", + "linkcheck_ignore", + "linkcheck_retries", + "master_doc", + "nitpicky", + "project_copyright", + "pygments_style", + "rst_prolog", + "source_suffix", + "spelling_word_list_filename", + "templates_path", + "warning_is_error", + # Too difficult to test (see notes in the code) + "DATE_RANGE_ERROR", + "REQUEST_QUOTA_REACHED", + # pydantic-settings + "model_config", +] + +# Duplicate some of .gitignore +exclude = [ ".venv" ] +ignore_decorators = [ + "@pytest.fixture", + # Flask + "@*APP.route", + "@*APP.before_request", + "@*APP.errorhandler", +] diff --git a/src/mock_vws/_constants.py b/src/mock_vws/_constants.py index dc964520d..b7f7385b7 100644 --- a/src/mock_vws/_constants.py +++ b/src/mock_vws/_constants.py @@ -33,6 +33,8 @@ class ResultCodes(Enum): DATE_RANGE_ERROR = "DateRangeError" FAIL = "Fail" TARGET_STATUS_PROCESSING = "TargetStatusProcessing" + # While we sometimes hit this, we don't want to keep a database that is + # constantly in this state. REQUEST_QUOTA_REACHED = "RequestQuotaReached" TARGET_STATUS_NOT_SUCCESS = "TargetStatusNotSuccess" PROJECT_INACTIVE = "ProjectInactive" diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index dae00c333..60594f837 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -230,10 +230,11 @@ def pytest_collection_modifyitems( @beartype @pytest.fixture( + name="verify_mock_vuforia", params=list(VuforiaBackend), ids=[backend.value for backend in list(VuforiaBackend)], ) -def verify_mock_vuforia( +def fixture_verify_mock_vuforia( request: pytest.FixtureRequest, vuforia_database: VuforiaDatabase, inactive_database: VuforiaDatabase, From 15ddda6a02cda1a08ba5373c6b45ffaca839abd0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 17 Sep 2024 23:10:51 +0100 Subject: [PATCH 066/331] Do not specify directories for `interrogate` --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ff9d9c21..3c20b314c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -162,7 +162,7 @@ repos: - id: interrogate name: interrogate - entry: python -m interrogate src/ tests/ ci/ + entry: python -m interrogate language: system types_or: [python] exclude_types: [executable] From 4cf5feb133e7648cc41dde95a3c5f5d4884abc48 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Sep 2024 04:04:19 +0100 Subject: [PATCH 067/331] Use vulture on docs --- .pre-commit-config.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c8121da2b..763b7a010 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -93,6 +93,13 @@ repos: types_or: [python] pass_filenames: false + - id: vulture-docs + name: vulture docs + entry: doccmd --language=python --command="vulture" + language: system + types_or: [python] + pass_filenames: false + - id: pyroma name: pyroma entry: python -m pyroma --min 10 . @@ -231,3 +238,4 @@ ci: - ruff-format-fix-docs - spelling - vulture + - vulture-docs From 015abd22cbff885253d4b3211a989768e2336bbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 05:45:54 +0000 Subject: [PATCH 068/331] Bump pyproject-fmt from 2.2.3 to 2.2.4 Bumps [pyproject-fmt](https://github.com/tox-dev/pyproject-fmt) from 2.2.3 to 2.2.4. - [Release notes](https://github.com/tox-dev/pyproject-fmt/releases) - [Commits](https://github.com/tox-dev/pyproject-fmt/compare/2.2.3...2.2.4) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61f8fe650..6b4308369 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pyenchant==3.2.2", "pylint==3.2.7", "pylint-per-file-ignores==1.3.2", - "pyproject-fmt==2.2.3", + "pyproject-fmt==2.2.4", "pyright==1.1.380", "pyroma==4.2", "pytest==8.3.3", From c8ac87d049bce415c578c65a5f3e4a30f35ca308 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 05:46:12 +0000 Subject: [PATCH 069/331] Bump doccmd from 2024.9.16 to 2024.9.18 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.16 to 2024.9.18. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.16...2024.09.18) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61f8fe650..6dabfaf95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.16", + "doccmd==2024.9.18", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From ccd9673c26e95dc0219b162e02bd7d027723a269 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Sep 2024 05:46:20 +0000 Subject: [PATCH 070/331] Bump vulture from 2.11 to 2.12 Bumps [vulture](https://github.com/jendrikseipp/vulture) from 2.11 to 2.12. - [Release notes](https://github.com/jendrikseipp/vulture/releases) - [Changelog](https://github.com/jendrikseipp/vulture/blob/main/CHANGELOG.md) - [Commits](https://github.com/jendrikseipp/vulture/compare/v2.11...v2.12) --- updated-dependencies: - dependency-name: vulture dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61f8fe650..71fd4b28b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,7 @@ optional-dependencies.dev = [ "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20240914", "urllib3==2.2.3", - "vulture==2.11", + "vulture==2.12", "vws-python==2024.9.4.1", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", From 5d1a514d7cf5fb8cd9e6158fa3d70279c2e9c7bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Sep 2024 05:05:25 +0000 Subject: [PATCH 071/331] Bump pyright from 1.1.380 to 1.1.381 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.380 to 1.1.381. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.380...v1.1.381) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 860e2d52e..5b19d3eab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.2.7", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", - "pyright==1.1.380", + "pyright==1.1.381", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 1dec5d6743a9df8a67398ea068336667c4b43b8a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 19 Sep 2024 08:29:23 +0100 Subject: [PATCH 072/331] Simplify release script by removing unnecessary intermediary variables --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15eea7bca..75b525fcf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,11 +43,9 @@ jobs: - name: "Update changelog" uses: jacobtomlinson/gha-find-replace@v3 - env: - NEXT_VERSION: ${{ steps.calver.outputs.release }} with: find: "Next\n----" - replace: "Next\n----\n\n${{ env.NEXT_VERSION }}\n------------" + replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n------------" include: "CHANGELOG.rst" regex: false From 61c073ed94922ec017279f421323cb0dd48d985c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 19 Sep 2024 08:48:41 +0100 Subject: [PATCH 073/331] Simplify release script by removing unnecessary git fetch tags command --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 15eea7bca..33acb4bb6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,8 +76,7 @@ jobs: - name: Build a binary wheel and a source tarball run: | # Checkout the latest tag - the one we just created. - git fetch --tags - git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")" + git checkout ${{ steps.tag_version.outputs.new_tag }} python -m pip install build check-wheel-contents python -m build --sdist --wheel --outdir dist/ . check-wheel-contents dist/*.whl From 0a0b1d9acfdd052caa9181deec314d49b6b2b182 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 19 Sep 2024 09:01:54 +0100 Subject: [PATCH 074/331] Add back required part of the command --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33acb4bb6..8e27978c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -76,6 +76,7 @@ jobs: - name: Build a binary wheel and a source tarball run: | # Checkout the latest tag - the one we just created. + git fetch --tags git checkout ${{ steps.tag_version.outputs.new_tag }} python -m pip install build check-wheel-contents python -m build --sdist --wheel --outdir dist/ . From 6c6b3d02d43a50570ddeffa60425871bd0d4db48 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 05:05:09 +0000 Subject: [PATCH 075/331] Bump doccmd from 2024.9.18 to 2024.9.19.3 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.18 to 2024.9.19.3. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.18...2024.09.19.3) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5b19d3eab..b8fa414d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.18", + "doccmd==2024.9.19.3", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From d28b6ff158811b0be410125e1558454f87f2854d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Sep 2024 05:05:23 +0000 Subject: [PATCH 076/331] Bump ruff from 0.6.5 to 0.6.6 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.5 to 0.6.6. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.5...0.6.6) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5b19d3eab..f30fa77ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.5", + "ruff==0.6.6", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From b50290346c503b04835ba2c603a98117eff448ee Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 21 Sep 2024 11:55:01 +0100 Subject: [PATCH 077/331] Test shell snippets in documentation code blocks --- .pre-commit-config.yaml | 20 +++++++++++++++----- docs/source/ci-setup.rst | 4 ++-- docs/source/contributing.rst | 16 ++++++++-------- docs/source/docker.rst | 10 +++++----- docs/source/release-process.rst | 2 +- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 763b7a010..beac0fffe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,11 +19,6 @@ repos: files: spelling_private_dict\.txt$ - id: trailing-whitespace exclude: ^src/mock_vws/resources/ -- repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.10.0.1 - hooks: - - id: shellcheck - args: ["--shell", "bash"] - repo: local hooks: - id: custom-linters @@ -41,6 +36,19 @@ repos: pass_filenames: false types_or: [yaml] + - id: shellcheck + name: shellcheck + entry: shellcheck --shell bash + language: system + pass_filenames: false + types_or: [shell] + + - id: shellcheck-docs + name: shellcheck-docs + entry: doccmd --language=shell --language=console --command="shellcheck --shell=bash" + language: system + types_or: [markdown, rst] + - id: mypy name: mypy stages: [push] @@ -236,6 +244,8 @@ ci: - ruff-check-fix-docs - ruff-format-fix - ruff-format-fix-docs + - shellcheck + - shellcheck-docs - spelling - vulture - vulture-docs diff --git a/docs/source/ci-setup.rst b/docs/source/ci-setup.rst index b118d20bb..0c46b4d0b 100644 --- a/docs/source/ci-setup.rst +++ b/docs/source/ci-setup.rst @@ -22,7 +22,7 @@ Create environment variable files for secrets: $ mkdir -p ci_secrets $ cp vuforia_secrets.env.example ci_secrets/vuforia_secrets_1.env $ cp vuforia_secrets.env.example ci_secrets/vuforia_secrets_2.env - ... + $ ... Add Vuforia credentials for different target databases to the new files in the ``ci_secrets/`` directory. Add at least as many credentials files as there are builds in the GitHub test matrix. @@ -35,7 +35,7 @@ Add the encrypted secrets files to the repository: .. code-block:: console - $ PASSPHRASE_FOR_VUFORIA_SECRETS= make update-secrets + $ PASSPHRASE_FOR_VUFORIA_SECRETS="" make update-secrets $ git add secrets.tar.gpg $ git commit -m "Update secret archive" $ git push diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 315071d7d..2bea998bf 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -102,14 +102,14 @@ Skipping Some Tests Use the following custom ``pytest`` options to skip some tests: -.. code-block:: console - - --skip-real Skip tests for Real Vuforia - --skip-mock Skip tests for In Memory Mock Vuforia - --skip-docker_in_memory - Skip tests for In Memory version of Docker application - --skip-docker_build_tests - Skip tests for building Docker images +.. code-block:: text + + --skip-real Skip tests for Real Vuforia + --skip-mock Skip tests for In Memory Mock Vuforia + --skip-docker_in_memory + Skip tests for In Memory version of Docker application + --skip-docker_build_tests + Skip tests for building Docker images Documentation ------------- diff --git a/docs/source/docker.rst b/docs/source/docker.rst index bb63c6917..b8d053d17 100644 --- a/docs/source/docker.rst +++ b/docs/source/docker.rst @@ -154,13 +154,13 @@ Building images from source .. code-block:: console - $ export REPOSITORY_ROOT=$PWD - $ export DOCKERFILE=$REPOSITORY_ROOT/src/mock_vws/_flask_server/Dockerfile + $ export REPOSITORY_ROOT="$PWD" + $ export DOCKERFILE="$REPOSITORY_ROOT/src/mock_vws/_flask_server/Dockerfile" $ export TARGET_MANAGER_TAG=adamtheturtle/vuforia-target-manager-mock:latest $ export VWS_TAG=adamtheturtle/vuforia-vws-mock:latest $ export VWQ_TAG=adamtheturtle/vuforia-vwq-mock:latest - $ docker buildx build $REPOSITORY_ROOT --file $DOCKERFILE --target target-manager --tag $TARGET_MANAGER_TAG - $ docker buildx build $REPOSITORY_ROOT --file $DOCKERFILE --target vws --tag $VWS_TAG - $ docker buildx build $REPOSITORY_ROOT --file $DOCKERFILE --target vwq --tag $VWQ_TAG + $ docker buildx build "$REPOSITORY_ROOT" --file "$DOCKERFILE" --target target-manager --tag "$TARGET_MANAGER_TAG" + $ docker buildx build "$REPOSITORY_ROOT" --file "$DOCKERFILE" --target vws --tag "$VWS_TAG" + $ docker buildx build "$REPOSITORY_ROOT" --file "$DOCKERFILE" --target vwq --tag "$VWQ_TAG" diff --git a/docs/source/release-process.rst b/docs/source/release-process.rst index 0c662f553..db1744feb 100644 --- a/docs/source/release-process.rst +++ b/docs/source/release-process.rst @@ -17,6 +17,6 @@ Perform a Release .. code-block:: console :substitutions: - $ gh workflow run release.yml --repo |github-owner|/|github-repository| + $ gh workflow run release.yml --repo "|github-owner|/|github-repository|" .. _Install GitHub CLI: https://cli.github.com/ From 61c5b022f4c83fd5481ceb874bfebbb410071704 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 21 Sep 2024 12:02:04 +0100 Subject: [PATCH 078/331] Test shell snippets in documentation code blocks --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index beac0fffe..9df83b284 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -40,7 +40,6 @@ repos: name: shellcheck entry: shellcheck --shell bash language: system - pass_filenames: false types_or: [shell] - id: shellcheck-docs From cf3ebfaa139a5e6d553a945bbb16a0a3ed1769ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:49:47 +0000 Subject: [PATCH 079/331] Bump ruff from 0.6.6 to 0.6.7 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.6 to 0.6.7. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.6...0.6.7) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1216ecc8..2f65c0389 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.6", + "ruff==0.6.7", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From f80013a426fd8a199d28cc0cbef2b9a3b33e26b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:49:57 +0000 Subject: [PATCH 080/331] Bump doccmd from 2024.9.19.3 to 2024.9.21 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.19.3 to 2024.9.21. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.19.3...2024.09.21) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1216ecc8..ceb80f189 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.19.3", + "doccmd==2024.9.21", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 7462cfc5d408c7549226c680352cb1b1a75e60cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:50:13 +0000 Subject: [PATCH 081/331] Bump vws-python from 2024.9.4.1 to 2024.9.21 Bumps [vws-python](https://github.com/VWS-Python/vws-python) from 2024.9.4.1 to 2024.9.21. - [Release notes](https://github.com/VWS-Python/vws-python/releases) - [Changelog](https://github.com/VWS-Python/vws-python/blob/main/CHANGELOG.rst) - [Commits](https://github.com/VWS-Python/vws-python/compare/2024.09.04.1...2024.09.21) --- updated-dependencies: - dependency-name: vws-python dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1216ecc8..8ce74b736 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,7 +101,7 @@ optional-dependencies.dev = [ "types-requests==2.32.0.20240914", "urllib3==2.2.3", "vulture==2.12", - "vws-python==2024.9.4.1", + "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] From c14eada8768447f4e872669935e2aaa9f812ef3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:50:20 +0000 Subject: [PATCH 082/331] Bump sybil from 7.1.1 to 8.0.0 Bumps [sybil](https://github.com/simplistix/sybil) from 7.1.1 to 8.0.0. - [Changelog](https://github.com/simplistix/sybil/blob/master/CHANGELOG.rst) - [Commits](https://github.com/simplistix/sybil/compare/7.1.1...8.0.0) --- updated-dependencies: - dependency-name: sybil dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1216ecc8..99268cb65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "sphinx-toolbox==3.8.0", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", - "sybil==7.1.1", + "sybil==8.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pillow==10.2.0.20240822", From 7540a470b8916c596a1c403ddce644d64162eca4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:50:28 +0000 Subject: [PATCH 083/331] Bump pylint from 3.2.7 to 3.3.0 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.2.7 to 3.3.0. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.2.7...v3.3.0) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a1216ecc8..fb442fdd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ optional-dependencies.dev = [ "pre-commit==3.8.0", "pydocstyle==6.3", "pyenchant==3.2.2", - "pylint==3.2.7", + "pylint==3.3.0", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", "pyright==1.1.381", From de065c9d56f9a29932c8de3d008f7075cfd2fc30 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Sep 2024 07:31:55 +0100 Subject: [PATCH 084/331] Resolve pylint issues --- docs/source/conf.py | 2 -- src/mock_vws/_requests_mock_server/decorators.py | 2 +- tests/mock_vws/fixtures/vuforia_backends.py | 10 +++++----- tests/mock_vws/test_query.py | 1 + 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 508f67d87..6a2b33fd3 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,8 +3,6 @@ Configuration for Sphinx. """ -# pylint: disable=invalid-name - import datetime import importlib.metadata diff --git a/src/mock_vws/_requests_mock_server/decorators.py b/src/mock_vws/_requests_mock_server/decorators.py index 8a2a00740..03001f77f 100644 --- a/src/mock_vws/_requests_mock_server/decorators.py +++ b/src/mock_vws/_requests_mock_server/decorators.py @@ -57,13 +57,13 @@ class MockVWS(ContextDecorator): def __init__( self, + *, base_vws_url: str = "https://vws.vuforia.com", base_vwq_url: str = "https://cloudreco.vuforia.com", duplicate_match_checker: ImageMatcher = _STRUCTURAL_SIMILARITY_MATCHER, query_match_checker: ImageMatcher = _STRUCTURAL_SIMILARITY_MATCHER, processing_time_seconds: float = 2.0, target_tracking_rater: TargetTrackingRater = _BRISQUE_TRACKING_RATER, - *, real_http: bool = False, ) -> None: """ diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index 60594f837..8b05da637 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -66,7 +66,7 @@ def _enable_use_real_vuforia( working_database: VuforiaDatabase, inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, -) -> Generator[None, None, None]: +) -> Generator[None]: """Test against the real Vuforia.""" assert monkeypatch assert inactive_database @@ -80,7 +80,7 @@ def _enable_use_mock_vuforia( working_database: VuforiaDatabase, inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, -) -> Generator[None, None, None]: +) -> Generator[None]: """Test against the in-memory mock Vuforia.""" assert monkeypatch working_database = VuforiaDatabase( @@ -112,7 +112,7 @@ def _enable_use_docker_in_memory( working_database: VuforiaDatabase, inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, -) -> Generator[None, None, None]: +) -> Generator[None]: """Test against mock Vuforia created to be run in a container.""" # We set ``wsgi.input_terminated`` to ``True`` so that when going through # ``requests`` in our tests, the Flask applications @@ -239,7 +239,7 @@ def fixture_verify_mock_vuforia( vuforia_database: VuforiaDatabase, inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, -) -> Generator[None, None, None]: +) -> Generator[None]: """ Test functions which use this fixture are run multiple times. Once with the real Vuforia, and once with each mock. @@ -284,7 +284,7 @@ def mock_only_vuforia( vuforia_database: VuforiaDatabase, inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, -) -> Generator[None, None, None]: +) -> Generator[None]: """ Test functions which use this fixture are run multiple times. Once with the each mock. diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 65c2c1d54..05a9ae7bc 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -202,6 +202,7 @@ class TestContentType: ], ) def test_incorrect_no_boundary( + *, high_quality_image: io.BytesIO, vuforia_database: VuforiaDatabase, content_type: str, From c1cf389392df6f76d323fb573eb7f68f53182659 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Sep 2024 07:35:30 +0100 Subject: [PATCH 085/331] Remove some unnecessary pylint ignores --- pyproject.toml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fb442fdd2..ee90a3040 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -253,26 +253,23 @@ enable = [ disable = [ # Style issues that we can deal with ourselves 'too-few-public-methods', - 'too-many-ancestors', 'too-many-locals', 'too-many-arguments', 'too-many-instance-attributes', - 'too-many-return-statements', 'too-many-lines', - 'too-many-statements', 'locally-disabled', - # Let flake8 handle long lines + # Let ruff handle long lines 'line-too-long', - # Let flake8 handle unused imports + # Let ruff handle unused imports 'unused-import', - # Let isort deal with sorting + # Let ruff deal with sorting 'ungrouped-imports', # We don't need everything to be documented because of mypy 'missing-type-doc', 'missing-return-type-doc', # Too difficult to please 'duplicate-code', - # Let isort handle imports + # Let ruff handle imports 'wrong-import-order', ] From 91aa3661822a2f12812ffc43c095d12c885d16e2 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Sep 2024 21:40:49 +0100 Subject: [PATCH 086/331] Add check-json and meta pre-commit hooks --- .pre-commit-config.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9df83b284..1c07f02dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,9 @@ # See https://pre-commit.com/hooks.html for more hooks default_install_hook_types: [pre-commit, pre-push, commit-msg] repos: +- repo: meta + hooks: + - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: @@ -11,7 +14,8 @@ repos: - id: check-merge-conflict - id: check-shebang-scripts-are-executable - id: check-symlinks - - id: check-toml + - id: check-json + - id: check-toml - id: check-vcs-permalinks - id: check-yaml - id: end-of-file-fixer From cd368dd32958d1a2e69837083ef7b7dc58508f70 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Sep 2024 21:42:46 +0100 Subject: [PATCH 087/331] Fix indentation --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c07f02dc..f46bca19c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: check-shebang-scripts-are-executable - id: check-symlinks - id: check-json - - id: check-toml + - id: check-toml - id: check-vcs-permalinks - id: check-yaml - id: end-of-file-fixer From 23cbdade563aa7a2154f1d660346c5ed952d35ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 05:14:11 +0000 Subject: [PATCH 088/331] Bump doccmd from 2024.9.21 to 2024.9.23 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.21 to 2024.9.23. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.21...2024.09.23) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 58aee0297..323ee58af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.21", + "doccmd==2024.9.23", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 4749112ef21e403863fd0c443c2a5602c0f62c73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:00:20 +0000 Subject: [PATCH 089/331] Bump actionlint-py from 1.7.1.15 to 1.7.2.16 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.1.15 to 1.7.2.16. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.1.15...v1.7.2.16) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 323ee58af..94ef9ee6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dependencies = [ "werkzeug", ] optional-dependencies.dev = [ - "actionlint-py==1.7.1.15", + "actionlint-py==1.7.2.16", "check-manifest==0.49", "check-wheel-contents==0.6.0", "deptry==0.20.0", From 55846752d7ba7563f5d157b159479319ebd19c9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:00:26 +0000 Subject: [PATCH 090/331] Bump doccmd from 2024.9.23 to 2024.9.24 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.23 to 2024.9.24. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.23...2024.09.24) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 323ee58af..6e8145bfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.23", + "doccmd==2024.9.24", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 6431f7a0e6680e83ca87b670304e8f576d04b538 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Sep 2024 06:00:33 +0000 Subject: [PATCH 091/331] Bump pylint from 3.3.0 to 3.3.1 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.3.0 to 3.3.1. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.3.0...v3.3.1) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 323ee58af..a45b0849e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ optional-dependencies.dev = [ "pre-commit==3.8.0", "pydocstyle==6.3", "pyenchant==3.2.2", - "pylint==3.3.0", + "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", "pyright==1.1.381", From a76eb65921f1bc7d2e8be221c38b551d20f4ebd0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 25 Sep 2024 12:46:34 +0100 Subject: [PATCH 092/331] Update RTD build OS --- readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs.yaml b/readthedocs.yaml index 88e40e66a..d3bd4fd21 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -1,7 +1,7 @@ version: 2 build: - os: ubuntu-20.04 + os: ubuntu-24.04 tools: python: "3.12" From 7b28f07caaf7eff64fce6b4f125b594ea04cbe55 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 05:51:37 +0000 Subject: [PATCH 093/331] Bump pyright from 1.1.381 to 1.1.382.post0 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.381 to 1.1.382.post0. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.381...v1.1.382.post0) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bc8c39de2..018a897d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", - "pyright==1.1.381", + "pyright==1.1.382.post0", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 23dd98437a1c15781002db18ae829be22cdc5f23 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 26 Sep 2024 08:50:38 +0100 Subject: [PATCH 094/331] Remove ignores of deprecated ruff rules --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bc8c39de2..3f155f072 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -141,9 +141,6 @@ lint.select = [ "ALL", ] lint.ignore = [ - # We do not annotate the type of 'self', or 'cls'. - "ANN101", - "ANN102", # Ruff warns that this conflicts with the formatter. "COM812", # Allow our chosen docstring line-style - no one-line summary. From d143292e285c3e6d19d78c8995fd360831c104ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 06:01:46 +0000 Subject: [PATCH 095/331] Bump doccmd from 2024.9.24 to 2024.9.26 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.24 to 2024.9.26. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.24...2024.09.26) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3f155f072..a138c1dff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.24", + "doccmd==2024.9.26", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 60c9a33069e0c0781b884b20676758fa8b403db1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Sep 2024 06:02:40 +0000 Subject: [PATCH 096/331] Bump ruff from 0.6.7 to 0.6.8 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.7 to 0.6.8. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.7...0.6.8) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3f155f072..7ebdb31bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.7", + "ruff==0.6.8", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From a676a37273ee7649d04fb9ae12c077875bafe6b5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 09:26:14 +0100 Subject: [PATCH 097/331] Change the only `: frozenset` type hint to Iterable --- src/mock_vws/_mock_common.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mock_vws/_mock_common.py b/src/mock_vws/_mock_common.py index c60273676..ef1bc987f 100644 --- a/src/mock_vws/_mock_common.py +++ b/src/mock_vws/_mock_common.py @@ -3,6 +3,7 @@ """ import json +from collections.abc import Iterable from dataclasses import dataclass from typing import Any @@ -23,7 +24,7 @@ class Route: route_name: str path_pattern: str - http_methods: frozenset[str] + http_methods: Iterable[str] @beartype From cb8567a467bd53f0dd528d2d260f21ed6a3b17e0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 09:35:53 +0100 Subject: [PATCH 098/331] Pass around `Iterable[VuforiaDatabase]` rather than `set[VuforiaDatabase]` --- src/mock_vws/_query_tools.py | 4 ++-- src/mock_vws/_query_validators/__init__.py | 4 ++-- src/mock_vws/_query_validators/auth_validators.py | 6 +++--- .../_query_validators/project_state_validators.py | 4 ++-- src/mock_vws/_services_validators/__init__.py | 4 ++-- .../_services_validators/auth_validators.py | 6 +++--- .../_services_validators/name_validators.py | 6 +++--- .../project_state_validators.py | 4 ++-- .../_services_validators/target_validators.py | 4 ++-- src/mock_vws/target_manager.py | 13 +++++++++---- 10 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/mock_vws/_query_tools.py b/src/mock_vws/_query_tools.py index 2f2936f4b..9a4a7a0a0 100644 --- a/src/mock_vws/_query_tools.py +++ b/src/mock_vws/_query_tools.py @@ -5,7 +5,7 @@ import base64 import io import uuid -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from email.message import EmailMessage from typing import Any @@ -27,7 +27,7 @@ def get_query_match_response_text( request_body: bytes, request_method: str, request_path: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], query_match_checker: ImageMatcher, ) -> str: """ diff --git a/src/mock_vws/_query_validators/__init__.py b/src/mock_vws/_query_validators/__init__.py index 411bdd995..a933a919c 100644 --- a/src/mock_vws/_query_validators/__init__.py +++ b/src/mock_vws/_query_validators/__init__.py @@ -2,7 +2,7 @@ Input validators to use in the mock query API. """ -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from beartype import beartype @@ -47,7 +47,7 @@ def run_query_validators( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Run all validators. diff --git a/src/mock_vws/_query_validators/auth_validators.py b/src/mock_vws/_query_validators/auth_validators.py index 054a82a78..555dea6c9 100644 --- a/src/mock_vws/_query_validators/auth_validators.py +++ b/src/mock_vws/_query_validators/auth_validators.py @@ -3,7 +3,7 @@ """ import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from beartype import beartype @@ -65,7 +65,7 @@ def validate_auth_header_number_of_parts( def validate_client_key_exists( *, request_headers: Mapping[str, str], - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the authorization header includes a client key for a database. @@ -116,7 +116,7 @@ def validate_authorization( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the authorization header given to the query endpoint. diff --git a/src/mock_vws/_query_validators/project_state_validators.py b/src/mock_vws/_query_validators/project_state_validators.py index dccf202fc..ae5065741 100644 --- a/src/mock_vws/_query_validators/project_state_validators.py +++ b/src/mock_vws/_query_validators/project_state_validators.py @@ -3,7 +3,7 @@ """ import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from beartype import beartype @@ -21,7 +21,7 @@ def validate_project_state( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the state of the project. diff --git a/src/mock_vws/_services_validators/__init__.py b/src/mock_vws/_services_validators/__init__.py index e49561adf..f2c72aec6 100644 --- a/src/mock_vws/_services_validators/__init__.py +++ b/src/mock_vws/_services_validators/__init__.py @@ -2,7 +2,7 @@ Input validators to use in the mock. """ -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from mock_vws.database import VuforiaDatabase @@ -56,7 +56,7 @@ def run_services_validators( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Run all validators. diff --git a/src/mock_vws/_services_validators/auth_validators.py b/src/mock_vws/_services_validators/auth_validators.py index e3ec36d23..89fe85f88 100644 --- a/src/mock_vws/_services_validators/auth_validators.py +++ b/src/mock_vws/_services_validators/auth_validators.py @@ -3,7 +3,7 @@ """ import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from http import HTTPStatus from beartype import beartype @@ -38,7 +38,7 @@ def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None: def validate_access_key_exists( *, request_headers: Mapping[str, str], - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the authorization header includes an access key for a database. @@ -95,7 +95,7 @@ def validate_authorization( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the authorization header given to a VWS endpoint. diff --git a/src/mock_vws/_services_validators/name_validators.py b/src/mock_vws/_services_validators/name_validators.py index f11de3cd6..516e320e6 100644 --- a/src/mock_vws/_services_validators/name_validators.py +++ b/src/mock_vws/_services_validators/name_validators.py @@ -4,7 +4,7 @@ import json import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from http import HTTPMethod, HTTPStatus from beartype import beartype @@ -121,7 +121,7 @@ def validate_name_length(*, request_body: bytes) -> None: @beartype def validate_name_does_not_exist_new_target( *, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], request_body: bytes, request_headers: Mapping[str, str], request_method: str, @@ -182,7 +182,7 @@ def validate_name_does_not_exist_existing_target( request_body: bytes, request_method: str, request_path: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate that the name does not exist for any existing target apart from diff --git a/src/mock_vws/_services_validators/project_state_validators.py b/src/mock_vws/_services_validators/project_state_validators.py index cd21bebee..a526d8f95 100644 --- a/src/mock_vws/_services_validators/project_state_validators.py +++ b/src/mock_vws/_services_validators/project_state_validators.py @@ -3,7 +3,7 @@ """ import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from http import HTTPMethod from beartype import beartype @@ -23,7 +23,7 @@ def validate_project_state( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate the state of the project. diff --git a/src/mock_vws/_services_validators/target_validators.py b/src/mock_vws/_services_validators/target_validators.py index 11bb4df9c..f417fceaf 100644 --- a/src/mock_vws/_services_validators/target_validators.py +++ b/src/mock_vws/_services_validators/target_validators.py @@ -3,7 +3,7 @@ """ import logging -from collections.abc import Mapping +from collections.abc import Iterable, Mapping from beartype import beartype @@ -21,7 +21,7 @@ def validate_target_id_exists( request_headers: Mapping[str, str], request_body: bytes, request_method: str, - databases: set[VuforiaDatabase], + databases: Iterable[VuforiaDatabase], ) -> None: """ Validate that if a target ID is given, it exists in the database matching diff --git a/src/mock_vws/target_manager.py b/src/mock_vws/target_manager.py index fb8543c23..c5887d28a 100644 --- a/src/mock_vws/target_manager.py +++ b/src/mock_vws/target_manager.py @@ -2,10 +2,15 @@ A fake implementation of a Vuforia target manager. """ +from typing import TYPE_CHECKING + from beartype import beartype from mock_vws.database import VuforiaDatabase +if TYPE_CHECKING: + from collections.abc import Iterable + @beartype class TargetManager: @@ -17,7 +22,7 @@ def __init__(self) -> None: """ Create a target manager with no databases. """ - self._databases: set[VuforiaDatabase] = set() + self._databases: Iterable[VuforiaDatabase] = set() def remove_database(self, database: VuforiaDatabase) -> None: """ @@ -29,7 +34,7 @@ def remove_database(self, database: VuforiaDatabase) -> None: Raises: KeyError: The database is not in the target manager. """ - self._databases.remove(database) + self._databases = {db for db in self._databases if db != database} def add_database(self, database: VuforiaDatabase) -> None: """ @@ -78,11 +83,11 @@ def add_database(self, database: VuforiaDatabase) -> None: message = message_fmt.format(key_name=key_name, value=new) raise ValueError(message) - self._databases.add(database) + self._databases = {*self._databases, database} @property def databases(self) -> set[VuforiaDatabase]: """ All cloud databases. """ - return self._databases + return set(self._databases) From 7e3ecee4fa20f486d3927018be1e9f4d48e5472a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 09:44:59 +0100 Subject: [PATCH 099/331] Treat endpoing headers as Mapping --- tests/mock_vws/test_query.py | 9 ++++++--- tests/mock_vws/utils/__init__.py | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 05a9ae7bc..cbf1f92a3 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -15,7 +15,7 @@ import time import uuid from http import HTTPMethod, HTTPStatus -from typing import Any +from typing import TYPE_CHECKING, Any from urllib.parse import urljoin from zoneinfo import ZoneInfo @@ -48,6 +48,9 @@ ) from tests.mock_vws.utils.too_many_requests import handle_server_errors +if TYPE_CHECKING: + from collections.abc import Iterable + VWQ_HOST = "https://cloudreco.vuforia.com" _JETTY_CONTENT_TYPE_ERROR = textwrap.dedent( @@ -983,7 +986,7 @@ def _add_and_wait_for_targets( """ Add targets with the given image. """ - target_ids: set[str] = set() + target_ids: Iterable[str] = set() for _ in range(num_targets): target_id = vws_client.add_target( name=uuid.uuid4().hex, @@ -992,7 +995,7 @@ def _add_and_wait_for_targets( active_flag=True, application_metadata=None, ) - target_ids.add(target_id) + target_ids = {*target_ids, target_id} for created_target_id in target_ids: vws_client.wait_for_target_processed(target_id=created_target_id) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 4519b350a..448f3e902 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -4,6 +4,7 @@ import io import secrets +from collections.abc import Mapping from dataclasses import dataclass from typing import Literal from urllib.parse import urljoin @@ -47,7 +48,7 @@ class Endpoint: base_url: str path_url: str method: str - headers: dict[str, str] + headers: Mapping[str, str] data: bytes | str successful_headers_result_code: ResultCodes successful_headers_status_code: int From fb05e49f90fd78ada22993e5c49e1d2bde8043ac Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 09:48:25 +0100 Subject: [PATCH 100/331] Use immutable types in key validators --- src/mock_vws/_services_validators/key_validators.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mock_vws/_services_validators/key_validators.py b/src/mock_vws/_services_validators/key_validators.py index dc2bc3063..7b3b4109b 100644 --- a/src/mock_vws/_services_validators/key_validators.py +++ b/src/mock_vws/_services_validators/key_validators.py @@ -5,6 +5,7 @@ import json import logging import re +from collections.abc import Iterable from dataclasses import dataclass from http import HTTPMethod, HTTPStatus @@ -30,9 +31,9 @@ class _Route: """ path_pattern: str - http_methods: set[HTTPMethod] - mandatory_keys: set[str] - optional_keys: set[str] + http_methods: Iterable[HTTPMethod] + mandatory_keys: Iterable[str] + optional_keys: Iterable[str] @beartype @@ -142,12 +143,12 @@ def validate_keys( pattern=re.compile(pattern=f"{route.path_pattern}$"), string=request_path, ) - and request_method in route.http_methods + and request_method in set(route.http_methods) ) mandatory_keys = matching_route.mandatory_keys optional_keys = matching_route.optional_keys - allowed_keys = mandatory_keys.union(optional_keys) + allowed_keys = {*mandatory_keys, *optional_keys} if not request_body and not allowed_keys: return @@ -156,7 +157,7 @@ def validate_keys( request_json = json.loads(s=request_text) given_keys = set(request_json.keys()) all_given_keys_allowed = given_keys.issubset(allowed_keys) - all_mandatory_keys_given = mandatory_keys.issubset(given_keys) + all_mandatory_keys_given = set(mandatory_keys).issubset(set(given_keys)) if all_given_keys_allowed and all_mandatory_keys_given: return From 3609f03d4a0ca18b5f9824403bd6b3c4d7a78fb6 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 09:52:19 +0100 Subject: [PATCH 101/331] Change mock web query API to take iterable HTTP Methods not set --- src/mock_vws/_requests_mock_server/mock_web_query_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index cc6871b80..8a5dbe696 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -6,7 +6,7 @@ """ import email.utils -from collections.abc import Callable +from collections.abc import Callable, Iterable from http import HTTPMethod, HTTPStatus from beartype import beartype @@ -31,7 +31,7 @@ @beartype def route( path_pattern: str, - http_methods: set[str], + http_methods: Iterable[str], ) -> Callable[[Callable[..., _ResponseType]], Callable[..., _ResponseType]]: """ Register a decorated method so that it can be recognized as a route. From e411acd73ea8f714a20ac99d26331043951a37d8 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:06:11 +0100 Subject: [PATCH 102/331] Change a few more `set` types to Iterable --- ci/test_custom_linters.py | 10 +++++++--- .../_requests_mock_server/decorators.py | 17 +++++++++++++---- .../mock_web_services_api.py | 4 ++-- tests/mock_vws/test_docker.py | 6 +++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ci/test_custom_linters.py b/ci/test_custom_linters.py index cac363803..55b0fec8e 100644 --- a/ci/test_custom_linters.py +++ b/ci/test_custom_linters.py @@ -3,11 +3,15 @@ """ from pathlib import Path +from typing import TYPE_CHECKING import pytest import yaml from beartype import beartype +if TYPE_CHECKING: + from collections.abc import Iterable + @beartype def _ci_patterns(*, repository_root: Path) -> set[str]: @@ -34,7 +38,7 @@ def _tests_from_pattern( """ # Clear the captured output. capsys.readouterr() - tests: set[str] = set() + tests: Iterable[str] = set() pytest.main( args=[ "-q", @@ -49,8 +53,8 @@ def _tests_from_pattern( # We filter empty lines and lines which look like # "9 tests collected in 0.01s". if line and "collected in" not in line: - tests.add(line) - return tests + tests = {*tests, line} + return set(tests) def test_ci_patterns_valid(request: pytest.FixtureRequest) -> None: diff --git a/src/mock_vws/_requests_mock_server/decorators.py b/src/mock_vws/_requests_mock_server/decorators.py index 03001f77f..547213f3a 100644 --- a/src/mock_vws/_requests_mock_server/decorators.py +++ b/src/mock_vws/_requests_mock_server/decorators.py @@ -4,7 +4,7 @@ import re from contextlib import ContextDecorator -from typing import Literal, Self +from typing import TYPE_CHECKING, Literal, Self from urllib.parse import urljoin, urlparse from beartype import BeartypeConf, beartype @@ -24,6 +24,9 @@ from .mock_web_query_api import MockVuforiaWebQueryAPI from .mock_web_services_api import MockVuforiaWebServicesAPI +if TYPE_CHECKING: + from collections.abc import Iterable + _STRUCTURAL_SIMILARITY_MATCHER = StructuralSimilarityMatcher() _BRISQUE_TRACKING_RATER = BrisqueTargetTrackingRater() @@ -132,7 +135,7 @@ def __enter__(self) -> Self: Returns: ``self``. """ - compiled_url_patterns: set[re.Pattern[str]] = set() + compiled_url_patterns: Iterable[re.Pattern[str]] = set() mock = RequestsMock(assert_all_requests_are_fired=False) for vws_route in self._mock_vws_api.routes: @@ -141,7 +144,10 @@ def __enter__(self) -> Self: url=f"{vws_route.path_pattern}$", ) compiled_url_pattern = re.compile(pattern=url_pattern) - compiled_url_patterns.add(compiled_url_pattern) + compiled_url_patterns = { + *compiled_url_patterns, + compiled_url_pattern, + } for vws_http_method in vws_route.http_methods: mock.add_callback( @@ -157,7 +163,10 @@ def __enter__(self) -> Self: url=f"{vwq_route.path_pattern}$", ) compiled_url_pattern = re.compile(pattern=url_pattern) - compiled_url_patterns.add(compiled_url_pattern) + compiled_url_patterns = { + *compiled_url_patterns, + compiled_url_pattern, + } for vwq_http_method in vwq_route.http_methods: mock.add_callback( diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 36936c034..9a2f54d25 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -11,7 +11,7 @@ import email.utils import json import uuid -from collections.abc import Callable +from collections.abc import Callable, Iterable from http import HTTPMethod, HTTPStatus from typing import Any from zoneinfo import ZoneInfo @@ -45,7 +45,7 @@ @beartype def route( path_pattern: str, - http_methods: set[HTTPMethod], + http_methods: Iterable[HTTPMethod], ) -> Callable[[Callable[..., _ResponseType]], Callable[..., _ResponseType]]: """ Register a decorated method so that it can be recognized as a route. diff --git a/tests/mock_vws/test_docker.py b/tests/mock_vws/test_docker.py index 3ad5a0ef5..8fd62fe32 100644 --- a/tests/mock_vws/test_docker.py +++ b/tests/mock_vws/test_docker.py @@ -4,7 +4,7 @@ import io import uuid -from collections.abc import Iterator +from collections.abc import Iterable, Iterator from http import HTTPStatus from typing import TYPE_CHECKING @@ -76,13 +76,13 @@ def fixture_custom_bridge_network() -> Iterator[Network]: yield network finally: network.reload() - images_to_remove: set[Image] = set() + images_to_remove: Iterable[Image] = set() for container in network.containers: network.disconnect(container=container) container.stop() container.remove(v=True, force=True) assert container.image is not None - images_to_remove.add(container.image) + images_to_remove = {*images_to_remove, container.image} # This does leave behind untagged images. for image in images_to_remove: From 6451476f0063d65db231346e92d60f33f42130ce Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:09:20 +0100 Subject: [PATCH 103/331] Remove unnecessary type hint --- src/mock_vws/_requests_mock_server/mock_web_services_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 9a2f54d25..a808215f3 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -498,7 +498,7 @@ def get_duplicates(self, request: PreparedRequest) -> _ResponseType: other_targets = database.targets - {target} - similar_targets: list[str] = [ + similar_targets = [ other.target_id for other in other_targets if self._duplicate_match_checker( From a12e86d270f75675d52f53fce89a8964959e8c11 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:09:40 +0100 Subject: [PATCH 104/331] Remove some unnecessary type hints --- src/mock_vws/_flask_server/vws.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index d5913f479..5a909cd44 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -469,7 +469,7 @@ def get_duplicates(target_id: str) -> Response: ) other_targets = database.targets - {target} - similar_targets: list[str] = [ + similar_targets = [ other.target_id for other in other_targets if image_match_checker( From 1664e4fdc7904e33210293bc27ff4df54f180dc9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:17:45 +0100 Subject: [PATCH 105/331] Switch a few dict types to Mapping --- src/mock_vws/_query_validators/exceptions.py | 3 ++- src/mock_vws/_requests_mock_server/mock_web_query_api.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index 8a39d468b..f849addd0 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -5,6 +5,7 @@ import email.utils import textwrap import uuid +from collections.abc import Mapping from http import HTTPStatus from beartype import beartype @@ -22,7 +23,7 @@ class ValidatorError(Exception): status_code: HTTPStatus response_text: str - headers: dict[str, str] + headers: Mapping[str, str] @beartype diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index 8a5dbe696..d3f4ffb6f 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -6,7 +6,7 @@ """ import email.utils -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Mapping from http import HTTPMethod, HTTPStatus from beartype import beartype @@ -25,7 +25,7 @@ _ROUTES: set[Route] = set() -_ResponseType = tuple[int, dict[str, str], str] +_ResponseType = tuple[int, Mapping[str, str], str] @beartype From d0d0beda2d884b2df3edb95dd11d56a106784e80 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:19:49 +0100 Subject: [PATCH 106/331] Remove a few dict type hints --- .../_requests_mock_server/mock_web_services_api.py | 8 ++------ src/mock_vws/_services_validators/exceptions.py | 3 ++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index a808215f3..1480b2524 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -11,7 +11,7 @@ import email.utils import json import uuid -from collections.abc import Callable, Iterable +from collections.abc import Callable, Iterable, Mapping from http import HTTPMethod, HTTPStatus from typing import Any from zoneinfo import ZoneInfo @@ -39,7 +39,7 @@ _ROUTES: set[Route] = set() -_ResponseType = tuple[int, dict[str, str], str] +_ResponseType = tuple[int, Mapping[str, str], str] @beartype @@ -231,7 +231,6 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: except ValidatorError as exc: return exc.status_code, exc.headers, exc.response_text - body: dict[str, str] = {} database = get_database_matching_server_keys( request_headers=request.headers, request_body=_body_bytes(request=request), @@ -298,8 +297,6 @@ def database_summary(self, request: PreparedRequest) -> _ResponseType: except ValidatorError as exc: return exc.status_code, exc.headers, exc.response_text - body: dict[str, str | int] = {} - database = get_database_matching_server_keys( request_headers=request.headers, request_body=_body_bytes(request=request), @@ -568,7 +565,6 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: target_id = request.path_url.split(sep="/")[-1] target = database.get_target(target_id=target_id) - body: dict[str, str] = {} date = email.utils.formatdate( timeval=None, diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index cce50859f..cb1125ac4 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -5,6 +5,7 @@ import email.utils import textwrap import uuid +from collections.abc import Mapping from http import HTTPStatus from pathlib import Path @@ -22,7 +23,7 @@ class ValidatorError(Exception): status_code: HTTPStatus response_text: str - headers: dict[str, str] + headers: Mapping[str, str] @beartype From 9b5ec4a8de6e5de8a664a72f7903b1c837ff34af Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:20:29 +0100 Subject: [PATCH 107/331] Remove some type hints --- src/mock_vws/_requests_mock_server/mock_web_services_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 1480b2524..740260ff8 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -376,7 +376,7 @@ def target_list(self, request: PreparedRequest) -> _ResponseType: response_results = [ target.target_id for target in database.not_deleted_targets ] - body: dict[str, str | list[str]] = { + body = { "transaction_id": uuid.uuid4().hex, "result_code": ResultCodes.SUCCESS.value, "results": response_results, From 9af3443e8ff53d00c5a744aab5f4111f66524648 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:22:53 +0100 Subject: [PATCH 108/331] Remove unnecessary type hint --- tests/mock_vws/fixtures/prepared_requests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index 3f949c5c0..37968f01f 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -50,7 +50,7 @@ def add_target( encoding="ascii" ) date = rfc_1123_date() - data: dict[str, Any] = { + data = { "name": "example_name", "width": 1, "image": image_data_encoded, From b88adcfc80d4c533c7e5201c0409e022627a98cf Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:43:09 +0100 Subject: [PATCH 109/331] Progress towards removing global variable for _ROUTES --- .../_requests_mock_server/mock_web_query_api.py | 11 +++++------ .../_requests_mock_server/mock_web_services_api.py | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index d3f4ffb6f..01b87d423 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -55,13 +55,12 @@ def decorator( The given `method` with multiple changes, including added validators. """ - _ROUTES.add( - Route( - route_name=method.__name__, - path_pattern=path_pattern, - http_methods=frozenset(http_methods), - ), + new_route = Route( + route_name=method.__name__, + path_pattern=path_pattern, + http_methods=frozenset(http_methods), ) + _ROUTES.add(new_route) return method diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 740260ff8..3f6a70ff4 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -70,13 +70,12 @@ def decorator( The given `method` with multiple changes, including added validators. """ - _ROUTES.add( - Route( - route_name=method.__name__, - path_pattern=path_pattern, - http_methods=frozenset(http_methods), - ), + new_route = Route( + route_name=method.__name__, + path_pattern=path_pattern, + http_methods=frozenset(http_methods), ) + _ROUTES.add(new_route) return method From 160d2191dc2c78ef4c31b7d0df6d90fe169f9ce1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 10:49:33 +0100 Subject: [PATCH 110/331] Remove unnecessary type hint --- src/mock_vws/_requests_mock_server/mock_web_query_api.py | 2 +- src/mock_vws/_requests_mock_server/mock_web_services_api.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index 01b87d423..1a287066a 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -101,7 +101,7 @@ def __init__( Attributes: routes: The `Route`s to be used in the mock. """ - self.routes: set[Route] = _ROUTES + self.routes = _ROUTES self._target_manager = target_manager self._query_match_checker = query_match_checker diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 3f6a70ff4..07d6c719c 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -127,7 +127,7 @@ def __init__( routes: The `Route`s to be used in the mock. """ self._target_manager = target_manager - self.routes: set[Route] = _ROUTES + self.routes = _ROUTES self._processing_time_seconds = processing_time_seconds self._duplicate_match_checker = duplicate_match_checker self._target_tracking_rater = target_tracking_rater From 0f0cdb10e4ac2d8b87a7537d5f6edf7064a5e81b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 28 Sep 2024 11:30:02 +0100 Subject: [PATCH 111/331] Make DatabaseDict.targets immutable --- src/mock_vws/database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mock_vws/database.py b/src/mock_vws/database.py index 153c8f580..4c2e47a1d 100644 --- a/src/mock_vws/database.py +++ b/src/mock_vws/database.py @@ -3,6 +3,7 @@ """ import uuid +from collections.abc import Iterable from dataclasses import dataclass, field from typing import Self, TypedDict @@ -25,7 +26,7 @@ class DatabaseDict(TypedDict): client_access_key: str client_secret_key: str state_name: str - targets: list[TargetDict] + targets: Iterable[TargetDict] @beartype From 2b67145007d6c3c99d63b126ad17c2abddbc8db6 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:12:07 +0100 Subject: [PATCH 112/331] Add stubs for tests for target raters + Flask usage --- tests/mock_vws/test_flask_app_usage.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 6d9f7e462..0c87dca7a 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -434,3 +434,16 @@ def test_structural_similarity_matcher( vws_client.wait_for_target_processed(target_id=duplicate_target_id) duplicates = vws_client.get_duplicate_targets(target_id=target_id) assert duplicates == [duplicate_target_id] + + +class TestTargetRaters: + """Tests for using target raters.""" + + def test_brisque(self) -> None: + """It is possible to use the BRISQUE target rater.""" + + def test_perfect(self) -> None: + """It is possible to use the perfect target rater.""" + + def test_random(self) -> None: + """It is possible to use the random target rater.""" From bb8373d8606bf36167f940d2b6704a0dfd9b5c91 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:14:41 +0100 Subject: [PATCH 113/331] Set environment variables in new tests --- tests/mock_vws/test_flask_app_usage.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 0c87dca7a..a97593c5b 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -439,11 +439,17 @@ def test_structural_similarity_matcher( class TestTargetRaters: """Tests for using target raters.""" - def test_brisque(self) -> None: + def test_default(self) -> None: + """By default, the BRISQUE target rater is used.""" + + def test_brisque(self, monkeypatch: pytest.MonkeyPatch) -> None: """It is possible to use the BRISQUE target rater.""" + monkeypatch.setenv(name="TARGET_RATER", value="brisque") - def test_perfect(self) -> None: + def test_perfect(self, monkeypatch: pytest.MonkeyPatch) -> None: """It is possible to use the perfect target rater.""" + monkeypatch.setenv(name="TARGET_RATER", value="perfect") - def test_random(self) -> None: + def test_random(self, monkeypatch: pytest.MonkeyPatch) -> None: """It is possible to use the random target rater.""" + monkeypatch.setenv(name="TARGET_RATER", value="random") From 4a939f4339cacee5097ed16f84e92db0e50ec437 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:21:39 +0100 Subject: [PATCH 114/331] Test for using the random target rater with Flask - working --- tests/mock_vws/test_flask_app_usage.py | 45 +++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index a97593c5b..423524baa 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -450,6 +450,49 @@ def test_perfect(self, monkeypatch: pytest.MonkeyPatch) -> None: """It is possible to use the perfect target rater.""" monkeypatch.setenv(name="TARGET_RATER", value="perfect") - def test_random(self, monkeypatch: pytest.MonkeyPatch) -> None: + def test_random( + self, + monkeypatch: pytest.MonkeyPatch, + high_quality_image: io.BytesIO, + ) -> None: """It is possible to use the random target rater.""" monkeypatch.setenv(name="TARGET_RATER", value="random") + + database = VuforiaDatabase() + databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" + requests.post(url=databases_url, json=database.to_dict(), timeout=30) + + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + + target_ids = [ + vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=high_quality_image, + application_metadata=None, + active_flag=True, + ) + for _ in range(50) + ] + + for target_id in target_ids: + vws_client.wait_for_target_processed(target_id=target_id) + + ratings = [ + vws_client.get_target_record( + target_id=target_id + ).target_record.tracking_rating + for target_id in target_ids + ] + + sorted_ratings = sorted(ratings) + lowest_rating = sorted_ratings[0] + highest_rating = sorted_ratings[-1] + minimum_rating = 0 + maximum_rating = 5 + assert lowest_rating >= minimum_rating + assert highest_rating <= maximum_rating + assert lowest_rating != highest_rating From 483ad53a22fb41df3043bb5a0a98896f386d06ba Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:29:23 +0100 Subject: [PATCH 115/331] Passing test for perfect rater --- src/mock_vws/_flask_server/target_manager.py | 2 +- tests/mock_vws/test_flask_app_usage.py | 40 +++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index d35387db8..189590c45 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -44,7 +44,7 @@ def to_target_rater(self) -> TargetTrackingRater: case self.BRISQUE: return BrisqueTargetTrackingRater() case self.PERFECT: - HardcodedTargetTrackingRater(rating=5) + return HardcodedTargetTrackingRater(rating=5) case self.RANDOM: return RandomTargetTrackingRater() diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 423524baa..67fdc66e8 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -446,9 +446,44 @@ def test_brisque(self, monkeypatch: pytest.MonkeyPatch) -> None: """It is possible to use the BRISQUE target rater.""" monkeypatch.setenv(name="TARGET_RATER", value="brisque") - def test_perfect(self, monkeypatch: pytest.MonkeyPatch) -> None: + def test_perfect( + self, + monkeypatch: pytest.MonkeyPatch, + high_quality_image: io.BytesIO, + ) -> None: """It is possible to use the perfect target rater.""" monkeypatch.setenv(name="TARGET_RATER", value="perfect") + database = VuforiaDatabase() + databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" + requests.post(url=databases_url, json=database.to_dict(), timeout=30) + + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + + target_ids = [ + vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=high_quality_image, + application_metadata=None, + active_flag=True, + ) + for _ in range(50) + ] + + for target_id in target_ids: + vws_client.wait_for_target_processed(target_id=target_id) + + ratings_set = { + vws_client.get_target_record( + target_id=target_id + ).target_record.tracking_rating + for target_id in target_ids + } + + assert ratings_set == {5} def test_random( self, @@ -496,3 +531,6 @@ def test_random( assert lowest_rating >= minimum_rating assert highest_rating <= maximum_rating assert lowest_rating != highest_rating + + def test_invalid_value(self) -> None: + """An error is raised if an invalid target rater is given.""" From 18b4f23d28546fa6403e45a55170e067d66731df Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:34:42 +0100 Subject: [PATCH 116/331] Add passing test for brisque --- tests/mock_vws/test_flask_app_usage.py | 50 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 67fdc66e8..1ef71d68c 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -442,10 +442,58 @@ class TestTargetRaters: def test_default(self) -> None: """By default, the BRISQUE target rater is used.""" - def test_brisque(self, monkeypatch: pytest.MonkeyPatch) -> None: + def test_brisque( + self, + monkeypatch: pytest.MonkeyPatch, + corrupted_image_file: io.BytesIO, + high_quality_image: io.BytesIO, + ) -> None: """It is possible to use the BRISQUE target rater.""" monkeypatch.setenv(name="TARGET_RATER", value="brisque") + database = VuforiaDatabase() + databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" + requests.post(url=databases_url, json=database.to_dict(), timeout=30) + + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + + corrupted_image_target_id = vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=corrupted_image_file, + application_metadata=None, + active_flag=True, + ) + + high_quality_image_target_id = vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=high_quality_image, + application_metadata=None, + active_flag=True, + ) + + for target_id in ( + corrupted_image_target_id, + high_quality_image_target_id, + ): + vws_client.wait_for_target_processed(target_id=target_id) + + corrupted_image_rating = vws_client.get_target_record( + target_id=corrupted_image_target_id, + ).target_record.tracking_rating + + high_quality_image_rating = vws_client.get_target_record( + target_id=high_quality_image_target_id, + ).target_record.tracking_rating + + # In the real Vuforia, this image may rate as -2. + assert corrupted_image_rating <= 0 + assert high_quality_image_rating > 1 + def test_perfect( self, monkeypatch: pytest.MonkeyPatch, From 5f06bcbb9b2c40e86341bb5aa1051d079526d669 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:35:54 +0100 Subject: [PATCH 117/331] Add test for default target rater --- tests/mock_vws/test_flask_app_usage.py | 48 +++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 1ef71d68c..ccbd35cfd 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -439,8 +439,54 @@ def test_structural_similarity_matcher( class TestTargetRaters: """Tests for using target raters.""" - def test_default(self) -> None: + def test_default( + self, + corrupted_image_file: io.BytesIO, + high_quality_image: io.BytesIO, + ) -> None: """By default, the BRISQUE target rater is used.""" + database = VuforiaDatabase() + databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" + requests.post(url=databases_url, json=database.to_dict(), timeout=30) + + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + + corrupted_image_target_id = vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=corrupted_image_file, + application_metadata=None, + active_flag=True, + ) + + high_quality_image_target_id = vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=high_quality_image, + application_metadata=None, + active_flag=True, + ) + + for target_id in ( + corrupted_image_target_id, + high_quality_image_target_id, + ): + vws_client.wait_for_target_processed(target_id=target_id) + + corrupted_image_rating = vws_client.get_target_record( + target_id=corrupted_image_target_id, + ).target_record.tracking_rating + + high_quality_image_rating = vws_client.get_target_record( + target_id=high_quality_image_target_id, + ).target_record.tracking_rating + + # In the real Vuforia, this image may rate as -2. + assert corrupted_image_rating <= 0 + assert high_quality_image_rating > 1 def test_brisque( self, From d333e1ac2f026b4e06e2b126338d1389653a4133 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:44:46 +0100 Subject: [PATCH 118/331] Avoid shadowing an exception --- .../_services_validators/target_validators.py | 15 +++++----- tests/mock_vws/test_flask_app_usage.py | 30 ++++++++++++++++++- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/mock_vws/_services_validators/target_validators.py b/src/mock_vws/_services_validators/target_validators.py index f417fceaf..bd9cff906 100644 --- a/src/mock_vws/_services_validators/target_validators.py +++ b/src/mock_vws/_services_validators/target_validators.py @@ -53,12 +53,11 @@ def validate_target_id_exists( databases=databases, ) - try: - (_,) = ( - target - for target in database.not_deleted_targets - if target.target_id == target_id - ) - except ValueError as exc: + matching_targets = [ + target + for target in database.not_deleted_targets + if target.target_id == target_id + ] + if not matching_targets: _LOGGER.warning('The target ID "%s" does not exist.', target_id) - raise UnknownTargetError from exc + raise UnknownTargetError diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index ccbd35cfd..ccdfb499c 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -626,5 +626,33 @@ def test_random( assert highest_rating <= maximum_rating assert lowest_rating != highest_rating - def test_invalid_value(self) -> None: + def test_invalid_value( + self, + monkeypatch: pytest.MonkeyPatch, + high_quality_image: io.BytesIO, + ) -> None: """An error is raised if an invalid target rater is given.""" + monkeypatch.setenv(name="TARGET_RATER", value=uuid.uuid4().hex) + database = VuforiaDatabase() + databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" + requests.post(url=databases_url, json=database.to_dict(), timeout=30) + + vws_client = VWS( + server_access_key=database.server_access_key, + server_secret_key=database.server_secret_key, + ) + + target_id = vws_client.add_target( + name=uuid.uuid4().hex, + width=1, + image=high_quality_image, + application_metadata=None, + active_flag=True, + ) + + vws_client.wait_for_target_processed(target_id=target_id) + + rating = vws_client.get_target_record( + target_id=target_id + ).target_record.tracking_rating + breakpoint() From 16fe3196866f8f09b512a138c363a3b8ecd64bf9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 13:50:29 +0100 Subject: [PATCH 119/331] Remove invalid value tests, for now --- tests/mock_vws/test_flask_app_usage.py | 31 -------------------------- 1 file changed, 31 deletions(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index ccdfb499c..05aae7089 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -625,34 +625,3 @@ def test_random( assert lowest_rating >= minimum_rating assert highest_rating <= maximum_rating assert lowest_rating != highest_rating - - def test_invalid_value( - self, - monkeypatch: pytest.MonkeyPatch, - high_quality_image: io.BytesIO, - ) -> None: - """An error is raised if an invalid target rater is given.""" - monkeypatch.setenv(name="TARGET_RATER", value=uuid.uuid4().hex) - database = VuforiaDatabase() - databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" - requests.post(url=databases_url, json=database.to_dict(), timeout=30) - - vws_client = VWS( - server_access_key=database.server_access_key, - server_secret_key=database.server_secret_key, - ) - - target_id = vws_client.add_target( - name=uuid.uuid4().hex, - width=1, - image=high_quality_image, - application_metadata=None, - active_flag=True, - ) - - vws_client.wait_for_target_processed(target_id=target_id) - - rating = vws_client.get_target_record( - target_id=target_id - ).target_record.tracking_rating - breakpoint() From 7ec07aad7ba40413c8a4722a131094fc83bb7235 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 29 Sep 2024 14:29:31 +0100 Subject: [PATCH 120/331] Fix no-self-use pylint error --- tests/mock_vws/test_flask_app_usage.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 05aae7089..0f9eda995 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -439,8 +439,8 @@ def test_structural_similarity_matcher( class TestTargetRaters: """Tests for using target raters.""" + @staticmethod def test_default( - self, corrupted_image_file: io.BytesIO, high_quality_image: io.BytesIO, ) -> None: @@ -488,8 +488,8 @@ def test_default( assert corrupted_image_rating <= 0 assert high_quality_image_rating > 1 + @staticmethod def test_brisque( - self, monkeypatch: pytest.MonkeyPatch, corrupted_image_file: io.BytesIO, high_quality_image: io.BytesIO, @@ -540,8 +540,8 @@ def test_brisque( assert corrupted_image_rating <= 0 assert high_quality_image_rating > 1 + @staticmethod def test_perfect( - self, monkeypatch: pytest.MonkeyPatch, high_quality_image: io.BytesIO, ) -> None: @@ -579,8 +579,8 @@ def test_perfect( assert ratings_set == {5} + @staticmethod def test_random( - self, monkeypatch: pytest.MonkeyPatch, high_quality_image: io.BytesIO, ) -> None: From c997eea7072393f823101229145b92c214042cf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 05:22:53 +0000 Subject: [PATCH 121/331] Bump doccmd from 2024.9.26 to 2024.9.27 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.26 to 2024.9.27. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.26...2024.09.27) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bf32366b7..859da0411 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.26", + "doccmd==2024.9.27", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From b7fd3c91dbd9963b620bcd1b20cc567c65d3bc37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 05:23:01 +0000 Subject: [PATCH 122/331] Bump pyright from 1.1.382.post0 to 1.1.382.post1 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.382.post0 to 1.1.382.post1. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.382.post0...v1.1.382.post1) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bf32366b7..d968b7250 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", - "pyright==1.1.382.post0", + "pyright==1.1.382.post1", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From c7f8a2d6493002dc92c0fd954bf7074fbd11d0da Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 05:36:28 +0000 Subject: [PATCH 123/331] Bump docker/build-push-action from 6.7.0 to 6.8.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.7.0 to 6.8.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.7.0...v6.8.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 8867074f0..3506cc3ef 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.7.0 + uses: docker/build-push-action@v6.8.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e288d816d..3e4909cb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,7 +100,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.7.0 + uses: docker/build-push-action@v6.8.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -111,7 +111,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.7.0 + uses: docker/build-push-action@v6.8.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -122,7 +122,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.7.0 + uses: docker/build-push-action@v6.8.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From 9f0f72ca18d681f2c41526322a62318d70207e7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 05:20:29 +0000 Subject: [PATCH 124/331] Bump docker/build-push-action from 6.8.0 to 6.9.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.8.0 to 6.9.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.8.0...v6.9.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 3506cc3ef..154816b9e 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.8.0 + uses: docker/build-push-action@v6.9.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e4909cb1..64521bb97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,7 +100,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.8.0 + uses: docker/build-push-action@v6.9.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -111,7 +111,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.8.0 + uses: docker/build-push-action@v6.9.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -122,7 +122,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.8.0 + uses: docker/build-push-action@v6.9.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From a4efbc56282fc4267fd740c09f56a8caf9905bbc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 05:20:23 +0000 Subject: [PATCH 125/331] Bump pyright from 1.1.382.post1 to 1.1.383 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.382.post1 to 1.1.383. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.382.post1...v1.1.383) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f452624b6..abde962a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", - "pyright==1.1.382.post1", + "pyright==1.1.383", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From a6781ef1c491fe880546cd79e4d0ae6a816ff197 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 05:40:05 +0000 Subject: [PATCH 126/331] Bump actionlint-py from 1.7.2.16 to 1.7.3.17 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.2.16 to 1.7.3.17. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.2.16...v1.7.3.17) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f452624b6..b15062e5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dependencies = [ "werkzeug", ] optional-dependencies.dev = [ - "actionlint-py==1.7.2.16", + "actionlint-py==1.7.3.17", "check-manifest==0.49", "check-wheel-contents==0.6.0", "deptry==0.20.0", From 7797dcfbf6ce3b5d750643d6595cb7fe6e787255 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 05:40:11 +0000 Subject: [PATCH 127/331] Bump vulture from 2.12 to 2.13 Bumps [vulture](https://github.com/jendrikseipp/vulture) from 2.12 to 2.13. - [Release notes](https://github.com/jendrikseipp/vulture/releases) - [Changelog](https://github.com/jendrikseipp/vulture/blob/main/CHANGELOG.md) - [Commits](https://github.com/jendrikseipp/vulture/compare/v2.12...v2.13) --- updated-dependencies: - dependency-name: vulture dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f452624b6..7e6fb7153 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,7 @@ optional-dependencies.dev = [ "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20240914", "urllib3==2.2.3", - "vulture==2.12", + "vulture==2.13", "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", From 004cbb86afd969cceb25e812e57ff57415f85702 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 3 Oct 2024 08:39:40 +0100 Subject: [PATCH 128/331] Calculate minimum Python version in Sphinx build --- README.rst | 5 +++-- docs/source/conf.py | 19 ++++++++++++------- docs/source/index.rst | 2 +- docs/source/installation.rst | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index addc7b528..52cd0dc66 100644 --- a/README.rst +++ b/README.rst @@ -13,12 +13,12 @@ Mocking calls made to Vuforia with Python ``requests`` Using the mock redirects requests to Vuforia made with `requests`_ to an in-memory implementation. -This requires Python 3.12+. - .. code-block:: shell pip install vws-python-mock +This requires Python |minimum-python-version|\+. + .. code-block:: python """Make a request to the Vuforia Web Services API mock.""" @@ -63,3 +63,4 @@ This includes details on how to use the mock, options, and details of the differ .. |Documentation Status| image:: https://readthedocs.org/projects/vws-python-mock/badge/?version=latest :target: https://vws-python-mock.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status +.. |minimum-python-version| replace:: 3.12 diff --git a/docs/source/conf.py b/docs/source/conf.py index 6a2b33fd3..7819a48b7 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -6,6 +6,8 @@ import datetime import importlib.metadata +from packaging.specifiers import SpecifierSet + project = "VWS-Python-Mock" author = "Adam Dangoor" @@ -43,21 +45,24 @@ _month, _day, _year, *_ = version.split(sep=".") release = f"{_month}.{_day}.{_year}" + +project_metadata = importlib.metadata.metadata(distribution_name=project) +requires_python = project_metadata["Requires-Python"] +specifiers = SpecifierSet(specifiers=requires_python) +(specifier,) = specifiers +assert specifier.operator == ">=" +minimum_python_version = specifier.version + language = "en" # The name of the syntax highlighting style to use. pygments_style = "sphinx" -python_minimum_supported_version = "3.12" - # Output file base name for HTML help builder. htmlhelp_basename = "VWSPYTHONMOCKdoc" autoclass_content = "init" intersphinx_mapping = { - "python": ( - f"https://docs.python.org/{python_minimum_supported_version}", - None, - ), + "python": (f"https://docs.python.org/{minimum_python_version}", None), "docker": ("https://docker-py.readthedocs.io/en/stable", None), } nitpicky = True @@ -80,9 +85,9 @@ autodoc_member_order = "bysource" rst_prolog = f""" -.. |python-minimum-version| replace:: {python_minimum_supported_version} .. |project| replace:: {project} .. |release| replace:: {release} +.. |minimum-python-version| replace:: {minimum_python_version} .. |github-owner| replace:: VWS-Python .. |github-repository| replace:: vws-python-mock """ diff --git a/docs/source/index.rst b/docs/source/index.rst index 4baabda22..6f39583a2 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -8,7 +8,7 @@ Mocking calls made to Vuforia with Python ``requests`` $ pip install vws-python-mock -This requires Python |python-minimum-version|\+. +This requires Python |minimum-python-version|\+. .. include:: basic-example.rst diff --git a/docs/source/installation.rst b/docs/source/installation.rst index ddcf7f2c3..ce56603b2 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -5,4 +5,4 @@ Installation $ pip install vws-python-mock -This requires Python |python-minimum-version|\+. +This requires Python |minimum-python-version|\+. From 2e0636d947c93a5e79d6270581049a7e3484fe93 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 4 Oct 2024 13:07:07 +0100 Subject: [PATCH 129/331] Remove types-pillow No longer needed as pillow ships types --- pyproject.toml | 1 - src/mock_vws/image_matchers.py | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2e467a225..0b2dde7b2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,6 @@ optional-dependencies.dev = [ "sybil==8.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", - "types-pillow==10.2.0.20240822", "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20240914", "urllib3==2.2.3", diff --git a/src/mock_vws/image_matchers.py b/src/mock_vws/image_matchers.py index b194b457e..0cb60a13e 100644 --- a/src/mock_vws/image_matchers.py +++ b/src/mock_vws/image_matchers.py @@ -75,23 +75,23 @@ def __call__( # Images must be the same size, and they must be larger than the # default SSIM window size of 11x11. target_size = (256, 256) - first_image = first_image.resize(size=target_size) - second_image = second_image.resize(size=target_size) + first_image_resized = first_image.resize(size=target_size) + second_image_resized = second_image.resize(size=target_size) - first_image_np = np.array(first_image, dtype=np.float32) + first_image_np = np.array(first_image_resized, dtype=np.float32) first_image_tensor = torch.tensor(first_image_np).float() / 255 first_image_tensor = first_image_tensor.view( - first_image.size[1], - first_image.size[0], - len(first_image.getbands()), + first_image_resized.size[1], + first_image_resized.size[0], + len(first_image_resized.getbands()), ) - second_image_np = np.array(second_image, dtype=np.float32) + second_image_np = np.array(second_image_resized, dtype=np.float32) second_image_tensor = torch.tensor(second_image_np).float() / 255 second_image_tensor = second_image_tensor.view( - second_image.size[1], - second_image.size[0], - len(second_image.getbands()), + second_image_resized.size[1], + second_image_resized.size[0], + len(second_image_resized.getbands()), ) first_image_tensor_batch_dimension = first_image_tensor.permute( From 940d20100206760e91515596f9b2539290e8c986 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 4 Oct 2024 23:40:26 +0100 Subject: [PATCH 130/331] Add shfmt to pre-commit --- .pre-commit-config.yaml | 15 +++++++++++++++ pyproject.toml | 1 + 2 files changed, 16 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f46bca19c..774e97054 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -52,6 +52,19 @@ repos: language: system types_or: [markdown, rst] + - id: shfmt + name: shfmt + entry: shfmt --write + language: system + pass_filenames: false + types_or: [shell] + + - id: shfmt-docs + name: shfmt-docs + entry: doccmd --language=shell --language=console --no-pad-file --command="shfmt --write" + language: system + types_or: [markdown, rst] + - id: mypy name: mypy stages: [push] @@ -249,6 +262,8 @@ ci: - ruff-format-fix-docs - shellcheck - shellcheck-docs + - shfmt + - shfmt-docs - spelling - vulture - vulture-docs diff --git a/pyproject.toml b/pyproject.toml index d1f2600f6..482915ace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ optional-dependencies.dev = [ # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. "shellcheck-py==0.10.0.1", + "shfmt-py==3.7.0.1", "sphinx==8.0.2", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", From 9c01c6aa0f4f27122c2434fb5c2e0a6e95220243 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 4 Oct 2024 22:41:44 +0000 Subject: [PATCH 131/331] [pre-commit.ci lite] apply automatic fixes --- docs/source/docker.rst | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/docs/source/docker.rst b/docs/source/docker.rst index b8d053d17..a4bae66b6 100644 --- a/docs/source/docker.rst +++ b/docs/source/docker.rst @@ -24,23 +24,23 @@ Creating containers $ docker network create -d bridge vws-bridge-network $ docker run \ - --detach \ - --publish 5005:5000 \ - --name vuforia-target-manager-mock \ - --network vws-bridge-network \ - adamtheturtle/vuforia-target-manager-mock + --detach \ + --publish 5005:5000 \ + --name vuforia-target-manager-mock \ + --network vws-bridge-network \ + adamtheturtle/vuforia-target-manager-mock $ docker run \ - --detach \ - --publish 5006:5000 \ - -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ - --network vws-bridge-network \ - adamtheturtle/vuforia-vws-mock + --detach \ + --publish 5006:5000 \ + -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ + --network vws-bridge-network \ + adamtheturtle/vuforia-vws-mock $ docker run \ - --detach \ - --publish 5007:5000 \ - -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ - --network vws-bridge-network \ - adamtheturtle/vuforia-vwq-mock + --detach \ + --publish 5007:5000 \ + -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ + --network vws-bridge-network \ + adamtheturtle/vuforia-vwq-mock Adding a database to the mock target manager @@ -61,17 +61,17 @@ For example, with the containers set up as in :ref:`creating-containers`, use `` .. code-block:: console $ curl --request POST \ - --header "Content-Type: application/json" \ - --data '{}' \ - '127.0.0.1:5005/databases' + --header "Content-Type: application/json" \ + --data '{}' \ + '127.0.0.1:5005/databases' { - "client_access_key": "2d61c1d17bb94694bee77c1f1f41e5d9", - "client_secret_key": "b73f8170cf7d42728fa8ce66221ad147", - "database_name": "e515df24ba944f43b8f7969bc98af107", - "server_access_key": "cb1759871a504875ab5f96d6db5ff79b", - "server_secret_key": "9b8533d912ad4aa79cb61b6ee197ece2", - "state_name": "WORKING", - "targets": [] + "client_access_key": "2d61c1d17bb94694bee77c1f1f41e5d9", + "client_secret_key": "b73f8170cf7d42728fa8ce66221ad147", + "database_name": "e515df24ba944f43b8f7969bc98af107", + "server_access_key": "cb1759871a504875ab5f96d6db5ff79b", + "server_secret_key": "9b8533d912ad4aa79cb61b6ee197ece2", + "state_name": "WORKING", + "targets": [] } Deleting a database From bdf56d7349e225af4ebc7d46dd9a64d0ecbba934 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 5 Oct 2024 00:02:39 +0100 Subject: [PATCH 132/331] Update shfmt commands --- .pre-commit-config.yaml | 4 ++-- docs/source/docker.rst | 50 ++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 774e97054..6ee57672e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,14 +54,14 @@ repos: - id: shfmt name: shfmt - entry: shfmt --write + entry: shfmt --write --space-redirects --indent=4 language: system pass_filenames: false types_or: [shell] - id: shfmt-docs name: shfmt-docs - entry: doccmd --language=shell --language=console --no-pad-file --command="shfmt --write" + entry: doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: system types_or: [markdown, rst] diff --git a/docs/source/docker.rst b/docs/source/docker.rst index a4bae66b6..e46c5d146 100644 --- a/docs/source/docker.rst +++ b/docs/source/docker.rst @@ -24,23 +24,23 @@ Creating containers $ docker network create -d bridge vws-bridge-network $ docker run \ - --detach \ - --publish 5005:5000 \ - --name vuforia-target-manager-mock \ - --network vws-bridge-network \ - adamtheturtle/vuforia-target-manager-mock + --detach \ + --publish 5005:5000 \ + --name vuforia-target-manager-mock \ + --network vws-bridge-network \ + adamtheturtle/vuforia-target-manager-mock $ docker run \ - --detach \ - --publish 5006:5000 \ - -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ - --network vws-bridge-network \ - adamtheturtle/vuforia-vws-mock + --detach \ + --publish 5006:5000 \ + -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ + --network vws-bridge-network \ + adamtheturtle/vuforia-vws-mock $ docker run \ - --detach \ - --publish 5007:5000 \ - -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ - --network vws-bridge-network \ - adamtheturtle/vuforia-vwq-mock + --detach \ + --publish 5007:5000 \ + -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ + --network vws-bridge-network \ + adamtheturtle/vuforia-vwq-mock Adding a database to the mock target manager @@ -61,17 +61,17 @@ For example, with the containers set up as in :ref:`creating-containers`, use `` .. code-block:: console $ curl --request POST \ - --header "Content-Type: application/json" \ - --data '{}' \ - '127.0.0.1:5005/databases' + --header "Content-Type: application/json" \ + --data '{}' \ + '127.0.0.1:5005/databases' { - "client_access_key": "2d61c1d17bb94694bee77c1f1f41e5d9", - "client_secret_key": "b73f8170cf7d42728fa8ce66221ad147", - "database_name": "e515df24ba944f43b8f7969bc98af107", - "server_access_key": "cb1759871a504875ab5f96d6db5ff79b", - "server_secret_key": "9b8533d912ad4aa79cb61b6ee197ece2", - "state_name": "WORKING", - "targets": [] + "client_access_key": "2d61c1d17bb94694bee77c1f1f41e5d9", + "client_secret_key": "b73f8170cf7d42728fa8ce66221ad147", + "database_name": "e515df24ba944f43b8f7969bc98af107", + "server_access_key": "cb1759871a504875ab5f96d6db5ff79b", + "server_secret_key": "9b8533d912ad4aa79cb61b6ee197ece2", + "state_name": "WORKING", + "targets": [] } Deleting a database From df00de7b553784349cdbdb76436214dfed5e15c2 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 5 Oct 2024 00:19:08 +0100 Subject: [PATCH 133/331] Fix pre-commit shfmt issue --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6ee57672e..36e7513bd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,5 @@ +fail_fast: true + # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_install_hook_types: [pre-commit, pre-push, commit-msg] @@ -56,7 +58,6 @@ repos: name: shfmt entry: shfmt --write --space-redirects --indent=4 language: system - pass_filenames: false types_or: [shell] - id: shfmt-docs From a6ab6b66e44581b5d035dd9d376bd0bb815162d4 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 14:07:00 +0100 Subject: [PATCH 134/331] Update calling method for shellcheck shell option to be consistent amoung projects --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36e7513bd..1898185a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: hooks: - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -44,7 +44,7 @@ repos: - id: shellcheck name: shellcheck - entry: shellcheck --shell bash + entry: shellcheck --shell=bash language: system types_or: [shell] From 959baded405a3fe04889054fbcf6d3f16c39e03c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 14:12:52 +0100 Subject: [PATCH 135/331] Exclude shellcheck error which prevents it from working on Windows --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 36e7513bd..d138318d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,7 +8,7 @@ repos: hooks: - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -44,13 +44,13 @@ repos: - id: shellcheck name: shellcheck - entry: shellcheck --shell bash + entry: shellcheck --shell=bash --exclude=SC1017 language: system types_or: [shell] - id: shellcheck-docs name: shellcheck-docs - entry: doccmd --language=shell --language=console --command="shellcheck --shell=bash" + entry: doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" language: system types_or: [markdown, rst] From f7df67823e1e8410459885635a4df5fb4f3fc575 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 14:29:28 +0100 Subject: [PATCH 136/331] Ignore D004 errors in doc8 so it works on Windows --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 482915ace..95ac54f3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -395,6 +395,9 @@ ignore_path = [ "./src/*/_setuptools_scm_version.txt", ] +# See https://github.com/PyCQA/doc8/issues/78 +ignore = [ "D004" ] + [tool.vulture] # Ideally we would limit the paths to the source code where we want to ignore names, # but Vulture does not enable this. From b132994316829569b178ab439235cedc6840a922 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 17:09:38 +0100 Subject: [PATCH 137/331] Use setup-uv GitHub Action --- .github/workflows/ci.yml | 14 +++----------- .github/workflows/lint.yml | 20 ++++++-------------- .github/workflows/release.yml | 13 +++++-------- .github/workflows/skip-tests.yml | 14 +++----------- .github/workflows/windows-ci.yml | 14 +++----------- 5 files changed, 20 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e01d924ed..ce834f162 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,10 +124,8 @@ jobs: # See https://github.com/codecov/codecov-action/issues/190. fetch-depth: 2 - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: "Set secrets file" run: | @@ -140,12 +138,6 @@ jobs: ENCRYPTED_FILE: secrets.tar.gpg LARGE_SECRET_PASSPHRASE: ${{ secrets.PASSPHRASE_FOR_VUFORIA_SECRETS }} - # We do not use the cache action as uv is faster than the cache action. - - name: "Install dependencies" - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - uv pip install --system --upgrade --editable .[dev] - # We have seen issues with running out of disk space on test_docker - name: Free Disk Space (Ubuntu) uses: jlumbroso/free-disk-space@main @@ -163,7 +155,7 @@ jobs: - name: "Run tests" run: | - pytest \ + uv run --all-extras --python=${{ matrix.python-version }} pytest \ -s \ -vvv \ --showlocals \ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6084052c3..3cc57dc62 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,22 +23,14 @@ jobs: python-version: ["3.12"] steps: - uses: actions/checkout@v4 - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - # We do not use the cache action as uv is faster than the cache action. - - name: "Install dependencies" - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - uv pip install --system --upgrade --editable .[dev] + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: "Lint" - run: | - pre-commit run --all-files --hook-stage commit --verbose - pre-commit run --all-files --hook-stage push --verbose - pre-commit run --all-files --hook-stage manual --verbose + run: | + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage commit --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage push --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage manual --verbose - uses: pre-commit-ci/lite-action@v1.0.3 if: always() diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64521bb97..f073630b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,10 +27,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: "Calver calculate version" uses: StephaneBour/actions-calver@master @@ -73,12 +71,11 @@ jobs: - name: Build a binary wheel and a source tarball run: | - # Checkout the latest tag - the one we just created. git fetch --tags git checkout ${{ steps.tag_version.outputs.new_tag }} - python -m pip install build check-wheel-contents - python -m build --sdist --wheel --outdir dist/ . - check-wheel-contents dist/*.whl + uv run pip install build check-wheel-contents + uv run python -m build --sdist --wheel --outdir dist/ . + uv run check-wheel-contents dist/*.whl # We use PyPI trusted publishing rather than a PyPI API token. # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing. diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index 7dbd9914d..1d7b1ee88 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -31,16 +31,8 @@ jobs: # See https://github.com/codecov/codecov-action/issues/190. fetch-depth: 2 - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - # We do not use the cache action as uv is faster than the cache action. - - name: "Install dependencies" - run: | - curl -LsSf https://astral.sh/uv/install.sh | sh - uv pip install --system --upgrade --editable .[dev] + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: "Set secrets file" run: | @@ -48,7 +40,7 @@ jobs: - name: "Run tests" run: | - pytest \ + uv run --all-extras --python=${{ matrix.python-version }} pytest \ --skip-docker_build_tests \ --skip-docker_in_memory \ --skip-mock \ diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index f78ffde0a..fe3a08bcd 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -29,16 +29,8 @@ jobs: # See https://github.com/codecov/codecov-action/issues/190. fetch-depth: 2 - - name: "Set up Python" - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - # We do not use the cache action as uv is faster than the cache action. - - name: "Install dependencies" - run: | - irm https://astral.sh/uv/install.ps1 | iex - uv pip install --system --upgrade --editable .[dev] + - name: Install uv + uses: astral-sh/setup-uv@v3 - name: "Set secrets file" run: | @@ -48,7 +40,7 @@ jobs: run: | # We use pytest-xdist to make this run much faster. # The downside is that we cannot use -s / --capture=no. - pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . + uv run --all-extras --python=${{ matrix.python-version }} pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . - name: "Show coverage file" run: | From 0618e7b408a0c2d2f91b2f33b0c54b8401fa2a53 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 17:12:12 +0100 Subject: [PATCH 138/331] Fix indentation --- .github/workflows/lint.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3cc57dc62..6ec2d0347 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,10 +27,10 @@ jobs: uses: astral-sh/setup-uv@v3 - name: "Lint" - run: | - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage commit --verbose - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage push --verbose - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage manual --verbose + run: | + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage commit --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage push --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage manual --verbose - uses: pre-commit-ci/lite-action@v1.0.3 if: always() From 93c4d8397d868faf9548cff42f88535d216fa737 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 17:20:55 +0100 Subject: [PATCH 139/331] Move release dependencies to pyproject.toml --- .github/workflows/release.yml | 3 +-- pyproject.toml | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f073630b1..664ad749f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,8 +73,7 @@ jobs: run: | git fetch --tags git checkout ${{ steps.tag_version.outputs.new_tag }} - uv run pip install build check-wheel-contents - uv run python -m build --sdist --wheel --outdir dist/ . + uv run --extra=release python -m build --sdist --wheel --outdir dist/ . uv run check-wheel-contents dist/*.whl # We use PyPI trusted publishing rather than a PyPI API token. diff --git a/pyproject.toml b/pyproject.toml index 482915ace..e7c6a9c20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,6 +106,7 @@ optional-dependencies.dev = [ "vws-web-tools==2023.12.26", ] urls.Documentation = "https://vws-python-mock.readthedocs.io" +optional-dependencies.release = ["build", "check-wheel-contents"] urls.Source = "https://github.com/VWS-Python/vws-python-mock" [tool.setuptools] From 905a8b9939d60422aa08f41ca927f0a0d260e33e Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 6 Oct 2024 17:26:12 +0100 Subject: [PATCH 140/331] Ignore release dependency group in deptry --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e7c6a9c20..fee71f558 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -319,6 +319,7 @@ ignore = [ [tool.deptry] pep621_dev_dependency_groups = [ "dev", + "release", ] [tool.deptry.per_rule_ignores] From 93bec5933fcdeea83d809df107afd9c58a6184ae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sun, 6 Oct 2024 16:27:22 +0000 Subject: [PATCH 141/331] [pre-commit.ci lite] apply automatic fixes --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fee71f558..03196e3df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,8 +105,8 @@ optional-dependencies.dev = [ "vws-test-fixtures==2023.3.5", "vws-web-tools==2023.12.26", ] +optional-dependencies.release = [ "build", "check-wheel-contents" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" -optional-dependencies.release = ["build", "check-wheel-contents"] urls.Source = "https://github.com/VWS-Python/vws-python-mock" [tool.setuptools] From 11f23d58742c95e7cb5a16ccfc71dc591f927bfe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 05:55:01 +0000 Subject: [PATCH 142/331] Bump doccmd from 2024.9.27 to 2024.10.6 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.9.27 to 2024.10.6. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.09.27...2024.10.06) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6db1223e1..47fce66c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.9.27", + "doccmd==2024.10.6", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From b22c41587cf16abae5cfa492a36ea0d9180efc5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 05:55:06 +0000 Subject: [PATCH 143/331] Bump pre-commit from 3.8.0 to 4.0.0 Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 3.8.0 to 4.0.0. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v3.8.0...v4.0.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6db1223e1..03908cbd5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy==1.11.2", - "pre-commit==3.8.0", + "pre-commit==4.0.0", "pydocstyle==6.3", "pyenchant==3.2.2", "pylint==3.3.1", From 9f9036ace5ec1eb6518d2b8e237114af481c8e1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 05:55:22 +0000 Subject: [PATCH 144/331] Bump ruff from 0.6.8 to 0.6.9 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.8 to 0.6.9. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.8...0.6.9) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6db1223e1..0a4bb7337 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.8", + "ruff==0.6.9", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 2d8b828952c5198bc0206bb6c0c5376242a9bfb9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 05:55:48 +0000 Subject: [PATCH 145/331] Bump vws-web-tools from 2023.12.26 to 2024.10.6.1 Bumps [vws-web-tools](https://github.com/VWS-Python/vws-web-tools) from 2023.12.26 to 2024.10.6.1. - [Release notes](https://github.com/VWS-Python/vws-web-tools/releases) - [Commits](https://github.com/VWS-Python/vws-web-tools/compare/2023.12.26...2024.10.06.1) --- updated-dependencies: - dependency-name: vws-web-tools dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6db1223e1..e975e104f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,7 +103,7 @@ optional-dependencies.dev = [ "vulture==2.13", "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", - "vws-web-tools==2023.12.26", + "vws-web-tools==2024.10.6.1", ] optional-dependencies.release = [ "build", "check-wheel-contents" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" From b1ab604f40862c4ee28593cbefd969bcd3e1c64c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 10:02:04 +0100 Subject: [PATCH 146/331] Bump pyenchant to a macOS ARM compatible RC --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6db1223e1..ebbe92ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ optional-dependencies.dev = [ "mypy==1.11.2", "pre-commit==3.8.0", "pydocstyle==6.3", - "pyenchant==3.2.2", + "pyenchant==3.3.0rc1", "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", From 769fd62c6c9a866428470fd9ddc9ab298cd9155a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 10:38:23 +0100 Subject: [PATCH 147/331] Update pre-commit config --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d138318d3..4efdb9933 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: - id: custom-linters name: custom-linters entry: python -m pytest ci/test_custom_linters.py - stages: [push] + stages: [pre-push] language: system types_or: [yaml, python] pass_filenames: false @@ -68,7 +68,7 @@ repos: - id: mypy name: mypy - stages: [push] + stages: [pre-push] entry: python -m mypy . language: system types_or: [python, toml] @@ -76,21 +76,21 @@ repos: - id: mypy-docs name: mypy-docs - stages: [push] + stages: [pre-push] entry: doccmd --language=python --command="mypy" language: system types_or: [markdown, rst, python, toml] - id: check-manifest name: check-manifest - stages: [push] + stages: [pre-push] entry: python -m check_manifest . language: system pass_filenames: false - id: pyright name: pyright - stages: [push] + stages: [pre-push] entry: python -m pyright . language: system types_or: [python, toml] @@ -98,14 +98,14 @@ repos: - id: pyright-docs name: pyright-docs - stages: [push] + stages: [pre-push] entry: doccmd --language=python --command="pyright" language: system types_or: [markdown, rst, python, toml] - id: pyright-verifytypes name: pyright-verifytypes - stages: [push] + stages: [pre-push] entry: python -m pyright --verifytypes mock_vws language: system pass_filenames: false From 4b25dabf6d73e2b2b6cb698cc8b48b027aadcbf3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 10:40:57 +0100 Subject: [PATCH 148/331] Use new hook stage names --- .github/workflows/lint.yml | 4 ++-- docs/source/contributing.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6ec2d0347..f593e6f2f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,8 +28,8 @@ jobs: - name: "Lint" run: | - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage commit --verbose - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage push --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage pre-commit --verbose + uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage pre-push --verbose uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage manual --verbose - uses: pre-commit-ci/lite-action@v1.0.3 diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 2bea998bf..daa07ba76 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -40,8 +40,8 @@ Run lint tools either by committing, or with: .. code-block:: console - $ pre-commit run --all-files --hook-stage commit --verbose - $ pre-commit run --all-files --hook-stage push --verbose + $ pre-commit run --all-files --hook-stage pre-commit --verbose + $ pre-commit run --all-files --hook-stage pre-push --verbose $ pre-commit run --all-files --hook-stage manual --verbose .. _Homebrew: https://brew.sh From b1c8cd5f9ef54770e7e72c7689ae54f4c310bd9a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 10:57:15 +0100 Subject: [PATCH 149/331] Switch pre-commit to Python language --- .pre-commit-config.yaml | 58 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4efdb9933..3886472eb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,46 +31,46 @@ repos: name: custom-linters entry: python -m pytest ci/test_custom_linters.py stages: [pre-push] - language: system + language: python types_or: [yaml, python] pass_filenames: false - id: actionlint name: actionlint entry: actionlint - language: system + language: python pass_filenames: false types_or: [yaml] - id: shellcheck name: shellcheck entry: shellcheck --shell=bash --exclude=SC1017 - language: system + language: python types_or: [shell] - id: shellcheck-docs name: shellcheck-docs entry: doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" - language: system + language: python types_or: [markdown, rst] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 - language: system + language: python types_or: [shell] - id: shfmt-docs name: shfmt-docs entry: doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" - language: system + language: python types_or: [markdown, rst] - id: mypy name: mypy stages: [pre-push] entry: python -m mypy . - language: system + language: python types_or: [python, toml] pass_filenames: false @@ -78,21 +78,21 @@ repos: name: mypy-docs stages: [pre-push] entry: doccmd --language=python --command="mypy" - language: system + language: python types_or: [markdown, rst, python, toml] - id: check-manifest name: check-manifest stages: [pre-push] entry: python -m check_manifest . - language: system + language: python pass_filenames: false - id: pyright name: pyright stages: [pre-push] entry: python -m pyright . - language: system + language: python types_or: [python, toml] pass_filenames: false @@ -100,55 +100,55 @@ repos: name: pyright-docs stages: [pre-push] entry: doccmd --language=python --command="pyright" - language: system + language: python types_or: [markdown, rst, python, toml] - id: pyright-verifytypes name: pyright-verifytypes stages: [pre-push] entry: python -m pyright --verifytypes mock_vws - language: system + language: python pass_filenames: false types_or: [python] - id: vulture name: vulture entry: python -m vulture . - language: system + language: python types_or: [python] pass_filenames: false - id: vulture-docs name: vulture docs entry: doccmd --language=python --command="vulture" - language: system + language: python types_or: [python] pass_filenames: false - id: pyroma name: pyroma entry: python -m pyroma --min 10 . - language: system + language: python pass_filenames: false types_or: [toml] - id: deptry name: deptry entry: python -m deptry src/ - language: system + language: python pass_filenames: false - id: pylint name: pylint entry: python -m pylint *.py src/ tests/ docs/ ci/ admin/ - language: system + language: python stages: [manual] pass_filenames: false - id: pylint-docs name: pylint-docs entry: doccmd --language=python --command="pylint" - language: system + language: python stages: [manual] types_or: [markdown, rst, python, toml] @@ -166,57 +166,57 @@ repos: - id: ruff-check-fix name: Ruff check fix entry: python -m ruff check --fix - language: system + language: python types_or: [python] - id: ruff-check-fix-docs name: Ruff check fix docs entry: doccmd --language=python --command="ruff check --fix" - language: system + language: python types_or: [markdown, rst] - id: ruff-format-fix name: Ruff format entry: python -m ruff format - language: system + language: python types_or: [python] - id: ruff-format-fix-docs name: Ruff format docs entry: doccmd --language=python --no-pad-file --command="ruff format" - language: system + language: python types_or: [markdown, rst] - id: doc8 name: doc8 entry: python -m doc8 - language: system + language: python types_or: [rst] - id: interrogate name: interrogate entry: python -m interrogate - language: system + language: python types_or: [python] exclude_types: [executable] - id: interrogate-docs name: interrogate docs entry: doccmd --language=python --command="interrogate" - language: system + language: python types_or: [markdown, rst] - id: pyproject-fmt-fix name: pyproject-fmt entry: pyproject-fmt - language: system + language: python types_or: [toml] files: pyproject.toml - id: linkcheck name: linkcheck entry: make -C docs/ linkcheck SPHINXOPTS=-W - language: system + language: python types_or: [rst] stages: [manual] pass_filenames: false @@ -224,7 +224,7 @@ repos: - id: spelling name: spelling entry: make -C docs/ spelling SPHINXOPTS=-W - language: system + language: python types_or: [rst] stages: [manual] pass_filenames: false @@ -232,7 +232,7 @@ repos: - id: docs name: Build Documentation entry: make docs - language: system + language: python stages: [manual] pass_filenames: false From 4173f471420249c25886cc5d18d7cc5e8d9e4e79 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:13:55 +0100 Subject: [PATCH 150/331] Switch some hooks to use uv --- .pre-commit-config.yaml | 50 ++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3886472eb..c0d9c97f0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: hooks: - id: custom-linters name: custom-linters - entry: python -m pytest ci/test_custom_linters.py + entry: uv run --extra=dev -m pytest ci/test_custom_linters.py stages: [pre-push] language: python types_or: [yaml, python] @@ -44,13 +44,13 @@ repos: - id: shellcheck name: shellcheck - entry: shellcheck --shell=bash --exclude=SC1017 + entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 language: python types_or: [shell] - id: shellcheck-docs name: shellcheck-docs - entry: doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" + entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" language: python types_or: [markdown, rst] @@ -62,14 +62,14 @@ repos: - id: shfmt-docs name: shfmt-docs - entry: doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" + entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] - id: mypy name: mypy stages: [pre-push] - entry: python -m mypy . + entry: uv run --extra=dev -m mypy . language: python types_or: [python, toml] pass_filenames: false @@ -77,21 +77,21 @@ repos: - id: mypy-docs name: mypy-docs stages: [pre-push] - entry: doccmd --language=python --command="mypy" + entry: uv run --extra=dev doccmd --language=python --command="mypy" language: python types_or: [markdown, rst, python, toml] - id: check-manifest name: check-manifest stages: [pre-push] - entry: python -m check_manifest . + entry: uv run --extra=dev -m check_manifest . language: python pass_filenames: false - id: pyright name: pyright stages: [pre-push] - entry: python -m pyright . + entry: uv run --extra=dev -m pyright . language: python types_or: [python, toml] pass_filenames: false @@ -99,55 +99,55 @@ repos: - id: pyright-docs name: pyright-docs stages: [pre-push] - entry: doccmd --language=python --command="pyright" + entry: uv run --extra=dev doccmd --language=python --command="pyright" language: python types_or: [markdown, rst, python, toml] - id: pyright-verifytypes name: pyright-verifytypes stages: [pre-push] - entry: python -m pyright --verifytypes mock_vws + entry: uv run --extra=dev -m pyright --verifytypes mock_vws language: python pass_filenames: false types_or: [python] - id: vulture name: vulture - entry: python -m vulture . + entry: uv run --extra=dev -m vulture . language: python types_or: [python] pass_filenames: false - id: vulture-docs name: vulture docs - entry: doccmd --language=python --command="vulture" + entry: uv run --extra=dev doccmd --language=python --command="vulture" language: python types_or: [python] pass_filenames: false - id: pyroma name: pyroma - entry: python -m pyroma --min 10 . + entry: uv run --extra=dev -m pyroma --min 10 . language: python pass_filenames: false types_or: [toml] - id: deptry name: deptry - entry: python -m deptry src/ + entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - id: pylint name: pylint - entry: python -m pylint *.py src/ tests/ docs/ ci/ admin/ + entry: uv run --extra=dev -m pylint *.py src/ tests/ docs/ ci/ admin/ language: python stages: [manual] pass_filenames: false - id: pylint-docs name: pylint-docs - entry: doccmd --language=python --command="pylint" + entry: uv run --extra=dev doccmd --language=python --command="pylint" language: python stages: [manual] types_or: [markdown, rst, python, toml] @@ -165,50 +165,50 @@ repos: - id: ruff-check-fix name: Ruff check fix - entry: python -m ruff check --fix + entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] - id: ruff-check-fix-docs name: Ruff check fix docs - entry: doccmd --language=python --command="ruff check --fix" + entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] - id: ruff-format-fix name: Ruff format - entry: python -m ruff format + entry: uv run --extra=dev -m ruff format language: python types_or: [python] - id: ruff-format-fix-docs name: Ruff format docs - entry: doccmd --language=python --no-pad-file --command="ruff format" + entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff format" language: python types_or: [markdown, rst] - id: doc8 name: doc8 - entry: python -m doc8 + entry: uv run --extra=dev -m doc8 language: python types_or: [rst] - id: interrogate name: interrogate - entry: python -m interrogate + entry: uv run --extra=dev -m interrogate language: python types_or: [python] exclude_types: [executable] - id: interrogate-docs name: interrogate docs - entry: doccmd --language=python --command="interrogate" + entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] - id: pyproject-fmt-fix name: pyproject-fmt - entry: pyproject-fmt + entry: uv run --extra=dev pyproject-fmt language: python types_or: [toml] files: pyproject.toml @@ -231,7 +231,7 @@ repos: - id: docs name: Build Documentation - entry: make docs + entry: uv run --extra=dev sphinx-build -M clean docs/source/ docs/build/ -W && uv run --extra=dev sphinx-build -M html docs/source/ docs/build/ -W language: python stages: [manual] pass_filenames: false From 97619308535ae32718bd0e802894a912e2123a94 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:22:54 +0100 Subject: [PATCH 151/331] Simplify pre-commit docs setup --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c0d9c97f0..c15162a0c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -231,7 +231,7 @@ repos: - id: docs name: Build Documentation - entry: uv run --extra=dev sphinx-build -M clean docs/source/ docs/build/ -W && uv run --extra=dev sphinx-build -M html docs/source/ docs/build/ -W + entry: make docs language: python stages: [manual] pass_filenames: false From cafeda48d62b2b6145085b6f48973aa8755c4a13 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:25:55 +0100 Subject: [PATCH 152/331] Make it possible to create docs without activating virtualenv --- docs/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index ba501f6f5..7aba47eda 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -9,11 +9,11 @@ BUILDDIR = build # Put it first so that "make" without argument is like "make help". help: - @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @uv run --extra=dev $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile - @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @uv run --extra=dev $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) From dedf220404b2d6fd5df42cafc9ec61f29bdaf63d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:47:54 +0100 Subject: [PATCH 153/331] Add uv dependency in more places --- .pre-commit-config.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c15162a0c..502a50570 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,30 +41,35 @@ repos: language: python pass_filenames: false types_or: [yaml] + additional_dependencies: ["uv"] - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 language: python types_or: [shell] + additional_dependencies: ["uv"] - id: shellcheck-docs name: shellcheck-docs entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" language: python types_or: [markdown, rst] + additional_dependencies: ["uv"] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 language: python types_or: [shell] + additional_dependencies: ["uv"] - id: shfmt-docs name: shfmt-docs entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] + additional_dependencies: ["uv"] - id: mypy name: mypy @@ -110,6 +115,7 @@ repos: language: python pass_filenames: false types_or: [python] + additional_dependencies: ["uv"] - id: vulture name: vulture @@ -131,6 +137,7 @@ repos: language: python pass_filenames: false types_or: [toml] + additional_dependencies: ["uv"] - id: deptry name: deptry @@ -168,30 +175,35 @@ repos: entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] + additional_dependencies: ["uv"] - id: ruff-check-fix-docs name: Ruff check fix docs entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] + additional_dependencies: ["uv"] - id: ruff-format-fix name: Ruff format entry: uv run --extra=dev -m ruff format language: python types_or: [python] + additional_dependencies: ["uv"] - id: ruff-format-fix-docs name: Ruff format docs entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff format" language: python types_or: [markdown, rst] + additional_dependencies: ["uv"] - id: doc8 name: doc8 entry: uv run --extra=dev -m doc8 language: python types_or: [rst] + additional_dependencies: ["uv"] - id: interrogate name: interrogate @@ -205,6 +217,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] + additional_dependencies: ["uv"] - id: pyproject-fmt-fix name: pyproject-fmt From dd18d8e8d3a17932882494b0ec30e5c7ad912f53 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:49:50 +0100 Subject: [PATCH 154/331] Add uv dependency in more places --- .pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 502a50570..e3d17e1a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,6 +34,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false + additional_dependencies: ["uv"] - id: actionlint name: actionlint @@ -78,6 +79,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false + additional_dependencies: ["uv"] - id: mypy-docs name: mypy-docs @@ -92,6 +94,7 @@ repos: entry: uv run --extra=dev -m check_manifest . language: python pass_filenames: false + additional_dependencies: ["uv"] - id: pyright name: pyright @@ -100,6 +103,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false + additional_dependencies: ["uv"] - id: pyright-docs name: pyright-docs @@ -123,6 +127,7 @@ repos: language: python types_or: [python] pass_filenames: false + additional_dependencies: ["uv"] - id: vulture-docs name: vulture docs @@ -130,6 +135,7 @@ repos: language: python types_or: [python] pass_filenames: false + additional_dependencies: ["uv"] - id: pyroma name: pyroma @@ -144,6 +150,7 @@ repos: entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false + additional_dependencies: ["uv"] - id: pylint name: pylint @@ -151,6 +158,7 @@ repos: language: python stages: [manual] pass_filenames: false + additional_dependencies: ["uv"] - id: pylint-docs name: pylint-docs @@ -233,6 +241,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false + additional_dependencies: ["uv"] - id: spelling name: spelling @@ -241,6 +250,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false + additional_dependencies: ["uv"] - id: docs name: Build Documentation From 5a68344d1ac9b79c6140b14abb306c9ef1076bb5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:51:25 +0100 Subject: [PATCH 155/331] Add uv dependency in more places --- .pre-commit-config.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e3d17e1a5..0240711e5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,7 +34,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: actionlint name: actionlint @@ -79,7 +79,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: mypy-docs name: mypy-docs @@ -94,7 +94,7 @@ repos: entry: uv run --extra=dev -m check_manifest . language: python pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: pyright name: pyright @@ -103,7 +103,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: pyright-docs name: pyright-docs @@ -127,7 +127,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: vulture-docs name: vulture docs @@ -135,7 +135,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: pyroma name: pyroma @@ -150,7 +150,7 @@ repos: entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: pylint name: pylint @@ -158,7 +158,7 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: pylint-docs name: pylint-docs @@ -241,7 +241,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: spelling name: spelling @@ -250,7 +250,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: ["uv"] - id: docs name: Build Documentation From 16f7e00027170288985f93b65c6f2ebcee508e3c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 11:54:40 +0100 Subject: [PATCH 156/331] Add uv dependency in more places --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0240711e5..63e29488a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -258,6 +258,7 @@ repos: language: python stages: [manual] pass_filenames: false + additional_dependencies: ["uv"] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. From 40ba3dc81df6a76570c1322f4dc47fa4ca0730f3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 7 Oct 2024 13:19:10 +0100 Subject: [PATCH 157/331] Use Sphinx feature to simplify setting copyright --- docs/source/conf.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 7819a48b7..a48ab8ac3 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,7 +3,6 @@ Configuration for Sphinx. """ -import datetime import importlib.metadata from packaging.specifiers import SpecifierSet @@ -28,8 +27,7 @@ source_suffix = ".rst" master_doc = "index" -year = datetime.datetime.now(tz=datetime.UTC).year -project_copyright = f"{year}, {author}" +project_copyright = f"%Y, {author}" # Exclude the prompt from copied code with sphinx_copybutton. # https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies. From d57586d409e126b2cf4bae35e0887fb8a5c5918d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 02:02:20 +0100 Subject: [PATCH 158/331] Pin build and check-wheel-contents --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1dc1f0226..c0711f7dc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,7 +105,7 @@ optional-dependencies.dev = [ "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", ] -optional-dependencies.release = [ "build", "check-wheel-contents" ] +optional-dependencies.release = [ "build==1.2.2.post1", "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" urls.Source = "https://github.com/VWS-Python/vws-python-mock" From 1b22dea6c011eeabaf743835b259844fb019ff0d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 02:55:28 +0100 Subject: [PATCH 159/331] Use uv instead of 'build' for building --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 664ad749f..2d835862e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -73,8 +73,8 @@ jobs: run: | git fetch --tags git checkout ${{ steps.tag_version.outputs.new_tag }} - uv run --extra=release python -m build --sdist --wheel --outdir dist/ . - uv run check-wheel-contents dist/*.whl + uv build --sdist --wheel --out-dir dist/ + uv run --extra=release check-wheel-contents dist/*.whl # We use PyPI trusted publishing rather than a PyPI API token. # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing. From 24e4d5b91176cf3c225a72e1bcf14a88e200e09f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 02:56:52 +0100 Subject: [PATCH 160/331] Use uv instead of 'build' for building --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c0711f7dc..7d55ba536 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,7 +105,7 @@ optional-dependencies.dev = [ "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", ] -optional-dependencies.release = [ "build==1.2.2.post1", "check-wheel-contents==0.6.0" ] +optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" urls.Source = "https://github.com/VWS-Python/vws-python-mock" From 8246a1ac7bcbc6d766f84dd54e90ba962a0ff063 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 04:12:53 +0100 Subject: [PATCH 161/331] Use environment variables to remove duplication in uv commands --- .github/workflows/ci.yml | 4 +++- .github/workflows/lint.yml | 8 +++++--- .github/workflows/skip-tests.yml | 4 +++- .github/workflows/windows-ci.yml | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce834f162..3393483b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -155,7 +155,7 @@ jobs: - name: "Run tests" run: | - uv run --all-extras --python=${{ matrix.python-version }} pytest \ + uv run --extra=dev pytest \ -s \ -vvv \ --showlocals \ @@ -164,6 +164,8 @@ jobs: --cov=tests/ \ --cov-report=xml \ ${{ matrix.ci_pattern }} + env: + UV_PYTHON: ${{ matrix.python-version }} - name: "Show coverage file" run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f593e6f2f..4fa4376f9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,9 +28,11 @@ jobs: - name: "Lint" run: | - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage pre-commit --verbose - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage pre-push --verbose - uv run --all-extras --python=${{ matrix.python-version }} pre-commit run --all-files --hook-stage manual --verbose + uv run --extra=dev pre-commit run --all-files --hook-stage pre-commit --verbose + uv run --extra=dev pre-commit run --all-files --hook-stage pre-push --verbose + uv run --extra=dev pre-commit run --all-files --hook-stage manual --verbose + env: + UV_PYTHON: ${{ matrix.python-version }} - uses: pre-commit-ci/lite-action@v1.0.3 if: always() diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index 1d7b1ee88..b51859b9c 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -40,7 +40,7 @@ jobs: - name: "Run tests" run: | - uv run --all-extras --python=${{ matrix.python-version }} pytest \ + uv run --extra=dev pytest \ --skip-docker_build_tests \ --skip-docker_in_memory \ --skip-mock \ @@ -52,6 +52,8 @@ jobs: --cov=tests/ \ --cov-report=xml \ . + env: + UV_PYTHON: ${{ matrix.python-version }} - name: "Show coverage file" run: | diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index fe3a08bcd..f8fb57aca 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -40,7 +40,9 @@ jobs: run: | # We use pytest-xdist to make this run much faster. # The downside is that we cannot use -s / --capture=no. - uv run --all-extras --python=${{ matrix.python-version }} pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . + uv run --extra=dev pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . + env: + UV_PYTHON: ${{ matrix.python-version }} - name: "Show coverage file" run: | From 93dbac8bd5e7cfb0e5a0766e5e4db467ab19db33 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 04:23:59 +0100 Subject: [PATCH 162/331] Update release process to support >= 10 releases in a day --- .github/workflows/release.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2d835862e..84ff080cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,11 +39,17 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get the changelog underline + id: changelog_underline + run: | + underline="$(echo "${{ steps.calver.outputs.release }}" | tr -c '\n' '-')" + echo "underline=${underline}" >> "$GITHUB_OUTPUT" + - name: "Update changelog" uses: jacobtomlinson/gha-find-replace@v3 with: find: "Next\n----" - replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n------------" + replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n${{ steps.changelog_underline.outputs.underline }}" include: "CHANGELOG.rst" regex: false From 65499077ba085821681ac35536df97118be270d6 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 04:43:46 +0100 Subject: [PATCH 163/331] Fix running actionlint without activated environment --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63e29488a..e1a4e3d81 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,7 +38,7 @@ repos: - id: actionlint name: actionlint - entry: actionlint + entry: uv run --extra=dev actionlint language: python pass_filenames: false types_or: [yaml] From dc935c9af0e40cee8014c14962bb92513da9055a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 05:00:42 +0100 Subject: [PATCH 164/331] Format some yaml files --- .github/dependabot.yml | 19 +- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 2 +- .pre-commit-config.yaml | 509 +++++++++++++++-------------- 4 files changed, 267 insertions(+), 265 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 79d0e38c9..64507e260 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,11 +1,12 @@ +--- version: 2 updates: -- package-ecosystem: pip - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 10 -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: daily + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 154816b9e..06a908cbb 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -45,5 +45,5 @@ jobs: file: src/mock_vws/_flask_server/Dockerfile push: false target: ${{ matrix.image.name }} - tags: | + tags: |- adamtheturtle/vuforia-${{ matrix.image.name }}-mock:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84ff080cc..92ec54451 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -130,6 +130,6 @@ jobs: platforms: linux/amd64,linux/arm64 push: true target: vwq - tags: | + tags: |- adamtheturtle/vuforia-vwq-mock:latest adamtheturtle/vuforia-vwq-mock:${{ steps.calver.outputs.release }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e1a4e3d81..201583468 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,294 +1,295 @@ +--- fail_fast: true # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_install_hook_types: [pre-commit, pre-push, commit-msg] repos: -- repo: meta - hooks: - - id: check-useless-excludes -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 - hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-executables-have-shebangs - - id: check-merge-conflict - - id: check-shebang-scripts-are-executable - - id: check-symlinks - - id: check-json - - id: check-toml - - id: check-vcs-permalinks - - id: check-yaml - - id: end-of-file-fixer - - id: file-contents-sorter - files: spelling_private_dict\.txt$ - - id: trailing-whitespace - exclude: ^src/mock_vws/resources/ -- repo: local - hooks: - - id: custom-linters - name: custom-linters - entry: uv run --extra=dev -m pytest ci/test_custom_linters.py - stages: [pre-push] - language: python - types_or: [yaml, python] - pass_filenames: false - additional_dependencies: ["uv"] + - repo: meta + hooks: + - id: check-useless-excludes + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: check-json + - id: check-toml + - id: check-vcs-permalinks + - id: check-yaml + - id: end-of-file-fixer + - id: file-contents-sorter + files: spelling_private_dict\.txt$ + - id: trailing-whitespace + exclude: ^src/mock_vws/resources/ + - repo: local + hooks: + - id: custom-linters + name: custom-linters + entry: uv run --extra=dev -m pytest ci/test_custom_linters.py + stages: [pre-push] + language: python + types_or: [yaml, python] + pass_filenames: false + additional_dependencies: ["uv"] - - id: actionlint - name: actionlint - entry: uv run --extra=dev actionlint - language: python - pass_filenames: false - types_or: [yaml] - additional_dependencies: ["uv"] + - id: actionlint + name: actionlint + entry: uv run --extra=dev actionlint + language: python + pass_filenames: false + types_or: [yaml] + additional_dependencies: ["uv"] - - id: shellcheck - name: shellcheck - entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 - language: python - types_or: [shell] - additional_dependencies: ["uv"] + - id: shellcheck + name: shellcheck + entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 + language: python + types_or: [shell] + additional_dependencies: ["uv"] - - id: shellcheck-docs - name: shellcheck-docs - entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" - language: python - types_or: [markdown, rst] - additional_dependencies: ["uv"] + - id: shellcheck-docs + name: shellcheck-docs + entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" + language: python + types_or: [markdown, rst] + additional_dependencies: ["uv"] - - id: shfmt - name: shfmt - entry: shfmt --write --space-redirects --indent=4 - language: python - types_or: [shell] - additional_dependencies: ["uv"] + - id: shfmt + name: shfmt + entry: shfmt --write --space-redirects --indent=4 + language: python + types_or: [shell] + additional_dependencies: ["uv"] - - id: shfmt-docs - name: shfmt-docs - entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" - language: python - types_or: [markdown, rst] - additional_dependencies: ["uv"] + - id: shfmt-docs + name: shfmt-docs + entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" + language: python + types_or: [markdown, rst] + additional_dependencies: ["uv"] - - id: mypy - name: mypy - stages: [pre-push] - entry: uv run --extra=dev -m mypy . - language: python - types_or: [python, toml] - pass_filenames: false - additional_dependencies: ["uv"] + - id: mypy + name: mypy + stages: [pre-push] + entry: uv run --extra=dev -m mypy . + language: python + types_or: [python, toml] + pass_filenames: false + additional_dependencies: ["uv"] - - id: mypy-docs - name: mypy-docs - stages: [pre-push] - entry: uv run --extra=dev doccmd --language=python --command="mypy" - language: python - types_or: [markdown, rst, python, toml] + - id: mypy-docs + name: mypy-docs + stages: [pre-push] + entry: uv run --extra=dev doccmd --language=python --command="mypy" + language: python + types_or: [markdown, rst, python, toml] - - id: check-manifest - name: check-manifest - stages: [pre-push] - entry: uv run --extra=dev -m check_manifest . - language: python - pass_filenames: false - additional_dependencies: ["uv"] + - id: check-manifest + name: check-manifest + stages: [pre-push] + entry: uv run --extra=dev -m check_manifest . + language: python + pass_filenames: false + additional_dependencies: ["uv"] - - id: pyright - name: pyright - stages: [pre-push] - entry: uv run --extra=dev -m pyright . - language: python - types_or: [python, toml] - pass_filenames: false - additional_dependencies: ["uv"] + - id: pyright + name: pyright + stages: [pre-push] + entry: uv run --extra=dev -m pyright . + language: python + types_or: [python, toml] + pass_filenames: false + additional_dependencies: ["uv"] - - id: pyright-docs - name: pyright-docs - stages: [pre-push] - entry: uv run --extra=dev doccmd --language=python --command="pyright" - language: python - types_or: [markdown, rst, python, toml] + - id: pyright-docs + name: pyright-docs + stages: [pre-push] + entry: uv run --extra=dev doccmd --language=python --command="pyright" + language: python + types_or: [markdown, rst, python, toml] - - id: pyright-verifytypes - name: pyright-verifytypes - stages: [pre-push] - entry: uv run --extra=dev -m pyright --verifytypes mock_vws - language: python - pass_filenames: false - types_or: [python] - additional_dependencies: ["uv"] + - id: pyright-verifytypes + name: pyright-verifytypes + stages: [pre-push] + entry: uv run --extra=dev -m pyright --verifytypes mock_vws + language: python + pass_filenames: false + types_or: [python] + additional_dependencies: ["uv"] - - id: vulture - name: vulture - entry: uv run --extra=dev -m vulture . - language: python - types_or: [python] - pass_filenames: false - additional_dependencies: ["uv"] + - id: vulture + name: vulture + entry: uv run --extra=dev -m vulture . + language: python + types_or: [python] + pass_filenames: false + additional_dependencies: ["uv"] - - id: vulture-docs - name: vulture docs - entry: uv run --extra=dev doccmd --language=python --command="vulture" - language: python - types_or: [python] - pass_filenames: false - additional_dependencies: ["uv"] + - id: vulture-docs + name: vulture docs + entry: uv run --extra=dev doccmd --language=python --command="vulture" + language: python + types_or: [python] + pass_filenames: false + additional_dependencies: ["uv"] - - id: pyroma - name: pyroma - entry: uv run --extra=dev -m pyroma --min 10 . - language: python - pass_filenames: false - types_or: [toml] - additional_dependencies: ["uv"] + - id: pyroma + name: pyroma + entry: uv run --extra=dev -m pyroma --min 10 . + language: python + pass_filenames: false + types_or: [toml] + additional_dependencies: ["uv"] - - id: deptry - name: deptry - entry: uv run --extra=dev -m deptry src/ - language: python - pass_filenames: false - additional_dependencies: ["uv"] + - id: deptry + name: deptry + entry: uv run --extra=dev -m deptry src/ + language: python + pass_filenames: false + additional_dependencies: ["uv"] - - id: pylint - name: pylint - entry: uv run --extra=dev -m pylint *.py src/ tests/ docs/ ci/ admin/ - language: python - stages: [manual] - pass_filenames: false - additional_dependencies: ["uv"] + - id: pylint + name: pylint + entry: uv run --extra=dev -m pylint *.py src/ tests/ docs/ ci/ admin/ + language: python + stages: [manual] + pass_filenames: false + additional_dependencies: ["uv"] - - id: pylint-docs - name: pylint-docs - entry: uv run --extra=dev doccmd --language=python --command="pylint" - language: python - stages: [manual] - types_or: [markdown, rst, python, toml] + - id: pylint-docs + name: pylint-docs + entry: uv run --extra=dev doccmd --language=python --command="pylint" + language: python + stages: [manual] + types_or: [markdown, rst, python, toml] - - id: hadolint-docker - name: Lint Dockerfiles - description: Runs hadolint Docker image to lint Dockerfiles - language: docker_image - types_or: [dockerfile] - stages: [manual] # Requires Docker to be running - # We choose not to use a Python wrapper or alternative to hadolint as none - # appear to be well maintained, and they require more setup than we would - # want. - entry: ghcr.io/hadolint/hadolint hadolint + - id: hadolint-docker + name: Lint Dockerfiles + description: Runs hadolint Docker image to lint Dockerfiles + language: docker_image + types_or: [dockerfile] + stages: [manual] # Requires Docker to be running + # We choose not to use a Python wrapper or alternative to hadolint as none + # appear to be well maintained, and they require more setup than we would + # want. + entry: ghcr.io/hadolint/hadolint hadolint - - id: ruff-check-fix - name: Ruff check fix - entry: uv run --extra=dev -m ruff check --fix - language: python - types_or: [python] - additional_dependencies: ["uv"] + - id: ruff-check-fix + name: Ruff check fix + entry: uv run --extra=dev -m ruff check --fix + language: python + types_or: [python] + additional_dependencies: ["uv"] - - id: ruff-check-fix-docs - name: Ruff check fix docs - entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" - language: python - types_or: [markdown, rst] - additional_dependencies: ["uv"] + - id: ruff-check-fix-docs + name: Ruff check fix docs + entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" + language: python + types_or: [markdown, rst] + additional_dependencies: ["uv"] - - id: ruff-format-fix - name: Ruff format - entry: uv run --extra=dev -m ruff format - language: python - types_or: [python] - additional_dependencies: ["uv"] + - id: ruff-format-fix + name: Ruff format + entry: uv run --extra=dev -m ruff format + language: python + types_or: [python] + additional_dependencies: ["uv"] - - id: ruff-format-fix-docs - name: Ruff format docs - entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff format" - language: python - types_or: [markdown, rst] - additional_dependencies: ["uv"] + - id: ruff-format-fix-docs + name: Ruff format docs + entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff format" + language: python + types_or: [markdown, rst] + additional_dependencies: ["uv"] - - id: doc8 - name: doc8 - entry: uv run --extra=dev -m doc8 - language: python - types_or: [rst] - additional_dependencies: ["uv"] + - id: doc8 + name: doc8 + entry: uv run --extra=dev -m doc8 + language: python + types_or: [rst] + additional_dependencies: ["uv"] - - id: interrogate - name: interrogate - entry: uv run --extra=dev -m interrogate - language: python - types_or: [python] - exclude_types: [executable] + - id: interrogate + name: interrogate + entry: uv run --extra=dev -m interrogate + language: python + types_or: [python] + exclude_types: [executable] - - id: interrogate-docs - name: interrogate docs - entry: uv run --extra=dev doccmd --language=python --command="interrogate" - language: python - types_or: [markdown, rst] - additional_dependencies: ["uv"] + - id: interrogate-docs + name: interrogate docs + entry: uv run --extra=dev doccmd --language=python --command="interrogate" + language: python + types_or: [markdown, rst] + additional_dependencies: ["uv"] - - id: pyproject-fmt-fix - name: pyproject-fmt - entry: uv run --extra=dev pyproject-fmt - language: python - types_or: [toml] - files: pyproject.toml + - id: pyproject-fmt-fix + name: pyproject-fmt + entry: uv run --extra=dev pyproject-fmt + language: python + types_or: [toml] + files: pyproject.toml - - id: linkcheck - name: linkcheck - entry: make -C docs/ linkcheck SPHINXOPTS=-W - language: python - types_or: [rst] - stages: [manual] - pass_filenames: false - additional_dependencies: ["uv"] + - id: linkcheck + name: linkcheck + entry: make -C docs/ linkcheck SPHINXOPTS=-W + language: python + types_or: [rst] + stages: [manual] + pass_filenames: false + additional_dependencies: ["uv"] - - id: spelling - name: spelling - entry: make -C docs/ spelling SPHINXOPTS=-W - language: python - types_or: [rst] - stages: [manual] - pass_filenames: false - additional_dependencies: ["uv"] + - id: spelling + name: spelling + entry: make -C docs/ spelling SPHINXOPTS=-W + language: python + types_or: [rst] + stages: [manual] + pass_filenames: false + additional_dependencies: ["uv"] - - id: docs - name: Build Documentation - entry: make docs - language: python - stages: [manual] - pass_filenames: false - additional_dependencies: ["uv"] + - id: docs + name: Build Documentation + entry: make docs + language: python + stages: [manual] + pass_filenames: false + additional_dependencies: ["uv"] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. ci: skip: - - actionlint - - check-manifest - - custom-linters - - deptry - - doc8 - - docs - - interrogate - - interrogate-docs - - linkcheck - - mypy - - mypy-docs - - pylint - - pyproject-fmt-fix - - pyright - - pyright-docs - - pyright-verifytypes - - pyroma - - ruff-check-fix - - ruff-check-fix-docs - - ruff-format-fix - - ruff-format-fix-docs - - shellcheck - - shellcheck-docs - - shfmt - - shfmt-docs - - spelling - - vulture - - vulture-docs + - actionlint + - check-manifest + - custom-linters + - deptry + - doc8 + - docs + - interrogate + - interrogate-docs + - linkcheck + - mypy + - mypy-docs + - pylint + - pyproject-fmt-fix + - pyright + - pyright-docs + - pyright-verifytypes + - pyroma + - ruff-check-fix + - ruff-check-fix-docs + - ruff-format-fix + - ruff-format-fix-docs + - shellcheck + - shellcheck-docs + - shfmt + - shfmt-docs + - spelling + - vulture + - vulture-docs From 6fd24e2bbcd4da10a6ef9fc1dfd1bcc17da70769 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 05:13:23 +0000 Subject: [PATCH 165/331] Bump doccmd from 2024.10.6 to 2024.10.8.12 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.10.6 to 2024.10.8.12. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.10.06...2024.10.08.12) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7d55ba536..7eac46740 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,7 +59,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.6", + "doccmd==2024.10.8.12", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", From 8d76e5dac1ccd1f6e9deda617dca318b8b8276e4 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:22:15 +0100 Subject: [PATCH 166/331] Add more pre-commit hooks --- .checkmake-config.ini | 2 ++ .pre-commit-config.yaml | 9 +++++++++ .yamlfmt | 5 +++++ pyproject.toml | 1 + 4 files changed, 17 insertions(+) create mode 100644 .checkmake-config.ini create mode 100644 .yamlfmt diff --git a/.checkmake-config.ini b/.checkmake-config.ini new file mode 100644 index 000000000..f2ac3c91b --- /dev/null +++ b/.checkmake-config.ini @@ -0,0 +1,2 @@ +[minphony] +disabled = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 201583468..dcd36c648 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,6 +45,13 @@ repos: types_or: [yaml] additional_dependencies: ["uv"] + - id: docformatter + name: docformatter + entry: uv run --extra=dev -m docformatter + language: python + types_or: [python] + additional_dependencies: ["uv"] + - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 @@ -286,7 +293,9 @@ ci: - ruff-check-fix-docs - ruff-format-fix - ruff-format-fix-docs + - docformatter - shellcheck + - docformatter - shellcheck-docs - shfmt - shfmt-docs diff --git a/.yamlfmt b/.yamlfmt new file mode 100644 index 000000000..fbb6dd434 --- /dev/null +++ b/.yamlfmt @@ -0,0 +1,5 @@ +formatter: + include_document_start: true + retain_line_breaks_single: true + trim_trailing_whitespace: true + end_of_file_newline: true diff --git a/pyproject.toml b/pyproject.toml index 7eac46740..713b7b818 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,6 +104,7 @@ optional-dependencies.dev = [ "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", + "docformatter==1.7.5", ] optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" From 93c70f32c91fa1d363c02cdca49680aaaf3a1fda Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:28:00 +0100 Subject: [PATCH 167/331] Configure docformatter --- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dcd36c648..8a4770efc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,9 +45,9 @@ repos: types_or: [yaml] additional_dependencies: ["uv"] - - id: docformatter - name: docformatter - entry: uv run --extra=dev -m docformatter + - id: docformatter --in-place + name: docformatter --in-place + entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] additional_dependencies: ["uv"] @@ -293,9 +293,9 @@ ci: - ruff-check-fix-docs - ruff-format-fix - ruff-format-fix-docs - - docformatter + - docformatter --in-place - shellcheck - - docformatter + - docformatter --in-place - shellcheck-docs - shfmt - shfmt-docs diff --git a/pyproject.toml b/pyproject.toml index 713b7b818..b3d228714 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ optional-dependencies.dev = [ "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", - "docformatter==1.7.5", + "docformatter --in-place==1.7.5", ] optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" @@ -291,6 +291,9 @@ spelling-private-dict-file = 'spelling_private_dict.txt' # --spelling-private-dict-file option instead of raising a message. spelling-store-unknown-words = 'no' +[tool.docformatter] +make-summary-multi-line = true + [tool.check-manifest] ignore = [ From e28dab6b8e94f6f4172addd76e8ef2e8f183ef24 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:29:48 +0100 Subject: [PATCH 168/331] Update pre-commit.ci ignore list --- .pre-commit-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a4770efc..b56930961 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -293,9 +293,8 @@ ci: - ruff-check-fix-docs - ruff-format-fix - ruff-format-fix-docs - - docformatter --in-place + - docformatter - shellcheck - - docformatter --in-place - shellcheck-docs - shfmt - shfmt-docs From e55c2360631a271eb8f1087f34816b51db19432a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:31:32 +0100 Subject: [PATCH 169/331] Add more hooks --- .pre-commit-config.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b56930961..10dfec06a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,6 +26,22 @@ repos: files: spelling_private_dict\.txt$ - id: trailing-whitespace exclude: ^src/mock_vws/resources/ + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: rst-directive-colons + - id: rst-inline-touching-normal + - id: text-unicode-replacement-char + - id: rst-backticks + - repo: https://github.com/mrtazz/checkmake.git + rev: 0.2.2 + hooks: + - id: checkmake + args: ["--config", ".checkmake-config.ini"] + - repo: https://github.com/google/yamlfmt + rev: v0.13.0 + hooks: + - id: yamlfmt - repo: local hooks: - id: custom-linters From 6ae442b65112b2c56d37c993949ceb5403c92022 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:32:49 +0100 Subject: [PATCH 170/331] Fix hook name --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10dfec06a..6d7e19326 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,8 +61,8 @@ repos: types_or: [yaml] additional_dependencies: ["uv"] - - id: docformatter --in-place - name: docformatter --in-place + - id: docformatter + name: docformatter entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] From d6e87975c1d4b8b49e080955623ed1b0a2ab5063 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:34:21 +0100 Subject: [PATCH 171/331] Fix dependency name --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b3d228714..1dd1aeb76 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -104,7 +104,7 @@ optional-dependencies.dev = [ "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", - "docformatter --in-place==1.7.5", + "docformatter==1.7.5", ] optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" From fe40b6f76a8536c32e49faf57a9ff7e5839f034c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:34:27 +0000 Subject: [PATCH 172/331] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- codecov.yaml | 1 + readthedocs.yaml | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/codecov.yaml b/codecov.yaml index e49034f39..5c35baac9 100644 --- a/codecov.yaml +++ b/codecov.yaml @@ -1,3 +1,4 @@ +--- coverage: status: patch: diff --git a/readthedocs.yaml b/readthedocs.yaml index d3bd4fd21..4b8a4eb2b 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -1,3 +1,4 @@ +--- version: 2 build: @@ -7,10 +8,10 @@ build: python: install: - - method: pip - path: . - extra_requirements: - - dev + - method: pip + path: . + extra_requirements: + - dev sphinx: builder: html From 45432653170451bd86cf293ae8b73a89da9d72c3 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 21:46:44 +0100 Subject: [PATCH 173/331] Do not expect new config files in manifest --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 1dd1aeb76..687d270ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -297,6 +297,8 @@ make-summary-multi-line = true [tool.check-manifest] ignore = [ + ".checkmake-config.ini", + ".yamlfmt", "*.enc", "admin/**", "readthedocs.yaml", From 65fd0bb15c65f2c45ef62ba44224ea21bccf41bd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 20:50:14 +0000 Subject: [PATCH 174/331] [pre-commit.ci lite] apply automatic fixes --- admin/__init__.py | 4 +- admin/create_secrets_files.py | 8 +-- ci/__init__.py | 4 +- ci/test_custom_linters.py | 3 +- conftest.py | 7 +- docs/source/__init__.py | 4 +- src/mock_vws/_base64_decoding.py | 3 +- src/mock_vws/_constants.py | 6 +- src/mock_vws/_database_matchers.py | 6 +- src/mock_vws/_flask_server/__init__.py | 4 +- src/mock_vws/_flask_server/target_manager.py | 64 ++++++++++--------- src/mock_vws/_flask_server/vwq.py | 22 ++++--- src/mock_vws/_flask_server/vws.py | 46 ++++++------- src/mock_vws/_mock_common.py | 3 +- src/mock_vws/_query_validators/__init__.py | 3 +- .../accept_header_validators.py | 3 +- .../_query_validators/auth_validators.py | 16 ++--- .../content_length_validators.py | 9 +-- .../content_type_validators.py | 3 +- .../_query_validators/date_validators.py | 16 ++--- src/mock_vws/_query_validators/exceptions.py | 4 +- .../_query_validators/fields_validators.py | 3 +- .../_query_validators/image_validators.py | 15 ++--- .../include_target_data_validators.py | 5 +- .../num_results_validators.py | 5 +- .../project_state_validators.py | 3 +- .../_requests_mock_server/decorators.py | 16 ++--- .../mock_web_query_api.py | 12 ++-- .../mock_web_services_api.py | 36 ++++------- src/mock_vws/_services_validators/__init__.py | 3 +- .../active_flag_validators.py | 3 +- .../_services_validators/auth_validators.py | 12 ++-- .../content_length_validators.py | 9 +-- .../content_type_validators.py | 4 +- .../_services_validators/date_validators.py | 9 +-- .../_services_validators/exceptions.py | 8 +-- .../_services_validators/image_validators.py | 18 ++---- .../_services_validators/json_validators.py | 8 +-- .../_services_validators/key_validators.py | 6 +- .../metadata_validators.py | 9 +-- .../_services_validators/name_validators.py | 15 ++--- .../project_state_validators.py | 3 +- .../_services_validators/target_validators.py | 5 +- .../_services_validators/width_validators.py | 3 +- src/mock_vws/database.py | 3 +- src/mock_vws/image_matchers.py | 25 +++++--- src/mock_vws/target.py | 20 +++--- src/mock_vws/target_manager.py | 6 +- src/mock_vws/target_raters.py | 35 +++++----- tests/__init__.py | 4 +- tests/conftest.py | 7 +- tests/mock_vws/fixtures/credentials.py | 8 ++- tests/mock_vws/fixtures/prepared_requests.py | 10 +-- tests/mock_vws/fixtures/vuforia_backends.py | 29 +++++---- tests/mock_vws/test_add_target.py | 22 +++---- tests/mock_vws/test_authorization_header.py | 10 +-- tests/mock_vws/test_content_length.py | 3 +- tests/mock_vws/test_database_summary.py | 27 ++++---- tests/mock_vws/test_date_header.py | 47 ++++++-------- tests/mock_vws/test_delete_target.py | 3 +- tests/mock_vws/test_docker.py | 3 +- tests/mock_vws/test_flask_app_usage.py | 44 +++++++++---- tests/mock_vws/test_get_duplicates.py | 7 +- tests/mock_vws/test_get_target.py | 13 ++-- tests/mock_vws/test_invalid_given_id.py | 8 +-- tests/mock_vws/test_query.py | 48 ++++++-------- tests/mock_vws/test_requests_mock_usage.py | 43 +++++++++---- tests/mock_vws/test_target_summary.py | 5 +- tests/mock_vws/test_update_target.py | 32 ++++------ tests/mock_vws/utils/__init__.py | 6 +- tests/mock_vws/utils/assertions.py | 23 +++---- tests/mock_vws/utils/retries.py | 4 +- tests/mock_vws/utils/too_many_requests.py | 5 +- 73 files changed, 449 insertions(+), 499 deletions(-) diff --git a/admin/__init__.py b/admin/__init__.py index 1a76e35be..6a8f8f73b 100644 --- a/admin/__init__.py +++ b/admin/__init__.py @@ -1 +1,3 @@ -"""Admin tools.""" +""" +Admin tools. +""" diff --git a/admin/create_secrets_files.py b/admin/create_secrets_files.py index a236fe2f9..58aca18fe 100644 --- a/admin/create_secrets_files.py +++ b/admin/create_secrets_files.py @@ -1,5 +1,4 @@ -""" -Create licenses and target databases for the tests to run against. +"""Create licenses and target databases for the tests to run against. Usage: @@ -11,7 +10,6 @@ $ export EXISTING_SECRETS_FILE=/existing/file/with/inactive/db/creds # You may have to run this a few times, but it is idempotent. $ python admin/create_secrets_files.py - """ import datetime @@ -27,7 +25,9 @@ def main() -> None: - """Create secrets files.""" + """ + Create secrets files. + """ email_address = os.environ["VWS_EMAIL_ADDRESS"] password = os.environ["VWS_PASSWORD"] new_secrets_dir = Path(os.environ["NEW_SECRETS_DIR"]).expanduser() diff --git a/ci/__init__.py b/ci/__init__.py index 4b867b2bd..fdd0b5af8 100644 --- a/ci/__init__.py +++ b/ci/__init__.py @@ -1 +1,3 @@ -"""CI helpers.""" +""" +CI helpers. +""" diff --git a/ci/test_custom_linters.py b/ci/test_custom_linters.py index 55b0fec8e..8de79cbb8 100644 --- a/ci/test_custom_linters.py +++ b/ci/test_custom_linters.py @@ -91,8 +91,7 @@ def test_tests_collected_once( capsys: pytest.CaptureFixture[str], request: pytest.FixtureRequest, ) -> None: - """ - Each test in the test suite is collected exactly once. + """Each test in the test suite is collected exactly once. This does not necessarily mean that they are run - they may be skipped. """ diff --git a/conftest.py b/conftest.py index f7b14d1d7..ed36d6500 100644 --- a/conftest.py +++ b/conftest.py @@ -1,4 +1,6 @@ -"""Setup for Sybil.""" +""" +Setup for Sybil. +""" from doctest import ELLIPSIS @@ -35,8 +37,7 @@ def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: @beartype @pytest.hookimpl(optionalhook=True) def pytest_set_filtered_exceptions() -> tuple[type[Exception], ...]: - """ - Return exceptions to retry on. + """Return exceptions to retry on. This is for ``pytest-retry``. The configuration for retries is in ``pyproject.toml``. diff --git a/docs/source/__init__.py b/docs/source/__init__.py index 535ceb2ec..b63eed5fb 100644 --- a/docs/source/__init__.py +++ b/docs/source/__init__.py @@ -1 +1,3 @@ -"""Documentation.""" +""" +Documentation. +""" diff --git a/src/mock_vws/_base64_decoding.py b/src/mock_vws/_base64_decoding.py index 03dfe09e5..0d9ae1159 100644 --- a/src/mock_vws/_base64_decoding.py +++ b/src/mock_vws/_base64_decoding.py @@ -11,8 +11,7 @@ @beartype def decode_base64(encoded_data: str) -> bytes: - """ - Decode base64 somewhat like Vuforia does. + """Decode base64 somewhat like Vuforia does. Raises: binascii.Error: Vuforia would consider this encoded data as an diff --git a/src/mock_vws/_constants.py b/src/mock_vws/_constants.py index b7f7385b7..25753ed58 100644 --- a/src/mock_vws/_constants.py +++ b/src/mock_vws/_constants.py @@ -9,8 +9,7 @@ @beartype class ResultCodes(Enum): - """ - Constants representing various VWS result codes. + """Constants representing various VWS result codes. See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes. @@ -44,8 +43,7 @@ class ResultCodes(Enum): @beartype class TargetStatuses(Enum): - """ - Constants representing VWS target statuses. + """Constants representing VWS target statuses. See the 'status' field in https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record diff --git a/src/mock_vws/_database_matchers.py b/src/mock_vws/_database_matchers.py index 691ca4ecb..5e78cf083 100644 --- a/src/mock_vws/_database_matchers.py +++ b/src/mock_vws/_database_matchers.py @@ -19,8 +19,7 @@ def get_database_matching_client_keys( request_path: str, databases: Iterable[VuforiaDatabase], ) -> VuforiaDatabase: - """ - Return the first of the given databases which is being accessed by the + """Return the first of the given databases which is being accessed by the given client request. Args: @@ -65,8 +64,7 @@ def get_database_matching_server_keys( request_path: str, databases: Iterable[VuforiaDatabase], ) -> VuforiaDatabase: - """ - Return the first of the given databases which is being accessed by the + """Return the first of the given databases which is being accessed by the given server request. Args: diff --git a/src/mock_vws/_flask_server/__init__.py b/src/mock_vws/_flask_server/__init__.py index 81533727f..50e18f288 100644 --- a/src/mock_vws/_flask_server/__init__.py +++ b/src/mock_vws/_flask_server/__init__.py @@ -1 +1,3 @@ -"""Flask server for the mock Vuforia web service.""" +""" +Flask server for the mock Vuforia web service. +""" diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index 189590c45..c31950be6 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -32,14 +32,18 @@ @beartype class _TargetRaterChoice(StrEnum): - """Target rater choices.""" + """ + Target rater choices. + """ BRISQUE = auto() PERFECT = auto() RANDOM = auto() def to_target_rater(self) -> TargetTrackingRater: - """Get the target rater.""" + """ + Get the target rater. + """ match self: case self.BRISQUE: return BrisqueTargetTrackingRater() @@ -53,7 +57,9 @@ def to_target_rater(self) -> TargetTrackingRater: @beartype class TargetManagerSettings(BaseSettings): - """Settings for the Target Manager Flask app.""" + """ + Settings for the Target Manager Flask app. + """ target_manager_host: str = "" target_rater: _TargetRaterChoice = _TargetRaterChoice.BRISQUE @@ -65,8 +71,7 @@ class TargetManagerSettings(BaseSettings): ) @beartype def delete_database(database_name: str) -> Response: - """ - Delete a database. + """Delete a database. :status 200: The database has been deleted. """ @@ -99,32 +104,29 @@ def get_databases() -> Response: @TARGET_MANAGER_FLASK_APP.route("/databases", methods=[HTTPMethod.POST]) @beartype def create_database() -> Response: - """ - Create a new database. - - :reqheader Content-Type: application/json - :resheader Content-Type: application/json - - :reqjson string client_access_key: (Optional) The client access key for the - database. - :reqjson string client_secret_key: (Optional) The client secret key for the - database. - :reqjson string database_name: (Optional) The name of the database. - :reqjson string server_access_key: (Optional) The server access key for the - database. - :reqjson string server_secret_key: (Optional) The server secret key for the - database. - :reqjson string state_name: (Optional) The state of the database. This can - be "WORKING" or "PROJECT_INACTIVE". This defaults to "WORKING". - - :resjson string client_access_key: The client access key for the database. - :resjson string client_secret_key: The client secret key for the database. - :resjson string database_name: The database name. - :resjson string server_access_key: The server access key for the database. - :resjson string server_secret_key: The server secret key for the database. - :resjson string state_name: The database state. This will be "WORKING" or - "PROJECT_INACTIVE". - :reqjsonarr targets: The targets in the database. + """Create a new database. + + :reqheader Content-Type: application/json :resheader Content-Type: + application/json + + :reqjson string client_access_key: (Optional) The client access key + for the database. :reqjson string client_secret_key: (Optional) + The client secret key for the database. :reqjson string + database_name: (Optional) The name of the database. :reqjson string + server_access_key: (Optional) The server access key for the + database. :reqjson string server_secret_key: (Optional) The server + secret key for the database. :reqjson string state_name: + (Optional) The state of the database. This can be "WORKING" or + "PROJECT_INACTIVE". This defaults to "WORKING". + + :resjson string client_access_key: The client access key for the + database. :resjson string client_secret_key: The client secret key + for the database. :resjson string database_name: The database name. + :resjson string server_access_key: The server access key for the + database. :resjson string server_secret_key: The server secret key + for the database. :resjson string state_name: The database state. + This will be "WORKING" or "PROJECT_INACTIVE". :reqjsonarr targets: + The targets in the database. :status 201: The database has been successfully created. """ diff --git a/src/mock_vws/_flask_server/vwq.py b/src/mock_vws/_flask_server/vwq.py index df5f986d0..924941bca 100644 --- a/src/mock_vws/_flask_server/vwq.py +++ b/src/mock_vws/_flask_server/vwq.py @@ -1,5 +1,4 @@ -""" -A fake implementation of the Vuforia Web Query API using Flask. +"""A fake implementation of the Vuforia Web Query API using Flask. See https://developer.vuforia.com/library/web-api/vuforia-query-web-api @@ -34,13 +33,17 @@ @beartype class _ImageMatcherChoice(StrEnum): - """Image matcher choices.""" + """ + Image matcher choices. + """ EXACT = auto() STRUCTURAL_SIMILARITY = auto() def to_image_matcher(self) -> ImageMatcher: - """Get the image matcher.""" + """ + Get the image matcher. + """ match self: case self.EXACT: return ExactMatcher() @@ -52,7 +55,9 @@ def to_image_matcher(self) -> ImageMatcher: @beartype class VWQSettings(BaseSettings): - """Settings for the VWQ Flask app.""" + """ + Settings for the VWQ Flask app. + """ vwq_host: str = "" target_manager_base_url: str @@ -80,10 +85,9 @@ def get_all_databases() -> set[VuforiaDatabase]: @CLOUDRECO_FLASK_APP.before_request @beartype def set_terminate_wsgi_input() -> None: - """ - We set ``wsgi.input_terminated`` to ``True`` when going through - ``requests`` in our tests, so that requests have the given - ``Content-Length`` headers and the given data in ``request.headers`` and + """We set ``wsgi.input_terminated`` to ``True`` when going through + ``requests`` in our tests, so that requests have the given ``Content- + Length`` headers and the given data in ``request.headers`` and ``request.data``. We do not set this at all when running an application as standalone. diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index 19a402b01..402b41e2c 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -1,5 +1,4 @@ -""" -A fake implementation of the Vuforia Web Services API. +"""A fake implementation of the Vuforia Web Services API. See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api @@ -48,13 +47,17 @@ @beartype class _ImageMatcherChoice(StrEnum): - """Image matcher choices.""" + """ + Image matcher choices. + """ EXACT = auto() STRUCTURAL_SIMILARITY = auto() def to_image_matcher(self) -> ImageMatcher: - """Get the image matcher.""" + """ + Get the image matcher. + """ match self: case self.EXACT: return ExactMatcher() @@ -66,7 +69,9 @@ def to_image_matcher(self) -> ImageMatcher: @beartype class VWSSettings(BaseSettings): - """Settings for the VWS Flask app.""" + """ + Settings for the VWS Flask app. + """ target_manager_base_url: str processing_time_seconds: float = 2.0 @@ -95,10 +100,9 @@ def get_all_databases() -> set[VuforiaDatabase]: @VWS_FLASK_APP.before_request def set_terminate_wsgi_input() -> None: - """ - We set ``wsgi.input_terminated`` to ``True`` when going through - ``requests`` in our tests, so that requests have the given - ``Content-Length`` headers and the given data in ``request.headers`` and + """We set ``wsgi.input_terminated`` to ``True`` when going through + ``requests`` in our tests, so that requests have the given ``Content- + Length`` headers and the given data in ``request.headers`` and ``request.data``. We do not set this at all when running an application as standalone. @@ -155,8 +159,7 @@ def handle_exceptions(exc: ValidatorError) -> Response: @VWS_FLASK_APP.route("/targets", methods=[HTTPMethod.POST]) @beartype def add_target() -> Response: - """ - Add a target. + """Add a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#add @@ -228,8 +231,7 @@ def add_target() -> Response: @VWS_FLASK_APP.route("/targets/", methods=[HTTPMethod.GET]) @beartype def get_target(target_id: str) -> Response: - """ - Get details of a target. + """Get details of a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record @@ -285,8 +287,7 @@ def get_target(target_id: str) -> Response: methods=[HTTPMethod.DELETE], ) def delete_target(target_id: str) -> Response: - """ - Delete a target. + """Delete a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#delete @@ -339,8 +340,7 @@ def delete_target(target_id: str) -> Response: @VWS_FLASK_APP.route("/summary", methods=[HTTPMethod.GET]) @beartype def database_summary() -> Response: - """ - Get a database summary report. + """Get a database summary report. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report @@ -392,8 +392,7 @@ def database_summary() -> Response: @VWS_FLASK_APP.route("/summary/", methods=[HTTPMethod.GET]) def target_summary(target_id: str) -> Response: - """ - Get a summary report for a target. + """Get a summary report for a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#retrieve-report @@ -447,8 +446,7 @@ def target_summary(target_id: str) -> Response: ) @beartype def get_duplicates(target_id: str) -> Response: - """ - Get targets which may be considered duplicates of a given target. + """Get targets which may be considered duplicates of a given target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check @@ -507,8 +505,7 @@ def get_duplicates(target_id: str) -> Response: @VWS_FLASK_APP.route("/targets", methods=[HTTPMethod.GET]) def target_list() -> Response: - """ - Get a list of all targets. + """Get a list of all targets. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#details-list @@ -548,8 +545,7 @@ def target_list() -> Response: @VWS_FLASK_APP.route("/targets/", methods=[HTTPMethod.PUT]) def update_target(target_id: str) -> Response: - """ - Update a target. + """Update a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#update diff --git a/src/mock_vws/_mock_common.py b/src/mock_vws/_mock_common.py index ef1bc987f..7ef5d7502 100644 --- a/src/mock_vws/_mock_common.py +++ b/src/mock_vws/_mock_common.py @@ -12,8 +12,7 @@ @dataclass(frozen=True) class Route: - """ - A representation of a VWS route. + """A representation of a VWS route. Args: route_name: The name of the method. diff --git a/src/mock_vws/_query_validators/__init__.py b/src/mock_vws/_query_validators/__init__.py index a933a919c..9fc608c78 100644 --- a/src/mock_vws/_query_validators/__init__.py +++ b/src/mock_vws/_query_validators/__init__.py @@ -49,8 +49,7 @@ def run_query_validators( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Run all validators. + """Run all validators. Args: request_path: The path of the request. diff --git a/src/mock_vws/_query_validators/accept_header_validators.py b/src/mock_vws/_query_validators/accept_header_validators.py index f7aa766a3..baeb735fe 100644 --- a/src/mock_vws/_query_validators/accept_header_validators.py +++ b/src/mock_vws/_query_validators/accept_header_validators.py @@ -14,8 +14,7 @@ @beartype def validate_accept_header(request_headers: Mapping[str, str]) -> None: - """ - Validate the accept header. + """Validate the accept header. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/auth_validators.py b/src/mock_vws/_query_validators/auth_validators.py index 555dea6c9..a8a139691 100644 --- a/src/mock_vws/_query_validators/auth_validators.py +++ b/src/mock_vws/_query_validators/auth_validators.py @@ -20,8 +20,8 @@ @beartype def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None: - """ - Validate that there is an authorization header given to the query endpoint. + """Validate that there is an authorization header given to the query + endpoint. Args: request_headers: The headers sent with the request. @@ -41,8 +41,7 @@ def validate_auth_header_number_of_parts( *, request_headers: Mapping[str, str], ) -> None: - """ - Validate the authorization header includes text either side of a space. + """Validate the authorization header includes text either side of a space. Args: request_headers: The headers sent with the request. @@ -67,8 +66,7 @@ def validate_client_key_exists( request_headers: Mapping[str, str], databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the authorization header includes a client key for a database. + """Validate the authorization header includes a client key for a database. Args: request_headers: The headers sent with the request. @@ -92,8 +90,7 @@ def validate_client_key_exists( def validate_auth_header_has_signature( request_headers: Mapping[str, str], ) -> None: - """ - Validate the authorization header includes a signature. + """Validate the authorization header includes a signature. Args: request_headers: The headers sent with the request. @@ -118,8 +115,7 @@ def validate_authorization( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the authorization header given to the query endpoint. + """Validate the authorization header given to the query endpoint. Args: request_path: The path of the request. diff --git a/src/mock_vws/_query_validators/content_length_validators.py b/src/mock_vws/_query_validators/content_length_validators.py index 4abbf6bf0..f7cbac25b 100644 --- a/src/mock_vws/_query_validators/content_length_validators.py +++ b/src/mock_vws/_query_validators/content_length_validators.py @@ -21,8 +21,7 @@ def validate_content_length_header_is_int( *, request_headers: Mapping[str, str], ) -> None: - """ - Validate the ``Content-Length`` header is an integer. + """Validate the ``Content-Length`` header is an integer. Args: request_headers: The headers sent with the request. @@ -46,8 +45,7 @@ def validate_content_length_header_not_too_large( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Length`` header is not too large. + """Validate the ``Content-Length`` header is not too large. Args: request_headers: The headers sent with the request. @@ -73,8 +71,7 @@ def validate_content_length_header_not_too_small( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Length`` header is not too small. + """Validate the ``Content-Length`` header is not too small. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/content_type_validators.py b/src/mock_vws/_query_validators/content_type_validators.py index ce0450bca..89b8dddd8 100644 --- a/src/mock_vws/_query_validators/content_type_validators.py +++ b/src/mock_vws/_query_validators/content_type_validators.py @@ -23,8 +23,7 @@ def validate_content_type_header( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Type`` header. + """Validate the ``Content-Type`` header. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/date_validators.py b/src/mock_vws/_query_validators/date_validators.py index 755200b3f..b5cfb2dea 100644 --- a/src/mock_vws/_query_validators/date_validators.py +++ b/src/mock_vws/_query_validators/date_validators.py @@ -21,8 +21,7 @@ @beartype def validate_date_header_given(*, request_headers: Mapping[str, str]) -> None: - """ - Validate the date header is given to the query endpoint. + """Validate the date header is given to the query endpoint. Args: request_headers: The headers sent with the request. @@ -38,11 +37,10 @@ def validate_date_header_given(*, request_headers: Mapping[str, str]) -> None: def _accepted_date_formats() -> set[str]: - """ - Return all known accepted date formats. + """Return all known accepted date formats. - We expect that more formats than this will be accepted. - These are the accepted ones we know of at the time of writing. + We expect that more formats than this will be accepted. These are + the accepted ones we know of at the time of writing. """ known_accepted_formats = { "%a, %b %d %H:%M:%S %Y", @@ -58,8 +56,7 @@ def _accepted_date_formats() -> set[str]: @beartype def validate_date_format(*, request_headers: Mapping[str, str]) -> None: - """ - Validate the format of the date header given to the query endpoint. + """Validate the format of the date header given to the query endpoint. Args: request_headers: The headers sent with the request. @@ -80,8 +77,7 @@ def validate_date_format(*, request_headers: Mapping[str, str]) -> None: @beartype def validate_date_in_range(*, request_headers: Mapping[str, str]) -> None: - """ - Validate date in the date header given to the query endpoint. + """Validate date in the date header given to the query endpoint. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index f849addd0..bf1cb7b37 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -425,8 +425,8 @@ def __init__(self) -> None: @beartype class InvalidMaxNumResultsError(ValidatorError): """ - Exception raised when an invalid value is given as the - "max_num_results" field. + Exception raised when an invalid value is given as the "max_num_results" + field. """ def __init__(self, given_value: str) -> None: diff --git a/src/mock_vws/_query_validators/fields_validators.py b/src/mock_vws/_query_validators/fields_validators.py index 0ab9f2260..3b91fb9fb 100644 --- a/src/mock_vws/_query_validators/fields_validators.py +++ b/src/mock_vws/_query_validators/fields_validators.py @@ -21,8 +21,7 @@ def validate_extra_fields( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate that the no unknown fields are given. + """Validate that the no unknown fields are given. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/image_validators.py b/src/mock_vws/_query_validators/image_validators.py index fe8998b44..e299b4384 100644 --- a/src/mock_vws/_query_validators/image_validators.py +++ b/src/mock_vws/_query_validators/image_validators.py @@ -26,8 +26,7 @@ def validate_image_field_given( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate that the image field is given. + """Validate that the image field is given. Args: request_headers: The headers sent with the request. @@ -58,8 +57,7 @@ def validate_image_file_size( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the file size of the image given to the query endpoint. + """Validate the file size of the image given to the query endpoint. Args: request_headers: The headers sent with the request. @@ -99,8 +97,7 @@ def validate_image_dimensions( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the dimensions the image given to the query endpoint. + """Validate the dimensions the image given to the query endpoint. Args: request_headers: The headers sent with the request. @@ -138,8 +135,7 @@ def validate_image_format( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the format of the image given to the query endpoint. + """Validate the format of the image given to the query endpoint. Args: request_headers: The headers sent with the request. @@ -172,8 +168,7 @@ def validate_image_is_image( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate that the given image data is actually an image file. + """Validate that the given image data is actually an image file. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/include_target_data_validators.py b/src/mock_vws/_query_validators/include_target_data_validators.py index 31f1c5d50..684a880e8 100644 --- a/src/mock_vws/_query_validators/include_target_data_validators.py +++ b/src/mock_vws/_query_validators/include_target_data_validators.py @@ -20,9 +20,8 @@ def validate_include_target_data( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``include_target_data`` field is either an accepted value or - not given. + """Validate the ``include_target_data`` field is either an accepted value + or not given. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/num_results_validators.py b/src/mock_vws/_query_validators/num_results_validators.py index 9eb49a6a0..bbfe12d0c 100644 --- a/src/mock_vws/_query_validators/num_results_validators.py +++ b/src/mock_vws/_query_validators/num_results_validators.py @@ -24,9 +24,8 @@ def validate_max_num_results( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``max_num_results`` field is either an integer within range or - not given. + """Validate the ``max_num_results`` field is either an integer within range + or not given. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_query_validators/project_state_validators.py b/src/mock_vws/_query_validators/project_state_validators.py index ae5065741..bd44f4fd8 100644 --- a/src/mock_vws/_query_validators/project_state_validators.py +++ b/src/mock_vws/_query_validators/project_state_validators.py @@ -23,8 +23,7 @@ def validate_project_state( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the state of the project. + """Validate the state of the project. Args: request_path: The path of the request. diff --git a/src/mock_vws/_requests_mock_server/decorators.py b/src/mock_vws/_requests_mock_server/decorators.py index 547213f3a..b9423b451 100644 --- a/src/mock_vws/_requests_mock_server/decorators.py +++ b/src/mock_vws/_requests_mock_server/decorators.py @@ -45,7 +45,9 @@ def __init__(self, url: str) -> None: self.url = url def __str__(self) -> str: - """Give a string representation of this error with a suggestion.""" + """ + Give a string representation of this error with a suggestion. + """ return ( f'Invalid URL "{self.url}": No scheme supplied. ' f'Perhaps you meant "https://{self.url}".' @@ -69,8 +71,7 @@ def __init__( target_tracking_rater: TargetTrackingRater = _BRISQUE_TRACKING_RATER, real_http: bool = False, ) -> None: - """ - Route requests to Vuforia's Web Service APIs to fakes of those APIs. + """Route requests to Vuforia's Web Service APIs to fakes of those APIs. Args: real_http: Whether or not to forward requests to the real @@ -116,8 +117,7 @@ def __init__( ) def add_database(self, database: VuforiaDatabase) -> None: - """ - Add a cloud database. + """Add a cloud database. Args: database: The database to add. @@ -129,8 +129,7 @@ def add_database(self, database: VuforiaDatabase) -> None: self._target_manager.add_database(database=database) def __enter__(self) -> Self: - """ - Start an instance of a Vuforia mock. + """Start an instance of a Vuforia mock. Returns: ``self``. @@ -186,8 +185,7 @@ def __enter__(self) -> Self: return self def __exit__(self, *exc: object) -> Literal[False]: - """ - Stop the Vuforia mock. + """Stop the Vuforia mock. Returns: False diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index 1a287066a..abc125c5c 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -1,5 +1,4 @@ -""" -A fake implementation of the Vuforia Web Query API. +"""A fake implementation of the Vuforia Web Query API. See https://developer.vuforia.com/library/web-api/vuforia-query-web-api @@ -33,8 +32,7 @@ def route( path_pattern: str, http_methods: Iterable[str], ) -> Callable[[Callable[..., _ResponseType]], Callable[..., _ResponseType]]: - """ - Register a decorated method so that it can be recognized as a route. + """Register a decorated method so that it can be recognized as a route. Args: path_pattern: The end part of a URL pattern. E.g. `/targets` or @@ -48,8 +46,7 @@ def route( def decorator( method: Callable[..., _ResponseType], ) -> Callable[..., _ResponseType]: - """ - Register a decorated method so that it can be recognized as a route. + """Register a decorated method so that it can be recognized as a route. Returns: The given `method` with multiple changes, including added @@ -81,8 +78,7 @@ def _body_bytes(request: PreparedRequest) -> bytes: @beartype class MockVuforiaWebQueryAPI: - """ - A fake implementation of the Vuforia Web Query API. + """A fake implementation of the Vuforia Web Query API. This implementation is tied to the implementation of ``responses``. """ diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 07d6c719c..7aea34ad6 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -1,5 +1,4 @@ -""" -A fake implementation of the Vuforia Web Services API. +"""A fake implementation of the Vuforia Web Services API. See https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api @@ -47,8 +46,7 @@ def route( path_pattern: str, http_methods: Iterable[HTTPMethod], ) -> Callable[[Callable[..., _ResponseType]], Callable[..., _ResponseType]]: - """ - Register a decorated method so that it can be recognized as a route. + """Register a decorated method so that it can be recognized as a route. Args: path_pattern: The end part of a URL pattern. E.g. `/targets` or @@ -63,8 +61,7 @@ def route( def decorator( method: Callable[..., _ResponseType], ) -> Callable[..., _ResponseType]: - """ - Register a decorated method so that it can be recognized as a route. + """Register a decorated method so that it can be recognized as a route. Returns: The given `method` with multiple changes, including added @@ -99,8 +96,7 @@ def _body_bytes(request: PreparedRequest) -> bytes: @beartype(conf=BeartypeConf(is_pep484_tower=True)) class MockVuforiaWebServicesAPI: - """ - A fake implementation of the Vuforia Web Services API. + """A fake implementation of the Vuforia Web Services API. This implementation is tied to the implementation of ``responses``. """ @@ -137,8 +133,7 @@ def __init__( http_methods={HTTPMethod.POST}, ) def add_target(self, request: PreparedRequest) -> _ResponseType: - """ - Add a target. + """Add a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#add @@ -213,8 +208,7 @@ def add_target(self, request: PreparedRequest) -> _ResponseType: http_methods={HTTPMethod.DELETE}, ) def delete_target(self, request: PreparedRequest) -> _ResponseType: - """ - Delete a target. + """Delete a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#delete @@ -279,8 +273,7 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: @route(path_pattern="/summary", http_methods={HTTPMethod.GET}) def database_summary(self, request: PreparedRequest) -> _ResponseType: - """ - Get a database summary report. + """Get a database summary report. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#summary-report @@ -341,8 +334,7 @@ def database_summary(self, request: PreparedRequest) -> _ResponseType: @route(path_pattern="/targets", http_methods={HTTPMethod.GET}) def target_list(self, request: PreparedRequest) -> _ResponseType: - """ - Get a list of all targets. + """Get a list of all targets. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#details-list @@ -399,8 +391,7 @@ def target_list(self, request: PreparedRequest) -> _ResponseType: http_methods={HTTPMethod.GET}, ) def get_target(self, request: PreparedRequest) -> _ResponseType: - """ - Get details of a target. + """Get details of a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record @@ -465,8 +456,7 @@ def get_target(self, request: PreparedRequest) -> _ResponseType: http_methods={HTTPMethod.GET}, ) def get_duplicates(self, request: PreparedRequest) -> _ResponseType: - """ - Get targets which may be considered duplicates of a given target. + """Get targets which may be considered duplicates of a given target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check @@ -537,8 +527,7 @@ def get_duplicates(self, request: PreparedRequest) -> _ResponseType: http_methods={HTTPMethod.PUT}, ) def update_target(self, request: PreparedRequest) -> _ResponseType: - """ - Update a target. + """Update a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#update @@ -650,8 +639,7 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: http_methods={HTTPMethod.GET}, ) def target_summary(self, request: PreparedRequest) -> _ResponseType: - """ - Get a summary report for a target. + """Get a summary report for a target. Fake implementation of https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#retrieve-report diff --git a/src/mock_vws/_services_validators/__init__.py b/src/mock_vws/_services_validators/__init__.py index f2c72aec6..ac4c0a331 100644 --- a/src/mock_vws/_services_validators/__init__.py +++ b/src/mock_vws/_services_validators/__init__.py @@ -58,8 +58,7 @@ def run_services_validators( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Run all validators. + """Run all validators. Args: request_path: The path of the request. diff --git a/src/mock_vws/_services_validators/active_flag_validators.py b/src/mock_vws/_services_validators/active_flag_validators.py index 1f444d3c1..f4864bcc7 100644 --- a/src/mock_vws/_services_validators/active_flag_validators.py +++ b/src/mock_vws/_services_validators/active_flag_validators.py @@ -15,8 +15,7 @@ @beartype def validate_active_flag(*, request_body: bytes) -> None: - """ - Validate the active flag data given to the endpoint. + """Validate the active flag data given to the endpoint. Args: request_body: The body of the request. diff --git a/src/mock_vws/_services_validators/auth_validators.py b/src/mock_vws/_services_validators/auth_validators.py index 89fe85f88..0fd8d6757 100644 --- a/src/mock_vws/_services_validators/auth_validators.py +++ b/src/mock_vws/_services_validators/auth_validators.py @@ -20,8 +20,7 @@ @beartype def validate_auth_header_exists(*, request_headers: Mapping[str, str]) -> None: - """ - Validate that there is an authorization header given to a VWS endpoint. + """Validate that there is an authorization header given to a VWS endpoint. Args: request_headers: The headers sent with the request. @@ -40,8 +39,7 @@ def validate_access_key_exists( request_headers: Mapping[str, str], databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the authorization header includes an access key for a database. + """Validate the authorization header includes an access key for a database. Args: request_headers: The headers sent with the request. @@ -69,8 +67,7 @@ def validate_auth_header_has_signature( *, request_headers: Mapping[str, str], ) -> None: - """ - Validate the authorization header includes a signature. + """Validate the authorization header includes a signature. Args: request_headers: The headers sent with the request. @@ -97,8 +94,7 @@ def validate_authorization( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the authorization header given to a VWS endpoint. + """Validate the authorization header given to a VWS endpoint. Args: request_path: The path of the request. diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index 88f3e451d..a9728e4d6 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -22,8 +22,7 @@ def validate_content_length_header_is_int( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Length`` header is an integer. + """Validate the ``Content-Length`` header is an integer. Args: request_headers: The headers sent with the request. @@ -49,8 +48,7 @@ def validate_content_length_header_not_too_large( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Length`` header is not too large. + """Validate the ``Content-Length`` header is not too large. Args: request_headers: The headers sent with the request. @@ -75,8 +73,7 @@ def validate_content_length_header_not_too_small( request_headers: Mapping[str, str], request_body: bytes, ) -> None: - """ - Validate the ``Content-Length`` header is not too small. + """Validate the ``Content-Length`` header is not too small. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_services_validators/content_type_validators.py b/src/mock_vws/_services_validators/content_type_validators.py index 6afa606dc..0e98eb8bd 100644 --- a/src/mock_vws/_services_validators/content_type_validators.py +++ b/src/mock_vws/_services_validators/content_type_validators.py @@ -19,8 +19,8 @@ def validate_content_type_header_given( request_headers: Mapping[str, str], request_method: str, ) -> None: - """ - Validate that there is a non-empty content type header given if required. + """Validate that there is a non-empty content type header given if + required. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_services_validators/date_validators.py b/src/mock_vws/_services_validators/date_validators.py index b52bf83d7..4f6bda3ed 100644 --- a/src/mock_vws/_services_validators/date_validators.py +++ b/src/mock_vws/_services_validators/date_validators.py @@ -20,8 +20,7 @@ @beartype def validate_date_header_given(*, request_headers: Mapping[str, str]) -> None: - """ - Validate the date header is given to a VWS endpoint. + """Validate the date header is given to a VWS endpoint. Args: request_headers: The headers sent with the request. @@ -38,8 +37,7 @@ def validate_date_header_given(*, request_headers: Mapping[str, str]) -> None: @beartype def validate_date_format(*, request_headers: Mapping[str, str]) -> None: - """ - Validate the format of the date header given to a VWS endpoint. + """Validate the format of the date header given to a VWS endpoint. Args: request_headers: The headers sent with the request. @@ -58,8 +56,7 @@ def validate_date_format(*, request_headers: Mapping[str, str]) -> None: @beartype def validate_date_in_range(*, request_headers: Mapping[str, str]) -> None: - """ - Validate the date header given to a VWS endpoint is in range. + """Validate the date header given to a VWS endpoint is in range. Args: request_headers: The headers sent with the request. diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index cb1125ac4..0eeda683f 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -267,11 +267,11 @@ def __init__(self) -> None: @beartype class OopsErrorOccurredResponseError(ValidatorError): - """ - Exception raised when VWS returns an HTML page which says "Oops, an error - occurred". + """Exception raised when VWS returns an HTML page which says "Oops, an + error occurred". - This has been seen to happen when the given name includes a bad character. + This has been seen to happen when the given name includes a bad + character. """ def __init__(self) -> None: diff --git a/src/mock_vws/_services_validators/image_validators.py b/src/mock_vws/_services_validators/image_validators.py index 8927b7986..96b786f28 100644 --- a/src/mock_vws/_services_validators/image_validators.py +++ b/src/mock_vws/_services_validators/image_validators.py @@ -23,8 +23,7 @@ @beartype def validate_image_format(*, request_body: bytes) -> None: - """ - Validate the format of the image given to a VWS endpoint. + """Validate the format of the image given to a VWS endpoint. Args: request_body: The body of the request. @@ -54,8 +53,7 @@ def validate_image_format(*, request_body: bytes) -> None: @beartype def validate_image_color_space(*, request_body: bytes) -> None: - """ - Validate the color space of the image given to a VWS endpoint. + """Validate the color space of the image given to a VWS endpoint. Args: request_body: The body of the request. @@ -88,8 +86,7 @@ def validate_image_color_space(*, request_body: bytes) -> None: @beartype def validate_image_size(*, request_body: bytes) -> None: - """ - Validate the file size of the image given to a VWS endpoint. + """Validate the file size of the image given to a VWS endpoint. Args: request_body: The body of the request. @@ -119,8 +116,7 @@ def validate_image_size(*, request_body: bytes) -> None: @beartype def validate_image_is_image(*, request_body: bytes) -> None: - """ - Validate that the given image data is actually an image file. + """Validate that the given image data is actually an image file. Args: request_body: The body of the request. @@ -148,8 +144,7 @@ def validate_image_is_image(*, request_body: bytes) -> None: @beartype def validate_image_encoding(*, request_body: bytes) -> None: - """ - Validate that the given image data can be base64 decoded. + """Validate that the given image data can be base64 decoded. Args: request_body: The body of the request. @@ -175,8 +170,7 @@ def validate_image_encoding(*, request_body: bytes) -> None: @beartype def validate_image_data_type(*, request_body: bytes) -> None: - """ - Validate that the given image data is a string. + """Validate that the given image data is a string. Args: request_body: The body of the request. diff --git a/src/mock_vws/_services_validators/json_validators.py b/src/mock_vws/_services_validators/json_validators.py index 9c9303402..1f97f2784 100644 --- a/src/mock_vws/_services_validators/json_validators.py +++ b/src/mock_vws/_services_validators/json_validators.py @@ -19,9 +19,8 @@ @beartype def validate_body_given(*, request_body: bytes, request_method: str) -> None: - """ - Validate that no JSON is given for requests other than ``POST`` and ``PUT`` - requests. + """Validate that no JSON is given for requests other than ``POST`` and + ``PUT`` requests. Args: request_body: The body of the request. @@ -47,8 +46,7 @@ def validate_body_given(*, request_body: bytes, request_method: str) -> None: @beartype def validate_json(*, request_body: bytes) -> None: - """ - Validate that any given body is valid JSON. + """Validate that any given body is valid JSON. Args: request_body: The body of the request. diff --git a/src/mock_vws/_services_validators/key_validators.py b/src/mock_vws/_services_validators/key_validators.py index 7b3b4109b..85f4a3f77 100644 --- a/src/mock_vws/_services_validators/key_validators.py +++ b/src/mock_vws/_services_validators/key_validators.py @@ -18,8 +18,7 @@ @dataclass class _Route: - """ - A representation of a VWS route. + """A representation of a VWS route. Args: path_pattern: The end part of a URL pattern. E.g. `/targets` or @@ -43,8 +42,7 @@ def validate_keys( request_path: str, request_method: str, ) -> None: - """ - Validate the request keys given to a VWS endpoint. + """Validate the request keys given to a VWS endpoint. Args: request_body: The body of the request. diff --git a/src/mock_vws/_services_validators/metadata_validators.py b/src/mock_vws/_services_validators/metadata_validators.py index b8b81deb1..7ad3a1851 100644 --- a/src/mock_vws/_services_validators/metadata_validators.py +++ b/src/mock_vws/_services_validators/metadata_validators.py @@ -20,8 +20,7 @@ @beartype def validate_metadata_size(*, request_body: bytes) -> None: - """ - Validate that the given application metadata is a string or 1024 * 1024 + """Validate that the given application metadata is a string or 1024 * 1024 bytes or fewer. Args: @@ -51,8 +50,7 @@ def validate_metadata_size(*, request_body: bytes) -> None: @beartype def validate_metadata_encoding(*, request_body: bytes) -> None: - """ - Validate that the given application metadata can be base64 decoded. + """Validate that the given application metadata can be base64 decoded. Args: request_body: The body of the request. @@ -83,8 +81,7 @@ def validate_metadata_encoding(*, request_body: bytes) -> None: @beartype def validate_metadata_type(*, request_body: bytes) -> None: - """ - Validate that the given application metadata is a string or NULL. + """Validate that the given application metadata is a string or NULL. Args: request_body: The body of the request. diff --git a/src/mock_vws/_services_validators/name_validators.py b/src/mock_vws/_services_validators/name_validators.py index 516e320e6..2b1c93eb9 100644 --- a/src/mock_vws/_services_validators/name_validators.py +++ b/src/mock_vws/_services_validators/name_validators.py @@ -27,8 +27,7 @@ def validate_name_characters_in_range( request_method: str, request_path: str, ) -> None: - """ - Validate the characters in the name argument given to a VWS endpoint. + """Validate the characters in the name argument given to a VWS endpoint. Args: request_body: The body of the request. @@ -64,8 +63,7 @@ def validate_name_characters_in_range( @beartype def validate_name_type(*, request_body: bytes) -> None: - """ - Validate the type of the name argument given to a VWS endpoint. + """Validate the type of the name argument given to a VWS endpoint. Args: request_body: The body of the request. @@ -91,8 +89,7 @@ def validate_name_type(*, request_body: bytes) -> None: @beartype def validate_name_length(*, request_body: bytes) -> None: - """ - Validate the length of the name argument given to a VWS endpoint. + """Validate the length of the name argument given to a VWS endpoint. Args: request_body: The body of the request. @@ -127,8 +124,7 @@ def validate_name_does_not_exist_new_target( request_method: str, request_path: str, ) -> None: - """ - Validate that the name does not exist for any existing target. + """Validate that the name does not exist for any existing target. Args: databases: All Vuforia databases. @@ -184,8 +180,7 @@ def validate_name_does_not_exist_existing_target( request_path: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate that the name does not exist for any existing target apart from + """Validate that the name does not exist for any existing target apart from the one being updated. Args: diff --git a/src/mock_vws/_services_validators/project_state_validators.py b/src/mock_vws/_services_validators/project_state_validators.py index a526d8f95..09fed3d92 100644 --- a/src/mock_vws/_services_validators/project_state_validators.py +++ b/src/mock_vws/_services_validators/project_state_validators.py @@ -25,8 +25,7 @@ def validate_project_state( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate the state of the project. + """Validate the state of the project. Args: request_path: The path of the request. diff --git a/src/mock_vws/_services_validators/target_validators.py b/src/mock_vws/_services_validators/target_validators.py index bd9cff906..1f6a9e0a2 100644 --- a/src/mock_vws/_services_validators/target_validators.py +++ b/src/mock_vws/_services_validators/target_validators.py @@ -23,9 +23,8 @@ def validate_target_id_exists( request_method: str, databases: Iterable[VuforiaDatabase], ) -> None: - """ - Validate that if a target ID is given, it exists in the database matching - the request. + """Validate that if a target ID is given, it exists in the database + matching the request. Args: request_path: The path of the request. diff --git a/src/mock_vws/_services_validators/width_validators.py b/src/mock_vws/_services_validators/width_validators.py index 9f42e3c3c..e1d77c596 100644 --- a/src/mock_vws/_services_validators/width_validators.py +++ b/src/mock_vws/_services_validators/width_validators.py @@ -15,8 +15,7 @@ @beartype def validate_width(*, request_body: bytes) -> None: - """ - Validate the width argument given to a VWS endpoint. + """Validate the width argument given to a VWS endpoint. Args: request_body: The body of the request. diff --git a/src/mock_vws/database.py b/src/mock_vws/database.py index 4c2e47a1d..a06422f8e 100644 --- a/src/mock_vws/database.py +++ b/src/mock_vws/database.py @@ -40,8 +40,7 @@ def _random_hex() -> str: @beartype @dataclass(eq=True, frozen=True) class VuforiaDatabase: - """ - Credentials for VWS APIs. + """Credentials for VWS APIs. Args: database_name: The name of a VWS target manager database name. Defaults diff --git a/src/mock_vws/image_matchers.py b/src/mock_vws/image_matchers.py index 0cb60a13e..b1a3c2fc2 100644 --- a/src/mock_vws/image_matchers.py +++ b/src/mock_vws/image_matchers.py @@ -1,4 +1,6 @@ -"""Matchers for query and duplicate requests.""" +""" +Matchers for query and duplicate requests. +""" import io from typing import Protocol, runtime_checkable @@ -14,15 +16,16 @@ @runtime_checkable class ImageMatcher(Protocol): - """Protocol for a matcher for query and duplicate requests.""" + """ + Protocol for a matcher for query and duplicate requests. + """ def __call__( self, first_image_content: bytes, second_image_content: bytes, ) -> bool: - """ - Whether one image's content matches another's closely enough. + """Whether one image's content matches another's closely enough. Args: first_image_content: One image's content. @@ -35,15 +38,16 @@ def __call__( @beartype class ExactMatcher: - """A matcher which returns whether two images are exactly equal.""" + """ + A matcher which returns whether two images are exactly equal. + """ def __call__( self, first_image_content: bytes, second_image_content: bytes, ) -> bool: - """ - Whether one image's content matches another's exactly. + """Whether one image's content matches another's exactly. Args: first_image_content: One image's content. @@ -54,15 +58,16 @@ def __call__( @beartype class StructuralSimilarityMatcher: - """A matcher which returns whether two images are similar using SSIM.""" + """ + A matcher which returns whether two images are similar using SSIM. + """ def __call__( self, first_image_content: bytes, second_image_content: bytes, ) -> bool: - """ - Whether one image's content matches another's using a SSIM. + """Whether one image's content matches another's using a SSIM. Args: first_image_content: One image's content. diff --git a/src/mock_vws/target.py b/src/mock_vws/target.py index 67419ec88..b04c3ff52 100644 --- a/src/mock_vws/target.py +++ b/src/mock_vws/target.py @@ -82,13 +82,12 @@ class Target: @property def _post_processing_status(self) -> TargetStatuses: - """ - Return the status of the target, or what it will be when processing is - finished. + """Return the status of the target, or what it will be when processing + is finished. The status depends on the standard deviation of the color bands. - How VWS determines this is unknown, but it relates to how suitable the - target is for detection. + How VWS determines this is unknown, but it relates to how + suitable the target is for detection. """ image_file = io.BytesIO(initial_bytes=self.image_value) image = Image.open(fp=image_file) @@ -105,15 +104,14 @@ def _post_processing_status(self) -> TargetStatuses: @property def status(self) -> str: - """ - Return the status of the target. + """Return the status of the target. For now this waits half a second (arbitrary) before changing the status from 'processing' to 'failed' or 'success'. The status depends on the standard deviation of the color bands. - How VWS determines this is unknown, but it relates to how suitable the - target is for detection. + How VWS determines this is unknown, but it relates to how + suitable the target is for detection. """ processing_time = datetime.timedelta( seconds=float(self.processing_time_seconds), @@ -130,7 +128,9 @@ def status(self) -> str: @property def _post_processing_target_rating(self) -> int: - """The rating of the target after processing.""" + """ + The rating of the target after processing. + """ return self.target_tracking_rater(image_content=self.image_value) @property diff --git a/src/mock_vws/target_manager.py b/src/mock_vws/target_manager.py index c5887d28a..9dc08870a 100644 --- a/src/mock_vws/target_manager.py +++ b/src/mock_vws/target_manager.py @@ -25,8 +25,7 @@ def __init__(self) -> None: self._databases: Iterable[VuforiaDatabase] = set() def remove_database(self, database: VuforiaDatabase) -> None: - """ - Remove a cloud database. + """Remove a cloud database. Args: database: The database to add. @@ -37,8 +36,7 @@ def remove_database(self, database: VuforiaDatabase) -> None: self._databases = {db for db in self._databases if db != database} def add_database(self, database: VuforiaDatabase) -> None: - """ - Add a cloud database. + """Add a cloud database. Args: database: The database to add. diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index 2131bd34c..40f877aa6 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -1,4 +1,6 @@ -"""Raters for target quality.""" +""" +Raters for target quality. +""" import functools import io @@ -16,8 +18,7 @@ @functools.cache @beartype def _get_brisque_target_tracking_rating(*, image_content: bytes) -> int: - """ - Get a target tracking rating based on a BRISQUE score. + """Get a target tracking rating based on a BRISQUE score. This is a rough approximation of the quality score used by Vuforia, but is not accurate. For example, our "corrupted_image" rating is based on a @@ -45,11 +46,12 @@ def _get_brisque_target_tracking_rating(*, image_content: bytes) -> int: @runtime_checkable class TargetTrackingRater(Protocol): - """Protocol for a rater of target quality.""" + """ + Protocol for a rater of target quality. + """ def __call__(self, image_content: bytes) -> int: - """ - The target tracking rating. + """The target tracking rating. Args: image_content: A target's image's content. @@ -61,11 +63,12 @@ def __call__(self, image_content: bytes) -> int: @beartype class RandomTargetTrackingRater: - """A rater which returns a random number.""" + """ + A rater which returns a random number. + """ def __call__(self, image_content: bytes) -> int: - """ - A random target tracking rating. + """A random target tracking rating. Args: image_content: A target's image's content. @@ -76,7 +79,9 @@ def __call__(self, image_content: bytes) -> int: @beartype class HardcodedTargetTrackingRater: - """A rater which returns a hardcoded number.""" + """ + A rater which returns a hardcoded number. + """ def __init__(self, rating: int) -> None: """ @@ -86,8 +91,7 @@ def __init__(self, rating: int) -> None: self._rating = rating def __call__(self, image_content: bytes) -> int: - """ - A random target tracking rating. + """A random target tracking rating. Args: image_content: A target's image's content. @@ -98,11 +102,12 @@ def __call__(self, image_content: bytes) -> int: @beartype class BrisqueTargetTrackingRater: - """A rater which returns a rating based on a BRISQUE score.""" + """ + A rater which returns a rating based on a BRISQUE score. + """ def __call__(self, image_content: bytes) -> int: - """ - A rating based on a BRISQUE score. + """A rating based on a BRISQUE score. This is a rough approximation of the quality score used by Vuforia, but is not accurate. For example, our "corrupted_image" fixture is rated as diff --git a/tests/__init__.py b/tests/__init__.py index 3502d86d5..c7e38a862 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1 +1,3 @@ -"""Tests for ``vws``.""" +""" +Tests for ``vws``. +""" diff --git a/tests/conftest.py b/tests/conftest.py index 04f72f1c5..b8c06558f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -77,8 +77,7 @@ def target_id( image_file_success_state_low_rating: io.BytesIO, vws_client: VWS, ) -> str: - """ - Return the target ID of a target in the database. + """Return the target ID of a target in the database. The target is one which will have a 'success' status when processed. """ @@ -135,9 +134,9 @@ def endpoint(request: pytest.FixtureRequest) -> Endpoint: ], ) def not_base64_encoded_processable(request: pytest.FixtureRequest) -> str: - """ - Return a string which is not decodable as base64 data, but Vuforia will + """Return a string which is not decodable as base64 data, but Vuforia will respond as if this is valid base64 data. + ``UNPROCESSABLE_ENTITY`` when this is given. """ not_base64_encoded_string: str = request.param diff --git a/tests/mock_vws/fixtures/credentials.py b/tests/mock_vws/fixtures/credentials.py index 9ee5749c8..a7e163da7 100644 --- a/tests/mock_vws/fixtures/credentials.py +++ b/tests/mock_vws/fixtures/credentials.py @@ -13,7 +13,9 @@ class _VuforiaDatabaseSettings(BaseSettings): - """Settings for a Vuforia database.""" + """ + Settings for a Vuforia database. + """ target_manager_database_name: str server_access_key: str @@ -29,7 +31,9 @@ class _VuforiaDatabaseSettings(BaseSettings): class _InactiveVuforiaDatabaseSettings(_VuforiaDatabaseSettings): - """Settings for an inactive Vuforia database.""" + """ + Settings for an inactive Vuforia database. + """ model_config = SettingsConfigDict( env_prefix="INACTIVE_VUFORIA_", diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index 37968f01f..dac456b0b 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -25,13 +25,13 @@ @RETRY_ON_TOO_MANY_REQUESTS def _wait_for_target_processed(vws_client: VWS, target_id: str) -> None: - """ - Wait for a target to be processed. + """Wait for a target to be processed. - We retry here because pytest-retry does not retry on exceptions raised in - fixtures. + We retry here because pytest-retry does not retry on exceptions + raised in fixtures. - See https://github.com/str0zzapreti/pytest-retry/issues/33. + See + https://github.com/str0zzapreti/pytest-retry/issues/33. """ vws_client.wait_for_target_processed(target_id=target_id) diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index 8b05da637..23f70d7e3 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -31,8 +31,7 @@ @RETRY_ON_TOO_MANY_REQUESTS def _delete_all_targets(*, database_keys: VuforiaDatabase) -> None: - """ - Delete all targets. + """Delete all targets. Args: database_keys: The credentials to the Vuforia target database to delete @@ -67,7 +66,9 @@ def _enable_use_real_vuforia( inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, ) -> Generator[None]: - """Test against the real Vuforia.""" + """ + Test against the real Vuforia. + """ assert monkeypatch assert inactive_database _delete_all_targets(database_keys=working_database) @@ -81,7 +82,9 @@ def _enable_use_mock_vuforia( inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, ) -> Generator[None]: - """Test against the in-memory mock Vuforia.""" + """ + Test against the in-memory mock Vuforia. + """ assert monkeypatch working_database = VuforiaDatabase( database_name=working_database.database_name, @@ -113,7 +116,9 @@ def _enable_use_docker_in_memory( inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, ) -> Generator[None]: - """Test against mock Vuforia created to be run in a container.""" + """ + Test against mock Vuforia created to be run in a container. + """ # We set ``wsgi.input_terminated`` to ``True`` so that when going through # ``requests`` in our tests, the Flask applications # have the given ``Content-Length`` headers and the given data in @@ -214,7 +219,9 @@ def pytest_collection_modifyitems( config: pytest.Config, items: list[pytest.Function], ) -> None: - """Skip Docker tests if requested.""" + """ + Skip Docker tests if requested. + """ skip_docker_build_tests_option = "--skip-docker_build_tests" skip_docker_build_tests_marker = pytest.mark.skip( reason=( @@ -240,9 +247,8 @@ def fixture_verify_mock_vuforia( inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, ) -> Generator[None]: - """ - Test functions which use this fixture are run multiple times. Once with the - real Vuforia, and once with each mock. + """Test functions which use this fixture are run multiple times. Once with + the real Vuforia, and once with each mock. This is useful for verifying the mocks. @@ -285,9 +291,8 @@ def mock_only_vuforia( inactive_database: VuforiaDatabase, monkeypatch: pytest.MonkeyPatch, ) -> Generator[None]: - """ - Test functions which use this fixture are run multiple times. Once with the - each mock. + """Test functions which use this fixture are run multiple times. Once with + the each mock. This is useful for testing the mock using fixtures which connect to Vuforia. diff --git a/tests/mock_vws/test_add_target.py b/tests/mock_vws/test_add_target.py index adf9695a0..778392a08 100644 --- a/tests/mock_vws/test_add_target.py +++ b/tests/mock_vws/test_add_target.py @@ -45,8 +45,7 @@ def _add_target_to_vws( data: dict[str, Any], content_type: str = "application/json", ) -> Response: - """ - Return a response from a request to the endpoint to add a target. + """Return a response from a request to the endpoint to add a target. Args: vws_client: The client to use to connect to Vuforia. @@ -68,8 +67,7 @@ def _add_target_to_vws( @beartype def _assert_oops_response(response: Response) -> None: - """ - Assert that the response is in the format of Vuforia's "Oops, an error + """Assert that the response is in the format of Vuforia's "Oops, an error occurred" HTML response. Raises: @@ -94,8 +92,7 @@ def _assert_oops_response(response: Response) -> None: def assert_success(response: Response) -> None: - """ - Assert that the given response is a success response for adding a + """Assert that the given response is a success response for adding a target. Raises: @@ -459,8 +456,7 @@ def test_deleted_existing_target_name( @pytest.mark.usefixtures("verify_mock_vuforia") class TestImage: - """ - Tests for the image parameter. + """Tests for the image parameter. The specification for images is documented at https://library.vuforia.com/features/images/image-targets.html. @@ -595,11 +591,11 @@ def test_not_base64_encoded_processable( vws_client: VWS, not_base64_encoded_processable: str, ) -> None: - """ - Some strings which are not valid base64 encoded strings are allowed as - an image without getting a "Fail" response. - This is because Vuforia treats them as valid base64, but then not a - valid image. + """Some strings which are not valid base64 encoded strings are allowed + as an image without getting a "Fail" response. + + This is because Vuforia treats them as valid base64, but then + not a valid image. """ data = { "name": "example_name", diff --git a/tests/mock_vws/test_authorization_header.py b/tests/mock_vws/test_authorization_header.py index c0a710aff..3cde8cd05 100644 --- a/tests/mock_vws/test_authorization_header.py +++ b/tests/mock_vws/test_authorization_header.py @@ -88,8 +88,9 @@ class TestMalformed: @staticmethod def test_one_part_no_space(endpoint: Endpoint) -> None: - """ - A valid authorization string is two "parts" when split on a space. When + """A valid authorization string is two "parts" when split on a space. + + When a string is given which is one "part", a ``BAD_REQUEST`` or ``UNAUTHORIZED`` response is returned. """ @@ -141,8 +142,9 @@ def test_one_part_no_space(endpoint: Endpoint) -> None: @staticmethod def test_one_part_with_space(endpoint: Endpoint) -> None: - """ - A valid authorization string is two "parts" when split on a space. When + """A valid authorization string is two "parts" when split on a space. + + When a string is given which is one "part", a ``BAD_REQUEST`` or ``UNAUTHORIZED`` response is returned. """ diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index 65e0e6770..264900328 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -20,8 +20,7 @@ @pytest.mark.usefixtures("verify_mock_vuforia") class TestIncorrect: - """ - Tests for the ``Content-Length`` header set incorrectly. + """Tests for the ``Content-Length`` header set incorrectly. We cannot test what happens if ``Content-Length`` is removed from a prepared request because ``requests-mock`` behaves differently to diff --git a/tests/mock_vws/test_database_summary.py b/tests/mock_vws/test_database_summary.py index 3862e1a72..cf43d5a1b 100644 --- a/tests/mock_vws/test_database_summary.py +++ b/tests/mock_vws/test_database_summary.py @@ -54,9 +54,8 @@ def _wait_for_image_numbers( failed_images: int, processing_images: int, ) -> None: - """ - Wait for the number of images in various categories of the database summary - to match the expected given numbers. + """Wait for the number of images in various categories of the database + summary to match the expected given numbers. Args: vws_client: The client to use to connect to Vuforia. @@ -238,14 +237,13 @@ def test_deleted( class TestProcessingImages: - """ - Tests for processing images. + """Tests for processing images. - These tests are run only on the mock, and not the real implementation. - - This is because the real implementation is not reliable. - This is a documented difference between the mock and the real + These tests are run only on the mock, and not the real implementation. + + This is because the real implementation is not reliable. This is a + documented difference between the mock and the real implementation. """ @staticmethod @@ -288,8 +286,8 @@ class TestQuotas: @staticmethod def test_quotas(vws_client: VWS) -> None: - """ - Quotas are included in the database summary. + """Quotas are included in the database summary. + These match the quotas given for a free license. """ report = vws_client.get_database_summary_report() @@ -313,12 +311,11 @@ def test_query_request( high_quality_image: io.BytesIO, vws_client: VWS, ) -> None: - """ - The ``*_recos`` counts seem to be delayed by a significant amount of + """The ``*_recos`` counts seem to be delayed by a significant amount of time. - We therefore test that they exist, are integers and do not change - between quick requests. + We therefore test that they exist, are integers and do not + change between quick requests. """ target_id = vws_client.add_target( name=uuid.uuid4().hex, diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 827d2379e..4556ca53d 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -96,14 +96,13 @@ def test_no_date_header(endpoint: Endpoint) -> None: @pytest.mark.usefixtures("verify_mock_vuforia") class TestFormat: """ - Tests for what happens when the `Date` header is not in the - expected format. + Tests for what happens when the `Date` header is not in the expected + format. """ @staticmethod def test_incorrect_date_format(endpoint: Endpoint) -> None: - """ - A `BAD_REQUEST` response is returned when the date given in the date + """A `BAD_REQUEST` response is returned when the date given in the date header is not in the expected format (RFC 1123) to VWS API. An `UNAUTHORIZED` response is returned to the VWQ API. @@ -167,19 +166,18 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: @pytest.mark.usefixtures("verify_mock_vuforia") class TestSkewedTime: """ - Tests for what happens when the `Date` header is given with an - unexpected time. + Tests for what happens when the `Date` header is given with an unexpected + time. """ @staticmethod def test_date_out_of_range_after(endpoint: Endpoint) -> None: - """ - If the date header is more than five minutes (target API) or 65 minutes - (query API) after the request is sent, a `FORBIDDEN` response + """If the date header is more than five minutes (target API) or 65 + minutes (query API) after the request is sent, a `FORBIDDEN` response is returned. - Because there is a small delay in sending requests and Vuforia isn't - consistent, some leeway is given. + Because there is a small delay in sending requests and Vuforia + isn't consistent, some leeway is given. """ netloc = urlparse(url=endpoint.base_url).netloc skew = { @@ -250,13 +248,12 @@ def test_date_out_of_range_after(endpoint: Endpoint) -> None: @staticmethod def test_date_out_of_range_before(endpoint: Endpoint) -> None: - """ - If the date header is more than five minutes (target API) or 65 minutes - (query API) before the request is sent, a `FORBIDDEN` response + """If the date header is more than five minutes (target API) or 65 + minutes (query API) before the request is sent, a `FORBIDDEN` response is returned. - Because there is a small delay in sending requests and Vuforia isn't - consistent, some leeway is given. + Because there is a small delay in sending requests and Vuforia + isn't consistent, some leeway is given. """ netloc = urlparse(url=endpoint.base_url).netloc skew = { @@ -327,12 +324,11 @@ def test_date_out_of_range_before(endpoint: Endpoint) -> None: @staticmethod def test_date_in_range_after(endpoint: Endpoint) -> None: - """ - If a date header is within five minutes after the request is sent, no - error is returned. + """If a date header is within five minutes after the request is sent, + no error is returned. - Because there is a small delay in sending requests and Vuforia isn't - consistent, some leeway is given. + Because there is a small delay in sending requests and Vuforia + isn't consistent, some leeway is given. """ netloc = urlparse(url=endpoint.base_url).netloc skew = { @@ -391,12 +387,11 @@ def test_date_in_range_after(endpoint: Endpoint) -> None: @staticmethod def test_date_in_range_before(endpoint: Endpoint) -> None: - """ - If a date header is within five minutes before the request is sent, no - error is returned. + """If a date header is within five minutes before the request is sent, + no error is returned. - Because there is a small delay in sending requests and Vuforia isn't - consistent, some leeway is given. + Because there is a small delay in sending requests and Vuforia + isn't consistent, some leeway is given. """ netloc = urlparse(url=endpoint.base_url).netloc skew = { diff --git a/tests/mock_vws/test_delete_target.py b/tests/mock_vws/test_delete_target.py index 3eaa8ab68..755d9b24c 100644 --- a/tests/mock_vws/test_delete_target.py +++ b/tests/mock_vws/test_delete_target.py @@ -24,8 +24,7 @@ class TestDelete: @staticmethod def test_no_wait(target_id: str, vws_client: VWS) -> None: - """ - When attempting to delete a target immediately after creating it, a + """When attempting to delete a target immediately after creating it, a `FORBIDDEN` response is returned. This is because the target goes into a processing state. diff --git a/tests/mock_vws/test_docker.py b/tests/mock_vws/test_docker.py index 8fd62fe32..9f254b126 100644 --- a/tests/mock_vws/test_docker.py +++ b/tests/mock_vws/test_docker.py @@ -54,8 +54,7 @@ def wait_for_health_check(container: Container) -> None: @beartype @pytest.fixture(name="custom_bridge_network") def fixture_custom_bridge_network() -> Iterator[Network]: - """ - Yield a custom bridge network which containers can connect to. + """Yield a custom bridge network which containers can connect to. This also cleans up all containers connected to the network and the network after the test. diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index 0f9eda995..a10f4e82c 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -244,14 +244,18 @@ def test_delete_database() -> None: class TestQueryImageMatchers: - """Tests for query image matchers.""" + """ + Tests for query image matchers. + """ @staticmethod def test_exact_match( high_quality_image: io.BytesIO, monkeypatch: pytest.MonkeyPatch, ) -> None: - """The exact matcher matches only exactly the same images.""" + """ + The exact matcher matches only exactly the same images. + """ monkeypatch.setenv(name="QUERY_IMAGE_MATCHER", value="exact") database = VuforiaDatabase() @@ -295,7 +299,9 @@ def test_structural_similarity_matcher( different_high_quality_image: io.BytesIO, monkeypatch: pytest.MonkeyPatch, ) -> None: - """The structural similarity matcher matches similar images.""" + """ + The structural similarity matcher matches similar images. + """ monkeypatch.setenv( name="QUERY_IMAGE_MATCHER", value="structural_similarity", @@ -342,14 +348,18 @@ def test_structural_similarity_matcher( class TestDuplicatesImageMatchers: - """Tests for duplicates image matchers.""" + """ + Tests for duplicates image matchers. + """ @staticmethod def test_exact_match( high_quality_image: io.BytesIO, monkeypatch: pytest.MonkeyPatch, ) -> None: - """The exact matcher matches only exactly the same images.""" + """ + The exact matcher matches only exactly the same images. + """ monkeypatch.setenv(name="DUPLICATES_IMAGE_MATCHER", value="exact") database = VuforiaDatabase() vws_client = VWS( @@ -398,7 +408,9 @@ def test_structural_similarity_matcher( high_quality_image: io.BytesIO, monkeypatch: pytest.MonkeyPatch, ) -> None: - """The structural similarity matcher matches similar images.""" + """ + The structural similarity matcher matches similar images. + """ monkeypatch.setenv( name="DUPLICATES_IMAGE_MATCHER", value="structural_similarity", @@ -437,14 +449,18 @@ def test_structural_similarity_matcher( class TestTargetRaters: - """Tests for using target raters.""" + """ + Tests for using target raters. + """ @staticmethod def test_default( corrupted_image_file: io.BytesIO, high_quality_image: io.BytesIO, ) -> None: - """By default, the BRISQUE target rater is used.""" + """ + By default, the BRISQUE target rater is used. + """ database = VuforiaDatabase() databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" requests.post(url=databases_url, json=database.to_dict(), timeout=30) @@ -494,7 +510,9 @@ def test_brisque( corrupted_image_file: io.BytesIO, high_quality_image: io.BytesIO, ) -> None: - """It is possible to use the BRISQUE target rater.""" + """ + It is possible to use the BRISQUE target rater. + """ monkeypatch.setenv(name="TARGET_RATER", value="brisque") database = VuforiaDatabase() @@ -545,7 +563,9 @@ def test_perfect( monkeypatch: pytest.MonkeyPatch, high_quality_image: io.BytesIO, ) -> None: - """It is possible to use the perfect target rater.""" + """ + It is possible to use the perfect target rater. + """ monkeypatch.setenv(name="TARGET_RATER", value="perfect") database = VuforiaDatabase() databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" @@ -584,7 +604,9 @@ def test_random( monkeypatch: pytest.MonkeyPatch, high_quality_image: io.BytesIO, ) -> None: - """It is possible to use the random target rater.""" + """ + It is possible to use the random target rater. + """ monkeypatch.setenv(name="TARGET_RATER", value="random") database = VuforiaDatabase() diff --git a/tests/mock_vws/test_get_duplicates.py b/tests/mock_vws/test_get_duplicates.py index 82bc7054c..671c90d58 100644 --- a/tests/mock_vws/test_get_duplicates.py +++ b/tests/mock_vws/test_get_duplicates.py @@ -156,8 +156,7 @@ def test_active_flag( high_quality_image: io.BytesIO, vws_client: VWS, ) -> None: - """ - Targets with `active_flag` set to `False` can have duplicates. + """Targets with `active_flag` set to `False` can have duplicates. Targets with `active_flag` set to `False` are not found as duplicates. https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#check @@ -211,8 +210,8 @@ def test_processing( high_quality_image: io.BytesIO, vws_client: VWS, ) -> None: - """ - If a target is in the processing state, it can have duplicates. + """If a target is in the processing state, it can have duplicates. + Targets can have duplicates in the processing state. """ processed_target_id = vws_client.add_target( diff --git a/tests/mock_vws/test_get_target.py b/tests/mock_vws/test_get_target.py index cbc17474f..99fd6a1d4 100644 --- a/tests/mock_vws/test_get_target.py +++ b/tests/mock_vws/test_get_target.py @@ -1,5 +1,4 @@ -""" -Tests for getting a target record. +"""Tests for getting a target record. https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#target-record """ @@ -84,13 +83,13 @@ def test_success_status( image_file_success_state_low_rating: io.BytesIO, vws_client: VWS, ) -> None: - """ - When a random, large enough image is given, the status changes from + """When a random, large enough image is given, the status changes from 'processing' to 'success' after some time. - The mock is much more lenient than the real implementation of VWS. - The test image does not prove that what is counted as a success in the - mock will be counted as a success in the real implementation. + The mock is much more lenient than the real implementation of + VWS. The test image does not prove that what is counted as a + success in the mock will be counted as a success in the real + implementation. """ target_id = vws_client.add_target( name="example", diff --git a/tests/mock_vws/test_invalid_given_id.py b/tests/mock_vws/test_invalid_given_id.py index ed16bb2f1..7857868e8 100644 --- a/tests/mock_vws/test_invalid_given_id.py +++ b/tests/mock_vws/test_invalid_given_id.py @@ -1,6 +1,6 @@ """ -Tests for passing invalid target IDs to endpoints which -require a target ID to be given. +Tests for passing invalid target IDs to endpoints which require a target ID to +be given. """ from http import HTTPStatus @@ -17,8 +17,8 @@ @pytest.mark.usefixtures("verify_mock_vuforia") class TestInvalidGivenID: """ - Tests for giving an invalid ID to endpoints which require a target ID to - be given. + Tests for giving an invalid ID to endpoints which require a target ID to be + given. """ @staticmethod diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index cbf1f92a3..84457a62f 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -1,5 +1,4 @@ -""" -Tests for the mock of the query endpoint. +"""Tests for the mock of the query endpoint. https://developer.vuforia.com/library/web-api/vuforia-query-web-api. """ @@ -92,8 +91,7 @@ def _query( vuforia_database: VuforiaDatabase, body: dict[str, Any], ) -> Response: - """ - Make a request to the endpoint to make an image recognition query. + """Make a request to the endpoint to make an image recognition query. Args: vuforia_database: The credentials to use to connect to @@ -777,8 +775,7 @@ def test_extra_fields( def test_missing_image_and_extra_fields( vuforia_database: VuforiaDatabase, ) -> None: - """ - If extra fields are given and no image field is given, a + """If extra fields are given and no image field is given, a ``BAD_REQUEST`` response is returned. The extra field error takes precedence. @@ -851,11 +848,10 @@ def test_valid_accepted( vuforia_database: VuforiaDatabase, num_results: int | bytes, ) -> None: - """ - Numbers between 1 and 50 are valid inputs. + """Numbers between 1 and 50 are valid inputs. - We assert that the response is a success, but not that the maximum - number of results is enforced. + We assert that the response is a success, but not that the + maximum number of results is enforced. This is because uploading 50 images would be very slow. @@ -906,9 +902,8 @@ def test_out_of_range( num_results: int, cloud_reco_client: CloudRecoService, ) -> None: - """ - An error is returned if ``max_num_results`` is given as an integer out - of the range (1, 50). + """An error is returned if ``max_num_results`` is given as an integer + out of the range (1, 50). The documentation at https://developer.vuforia.com/library/web-api/vuforia-query-web-api. @@ -947,12 +942,11 @@ def test_invalid_type( vuforia_database: VuforiaDatabase, num_results: bytes, ) -> None: - """ - An error is returned if ``max_num_results`` is given as something other - than an integer. + """An error is returned if ``max_num_results`` is given as something + other than an integer. - Integers greater than 2147483647 are not considered integers because - they are bigger than Java's maximum integer. + Integers greater than 2147483647 are not considered integers + because they are bigger than Java's maximum integer. """ image_content = high_quality_image.getvalue() body = { @@ -1817,10 +1811,10 @@ def test_updated_target( vws_client: VWS, cloud_reco_client: CloudRecoService, ) -> None: - """ - After a target is updated, only the new image can be matched. - The match result includes the updated name, timestamp and application - metadata. + """After a target is updated, only the new image can be matched. + + The match result includes the updated name, timestamp and + application metadata. """ metadata = b"example_metadata" metadata_encoded = base64.b64encode(s=metadata).decode( @@ -1980,8 +1974,7 @@ def test_status_failed( @pytest.mark.usefixtures("verify_mock_vuforia") class TestDateFormats: - """ - Tests for various date formats. + """Tests for various date formats. The date format for the VWS API as per https://library.vuforia.com/articles/Training/Using-the-VWS-API.html must @@ -2012,11 +2005,10 @@ def test_date_formats( *, include_tz: bool, ) -> None: - """ - Test various date formats which are known to be accepted. + """Test various date formats which are known to be accepted. - We expect that more formats than this will be accepted. - These are the accepted ones we know of at the time of writing. + We expect that more formats than this will be accepted. These + are the accepted ones we know of at the time of writing. """ image_content = high_quality_image.getvalue() body = {"image": ("image.jpeg", image_content, "image/jpeg")} diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index 5c3fb8928..0da5d1789 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -32,14 +32,15 @@ def _not_exact_matcher( first_image_content: bytes, second_image_content: bytes, ) -> bool: - """A matcher which returns True if the images are not the same.""" + """ + A matcher which returns True if the images are not the same. + """ return first_image_content != second_image_content @beartype def request_unmocked_address() -> None: - """ - Make a request, using `requests` to an unmocked, free local address. + """Make a request, using `requests` to an unmocked, free local address. Raises: requests.exceptions.ConnectionError: This is expected as there is @@ -79,8 +80,8 @@ class TestRealHTTP: @staticmethod def test_default() -> None: """ - By default, the mock stops any requests made with `requests` to - non-Vuforia addresses, but not to mocked Vuforia endpoints. + By default, the mock stops any requests made with `requests` to non- + Vuforia addresses, but not to mocked Vuforia endpoints. """ with MockVWS(): with pytest.raises( @@ -451,11 +452,15 @@ def test_duplicate_keys() -> None: class TestQueryImageMatchers: - """Tests for query image matchers.""" + """ + Tests for query image matchers. + """ @staticmethod def test_exact_match(high_quality_image: io.BytesIO) -> None: - """The exact matcher matches only exactly the same images.""" + """ + The exact matcher matches only exactly the same images. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, @@ -491,7 +496,9 @@ def test_exact_match(high_quality_image: io.BytesIO) -> None: @staticmethod def test_custom_matcher(high_quality_image: io.BytesIO) -> None: - """It is possible to use a custom matcher.""" + """ + It is possible to use a custom matcher. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, @@ -530,7 +537,9 @@ def test_structural_similarity_matcher( high_quality_image: io.BytesIO, different_high_quality_image: io.BytesIO, ) -> None: - """The structural similarity matcher matches similar images.""" + """ + The structural similarity matcher matches similar images. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, @@ -573,11 +582,15 @@ def test_structural_similarity_matcher( class TestDuplicatesImageMatchers: - """Tests for duplicates image matchers.""" + """ + Tests for duplicates image matchers. + """ @staticmethod def test_exact_match(high_quality_image: io.BytesIO) -> None: - """The exact matcher matches only exactly the same images.""" + """ + The exact matcher matches only exactly the same images. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, @@ -621,7 +634,9 @@ def test_exact_match(high_quality_image: io.BytesIO) -> None: @staticmethod def test_custom_matcher(high_quality_image: io.BytesIO) -> None: - """It is possible to use a custom matcher.""" + """ + It is possible to use a custom matcher. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, @@ -667,7 +682,9 @@ def test_custom_matcher(high_quality_image: io.BytesIO) -> None: def test_structural_similarity_matcher( high_quality_image: io.BytesIO, ) -> None: - """The structural similarity matcher matches similar images.""" + """ + The structural similarity matcher matches similar images. + """ database = VuforiaDatabase() vws_client = VWS( server_access_key=database.server_access_key, diff --git a/tests/mock_vws/test_target_summary.py b/tests/mock_vws/test_target_summary.py index f9c1a3b98..f1d61c237 100644 --- a/tests/mock_vws/test_target_summary.py +++ b/tests/mock_vws/test_target_summary.py @@ -81,9 +81,8 @@ def test_after_processing( image_fixture_name: str, expected_status: TargetStatuses, ) -> None: - """ - After processing is completed, the tracking rating is in the range of - 0 to 5. + """After processing is completed, the tracking rating is in the range + of 0 to 5. The documentation says: diff --git a/tests/mock_vws/test_update_target.py b/tests/mock_vws/test_update_target.py index cd587ba60..4cf4911c7 100644 --- a/tests/mock_vws/test_update_target.py +++ b/tests/mock_vws/test_update_target.py @@ -42,8 +42,7 @@ def _update_target( target_id: str, content_type: str = "application/json", ) -> Response: - """ - Make a request to the endpoint to update a target. + """Make a request to the endpoint to update a target. Args: vws_client: The client to use to connect to Vuforia. @@ -489,8 +488,7 @@ def test_name_valid( target_id: str, vws_client: VWS, ) -> None: - """ - A target's name must be a string of length 0 < N < 65. + """A target's name must be a string of length 0 < N < 65. We test characters out of range in another test as that gives a different error. @@ -625,8 +623,7 @@ def test_same_name_given( @pytest.mark.usefixtures("verify_mock_vuforia") class TestImage: - """ - Tests for the image parameter. + """Tests for the image parameter. The specification for images is documented at https://library.vuforia.com/features/images/image-targets.html. @@ -655,9 +652,9 @@ def test_bad_image_format_or_color_space( vws_client: VWS, ) -> None: """ - A `BAD_IMAGE` response is returned if an image which is not a JPEG - or PNG file is given, or if the given image is not in the greyscale or - RGB color space. + A `BAD_IMAGE` response is returned if an image which is not a JPEG or + PNG file is given, or if the given image is not in the greyscale or RGB + color space. """ vws_client.wait_for_target_processed(target_id=target_id) with pytest.raises(expected_exception=BadImageError) as exc: @@ -746,11 +743,11 @@ def test_not_base64_encoded_processable( target_id: str, not_base64_encoded_processable: str, ) -> None: - """ - Some strings which are not valid base64 encoded strings are allowed as - an image without getting a "Fail" response. - This is because Vuforia treats them as valid base64, but then not a - valid image. + """Some strings which are not valid base64 encoded strings are allowed + as an image without getting a "Fail" response. + + This is because Vuforia treats them as valid base64, but then + not a valid image. """ vws_client.wait_for_target_processed(target_id=target_id) @@ -847,12 +844,11 @@ def test_rating_can_change( high_quality_image: io.BytesIO, vws_client: VWS, ) -> None: - """ - If the target is updated with an image of different quality, the + """If the target is updated with an image of different quality, the tracking rating can change. - "quality" refers to Vuforia's internal rating system. - The mock randomly assigns a quality and makes sure that the new quality + "quality" refers to Vuforia's internal rating system. The mock + randomly assigns a quality and makes sure that the new quality is different to the old quality. """ target_id = vws_client.add_target( diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 448f3e902..3edc7507e 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -19,8 +19,7 @@ @dataclass(frozen=True) class Endpoint: - """ - Details of endpoints to be called in tests. + """Details of endpoints to be called in tests. Args: prepared_request: A request to make which would be successful. @@ -93,8 +92,7 @@ def make_image_file( width: int, height: int, ) -> io.BytesIO: - """ - Return an image file in the given format and color space. + """Return an image file in the given format and color space. The image file is filled with randomly colored pixels. diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index 76deda009..2ad4752cf 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -23,8 +23,7 @@ def assert_vws_failure( status_code: int, result_code: ResultCodes, ) -> None: - """ - Assert that a VWS failure response is as expected. + """Assert that a VWS failure response is as expected. Args: response: The response returned by a request to VWS. @@ -51,9 +50,8 @@ def assert_valid_date_header( *, response: Response, ) -> None: - """ - Assert that a response includes a `Date` header which is within two minutes - of "now". + """Assert that a response includes a `Date` header which is within two + minutes of "now". Args: response: The response returned by a request to a Vuforia service. @@ -86,8 +84,7 @@ def assert_valid_transaction_id( *, response: Response, ) -> None: - """ - Assert that a response includes a valid transaction ID. + """Assert that a response includes a valid transaction ID. Args: response: The response returned by a request to a Vuforia service. @@ -103,8 +100,7 @@ def assert_valid_transaction_id( @beartype def assert_json_separators(*, response: Response) -> None: - """ - Assert that a JSON response is formatted correctly. + """Assert that a JSON response is formatted correctly. Args: response: The response returned by a request to a Vuforia service. @@ -125,8 +121,7 @@ def assert_vws_response( status_code: int, result_code: ResultCodes, ) -> None: - """ - Assert that a VWS response is as expected, at least in part. + """Assert that a VWS response is as expected, at least in part. https://developer.vuforia.com/library/web-api/cloud-targets-web-services-api#result-codes implies that the expected status code can be worked out from the result @@ -174,8 +169,7 @@ def assert_vws_response( @beartype def assert_query_success(*, response: Response) -> None: - """ - Assert that the given response is a success response for performing an + """Assert that the given response is a success response for performing an image recognition query. Raises: @@ -235,8 +229,7 @@ def assert_vwq_failure( www_authenticate: str | None, connection: str, ) -> None: - """ - Assert that a VWQ failure response is as expected. + """Assert that a VWQ failure response is as expected. Args: response: The response returned by a request to VWQ. diff --git a/tests/mock_vws/utils/retries.py b/tests/mock_vws/utils/retries.py index 02e980e0b..6d7a7d491 100644 --- a/tests/mock_vws/utils/retries.py +++ b/tests/mock_vws/utils/retries.py @@ -1,4 +1,6 @@ -"""Helpers for retrying requests to VWS.""" +""" +Helpers for retrying requests to VWS. +""" from tenacity import retry from tenacity.retry import retry_if_exception_type diff --git a/tests/mock_vws/utils/too_many_requests.py b/tests/mock_vws/utils/too_many_requests.py index c08063dd2..2cb2b6863 100644 --- a/tests/mock_vws/utils/too_many_requests.py +++ b/tests/mock_vws/utils/too_many_requests.py @@ -12,9 +12,8 @@ @beartype def handle_server_errors(*, response: Response) -> None: - """ - Raise errors if the response is a 429 or 5xx. - This is useful for retrying tests based on the exceptions they raise. + """Raise errors if the response is a 429 or 5xx. This is useful for + retrying tests based on the exceptions they raise. Raises: vws.exceptions.vws_exceptions.TooManyRequestsError: The response is a From dcac512583113e16dbe96709b691f02adb012c66 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 8 Oct 2024 22:00:47 +0100 Subject: [PATCH 175/331] Sort dependencies --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 687d270ac..58463acf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,6 +60,7 @@ optional-dependencies.dev = [ "dirty-equals==0.8.0", "doc8==1.1.1", "doccmd==2024.10.8.12", + "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", "freezegun==1.5.1", @@ -104,7 +105,6 @@ optional-dependencies.dev = [ "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", - "docformatter==1.7.5", ] optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" From 1e1c056ccc147a69750b6628aa0f178b1287f9ac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 06:01:12 +0000 Subject: [PATCH 176/331] Bump pre-commit from 4.0.0 to 4.0.1 Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 4.0.0 to 4.0.1. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v4.0.0...v4.0.1) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7eac46740..b1a952ec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy==1.11.2", - "pre-commit==4.0.0", + "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", "pylint==3.3.1", From 812e919b2e853afa109c02135ca3b28ee2834426 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 08:21:32 +0100 Subject: [PATCH 177/331] Exclude a file from formatting --- .pre-commit-config.yaml | 3 + src/mock_vws/_flask_server/target_manager.py | 64 ++++++++++---------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d7e19326..04fb35ab2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,6 +66,9 @@ repos: entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] + # We exclude target_manager.py as it includes syntax for + # generating API documentation that ``docformatter`` does not like. + exclude: "src/mock_vws/_flask_server/target_manager.py" additional_dependencies: ["uv"] - id: shellcheck diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index c31950be6..189590c45 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -32,18 +32,14 @@ @beartype class _TargetRaterChoice(StrEnum): - """ - Target rater choices. - """ + """Target rater choices.""" BRISQUE = auto() PERFECT = auto() RANDOM = auto() def to_target_rater(self) -> TargetTrackingRater: - """ - Get the target rater. - """ + """Get the target rater.""" match self: case self.BRISQUE: return BrisqueTargetTrackingRater() @@ -57,9 +53,7 @@ def to_target_rater(self) -> TargetTrackingRater: @beartype class TargetManagerSettings(BaseSettings): - """ - Settings for the Target Manager Flask app. - """ + """Settings for the Target Manager Flask app.""" target_manager_host: str = "" target_rater: _TargetRaterChoice = _TargetRaterChoice.BRISQUE @@ -71,7 +65,8 @@ class TargetManagerSettings(BaseSettings): ) @beartype def delete_database(database_name: str) -> Response: - """Delete a database. + """ + Delete a database. :status 200: The database has been deleted. """ @@ -104,29 +99,32 @@ def get_databases() -> Response: @TARGET_MANAGER_FLASK_APP.route("/databases", methods=[HTTPMethod.POST]) @beartype def create_database() -> Response: - """Create a new database. - - :reqheader Content-Type: application/json :resheader Content-Type: - application/json - - :reqjson string client_access_key: (Optional) The client access key - for the database. :reqjson string client_secret_key: (Optional) - The client secret key for the database. :reqjson string - database_name: (Optional) The name of the database. :reqjson string - server_access_key: (Optional) The server access key for the - database. :reqjson string server_secret_key: (Optional) The server - secret key for the database. :reqjson string state_name: - (Optional) The state of the database. This can be "WORKING" or - "PROJECT_INACTIVE". This defaults to "WORKING". - - :resjson string client_access_key: The client access key for the - database. :resjson string client_secret_key: The client secret key - for the database. :resjson string database_name: The database name. - :resjson string server_access_key: The server access key for the - database. :resjson string server_secret_key: The server secret key - for the database. :resjson string state_name: The database state. - This will be "WORKING" or "PROJECT_INACTIVE". :reqjsonarr targets: - The targets in the database. + """ + Create a new database. + + :reqheader Content-Type: application/json + :resheader Content-Type: application/json + + :reqjson string client_access_key: (Optional) The client access key for the + database. + :reqjson string client_secret_key: (Optional) The client secret key for the + database. + :reqjson string database_name: (Optional) The name of the database. + :reqjson string server_access_key: (Optional) The server access key for the + database. + :reqjson string server_secret_key: (Optional) The server secret key for the + database. + :reqjson string state_name: (Optional) The state of the database. This can + be "WORKING" or "PROJECT_INACTIVE". This defaults to "WORKING". + + :resjson string client_access_key: The client access key for the database. + :resjson string client_secret_key: The client secret key for the database. + :resjson string database_name: The database name. + :resjson string server_access_key: The server access key for the database. + :resjson string server_secret_key: The server secret key for the database. + :resjson string state_name: The database state. This will be "WORKING" or + "PROJECT_INACTIVE". + :reqjsonarr targets: The targets in the database. :status 201: The database has been successfully created. """ From 63c175dbd21283e2dcef9f9147fd6e915135e681 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 08:51:35 +0100 Subject: [PATCH 178/331] Add newlines to avoid docformatter ignore --- .pre-commit-config.yaml | 3 -- src/mock_vws/_flask_server/target_manager.py | 29 +++++++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 04fb35ab2..6d7e19326 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,9 +66,6 @@ repos: entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] - # We exclude target_manager.py as it includes syntax for - # generating API documentation that ``docformatter`` does not like. - exclude: "src/mock_vws/_flask_server/target_manager.py" additional_dependencies: ["uv"] - id: shellcheck diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index 189590c45..78f944eb1 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -32,14 +32,18 @@ @beartype class _TargetRaterChoice(StrEnum): - """Target rater choices.""" + """ + Target rater choices. + """ BRISQUE = auto() PERFECT = auto() RANDOM = auto() def to_target_rater(self) -> TargetTrackingRater: - """Get the target rater.""" + """ + Get the target rater. + """ match self: case self.BRISQUE: return BrisqueTargetTrackingRater() @@ -53,7 +57,9 @@ def to_target_rater(self) -> TargetTrackingRater: @beartype class TargetManagerSettings(BaseSettings): - """Settings for the Target Manager Flask app.""" + """ + Settings for the Target Manager Flask app. + """ target_manager_host: str = "" target_rater: _TargetRaterChoice = _TargetRaterChoice.BRISQUE @@ -65,8 +71,7 @@ class TargetManagerSettings(BaseSettings): ) @beartype def delete_database(database_name: str) -> Response: - """ - Delete a database. + """Delete a database. :status 200: The database has been deleted. """ @@ -99,31 +104,41 @@ def get_databases() -> Response: @TARGET_MANAGER_FLASK_APP.route("/databases", methods=[HTTPMethod.POST]) @beartype def create_database() -> Response: - """ - Create a new database. + """Create a new database. :reqheader Content-Type: application/json :resheader Content-Type: application/json :reqjson string client_access_key: (Optional) The client access key for the database. + :reqjson string client_secret_key: (Optional) The client secret key for the database. + :reqjson string database_name: (Optional) The name of the database. + :reqjson string server_access_key: (Optional) The server access key for the database. + :reqjson string server_secret_key: (Optional) The server secret key for the database. + :reqjson string state_name: (Optional) The state of the database. This can be "WORKING" or "PROJECT_INACTIVE". This defaults to "WORKING". :resjson string client_access_key: The client access key for the database. + :resjson string client_secret_key: The client secret key for the database. + :resjson string database_name: The database name. + :resjson string server_access_key: The server access key for the database. + :resjson string server_secret_key: The server secret key for the database. + :resjson string state_name: The database state. This will be "WORKING" or "PROJECT_INACTIVE". + :reqjsonarr targets: The targets in the database. :status 201: The database has been successfully created. From e7f3e99e27a3e34b1ae945423b2e8ea6281394e5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 15:48:10 +0100 Subject: [PATCH 179/331] Remove checkmake - it is flaky on Windows --- .checkmake-config.ini | 2 -- .pre-commit-config.yaml | 11 ++--------- pyproject.toml | 1 + 3 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 .checkmake-config.ini diff --git a/.checkmake-config.ini b/.checkmake-config.ini deleted file mode 100644 index f2ac3c91b..000000000 --- a/.checkmake-config.ini +++ /dev/null @@ -1,2 +0,0 @@ -[minphony] -disabled = true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6d7e19326..93909c693 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,15 +33,7 @@ repos: - id: rst-inline-touching-normal - id: text-unicode-replacement-char - id: rst-backticks - - repo: https://github.com/mrtazz/checkmake.git - rev: 0.2.2 - hooks: - - id: checkmake - args: ["--config", ".checkmake-config.ini"] - - repo: https://github.com/google/yamlfmt - rev: v0.13.0 - hooks: - - id: yamlfmt + - repo: local hooks: - id: custom-linters @@ -317,3 +309,4 @@ ci: - spelling - vulture - vulture-docs + - yamlfix diff --git a/pyproject.toml b/pyproject.toml index 2108c185c..3f048e727 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -105,6 +105,7 @@ optional-dependencies.dev = [ "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", + "yamlfix==1.17.0", ] optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" From c2b7832eddffb1bb552864a061de9905ef494c45 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 15:50:07 +0100 Subject: [PATCH 180/331] Switch to yamlfix --- .github/dependabot.yml | 7 +-- .github/workflows/ci.yml | 16 +++---- .github/workflows/docker-build.yml | 2 +- .github/workflows/lint.yml | 6 +-- .github/workflows/release.yml | 15 ++++--- .github/workflows/skip-tests.yml | 16 +++---- .github/workflows/windows-ci.yml | 16 +++---- .pre-commit-config.yaml | 69 +++++++++++++++++------------- pyproject.toml | 4 ++ readthedocs.yaml | 5 +-- 10 files changed, 86 insertions(+), 70 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 64507e260..a2e641793 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,12 +1,13 @@ --- version: 2 + updates: - package-ecosystem: pip - directory: "/" + directory: / schedule: interval: daily open-pull-requests-limit: 10 - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: interval: daily diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3393483b6..2ebba1e06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: schedule: # * is a special character in YAML so you have to quote this string # Run at 1:00 every day - - cron: '0 1 * * *' + - cron: 0 1 * * * workflow_dispatch: {} # We share Vuforia credentials and therefore Vuforia databases across @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.12"] + python-version: ['3.12'] ci_pattern: - tests/mock_vws/test_query.py::TestContentType - tests/mock_vws/test_query.py::TestSuccess @@ -127,7 +127,7 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v3 - - name: "Set secrets file" + - name: Set secrets file run: | # See the "CI Setup" document for details of how this was set up. ci/decrypt_secret.sh @@ -153,7 +153,7 @@ jobs: dotnet: true haskell: true - - name: "Run tests" + - name: Run tests run: | uv run --extra=dev pytest \ -s \ @@ -167,7 +167,7 @@ jobs: env: UV_PYTHON: ${{ matrix.python-version }} - - name: "Show coverage file" + - name: Show coverage file run: | # Sometimes we have been sure that we have 100% coverage, but codecov # says otherwise. @@ -184,12 +184,12 @@ jobs: # # To work around this, we do not upload coverage data on scheduled runs. # We print the event name here to help with debugging. - - name: "Show event name" + - name: Show event name run: | echo ${{ github.event_name }} - - name: "Upload coverage to Codecov" - uses: "codecov/codecov-action@v4" + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 06a908cbb..d05815633 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -14,7 +14,7 @@ on: schedule: # * is a special character in YAML so you have to quote this string # Run at 1:00 every day - - cron: '0 1 * * *' + - cron: 0 1 * * * workflow_dispatch: {} jobs: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4fa4376f9..1d7e3e744 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,7 +10,7 @@ on: schedule: # * is a special character in YAML so you have to quote this string # Run at 1:00 every day - - cron: '0 1 * * *' + - cron: 0 1 * * * workflow_dispatch: {} jobs: @@ -20,13 +20,13 @@ jobs: strategy: matrix: - python-version: ["3.12"] + python-version: ['3.12'] steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v3 - - name: "Lint" + - name: Lint run: | uv run --extra=dev pre-commit run --all-files --hook-stage pre-commit --verbose uv run --extra=dev pre-commit run --all-files --hook-stage pre-push --verbose diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92ec54451..4e4e48812 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - python-version: ["3.12"] + python-version: ['3.12'] steps: - uses: actions/checkout@v4 @@ -30,11 +30,11 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v3 - - name: "Calver calculate version" + - name: Calver calculate version uses: StephaneBour/actions-calver@master id: calver with: - date_format: "%Y.%m.%d" + date_format: '%Y.%m.%d' release: false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -45,12 +45,13 @@ jobs: underline="$(echo "${{ steps.calver.outputs.release }}" | tr -c '\n' '-')" echo "underline=${underline}" >> "$GITHUB_OUTPUT" - - name: "Update changelog" + - name: Update changelog uses: jacobtomlinson/gha-find-replace@v3 with: find: "Next\n----" - replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n${{ steps.changelog_underline.outputs.underline }}" - include: "CHANGELOG.rst" + replace: "Next\n----\n\n${{ steps.calver.outputs.release }}\n${{ steps.changelog_underline.outputs.underline\ + \ }}" + include: CHANGELOG.rst regex: false - uses: stefanzweifel/git-auto-commit-action@v5 @@ -65,7 +66,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} custom_tag: ${{ steps.calver.outputs.release }} - tag_prefix: "" + tag_prefix: '' commit_sha: ${{ steps.commit.outputs.commit_hash }} - name: Create a GitHub release diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index b51859b9c..3c6d21a7f 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -12,7 +12,7 @@ on: schedule: # * is a special character in YAML so you have to quote this string # Run at 1:00 every day - - cron: '0 1 * * *' + - cron: 0 1 * * * workflow_dispatch: {} jobs: @@ -20,7 +20,7 @@ jobs: strategy: matrix: - python-version: ["3.12"] + python-version: ['3.12'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} @@ -34,11 +34,11 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v3 - - name: "Set secrets file" + - name: Set secrets file run: | cp ./vuforia_secrets.env.example ./vuforia_secrets.env - - name: "Run tests" + - name: Run tests run: | uv run --extra=dev pytest \ --skip-docker_build_tests \ @@ -55,7 +55,7 @@ jobs: env: UV_PYTHON: ${{ matrix.python-version }} - - name: "Show coverage file" + - name: Show coverage file run: | # Sometimes we have been sure that we have 100% coverage, but codecov # says otherwise. @@ -72,12 +72,12 @@ jobs: # # To work around this, we do not upload coverage data on scheduled runs. # We print the event name here to help with debugging. - - name: "Show event name" + - name: Show event name run: | echo ${{ github.event_name }} - - name: "Upload coverage to Codecov" - uses: "codecov/codecov-action@v4" + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index f8fb57aca..dc72a0a17 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -10,7 +10,7 @@ on: schedule: # * is a special character in YAML so you have to quote this string # Run at 1:00 every day - - cron: '0 1 * * *' + - cron: 0 1 * * * workflow_dispatch: {} jobs: @@ -18,7 +18,7 @@ jobs: strategy: matrix: - python-version: ["3.12"] + python-version: ['3.12'] platform: [windows-latest] runs-on: ${{ matrix.platform }} @@ -32,11 +32,11 @@ jobs: - name: Install uv uses: astral-sh/setup-uv@v3 - - name: "Set secrets file" + - name: Set secrets file run: | cp ./vuforia_secrets.env.example ./vuforia_secrets.env - - name: "Run tests" + - name: Run tests run: | # We use pytest-xdist to make this run much faster. # The downside is that we cannot use -s / --capture=no. @@ -44,7 +44,7 @@ jobs: env: UV_PYTHON: ${{ matrix.python-version }} - - name: "Show coverage file" + - name: Show coverage file run: | # Sometimes we have been sure that we have 100% coverage, but codecov # says otherwise. @@ -61,12 +61,12 @@ jobs: # # To work around this, we do not upload coverage data on scheduled runs. # We print the event name here to help with debugging. - - name: "Show event name" + - name: Show event name run: | echo ${{ github.event_name }} - - name: "Upload coverage to Codecov" - uses: "codecov/codecov-action@v4" + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 with: fail_ci_if_error: true # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93909c693..665b95adc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,7 @@ fail_fast: true # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_install_hook_types: [pre-commit, pre-push, commit-msg] + repos: - repo: meta hooks: @@ -43,7 +44,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: actionlint name: actionlint @@ -51,42 +52,44 @@ repos: language: python pass_filenames: false types_or: [yaml] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: docformatter name: docformatter entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 language: python types_or: [shell] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: shellcheck-docs name: shellcheck-docs - entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck --shell=bash --exclude=SC1017" + entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck + --shell=bash --exclude=SC1017" language: python types_or: [markdown, rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 language: python types_or: [shell] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: shfmt-docs name: shfmt-docs - entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt --no-pad-file --command="shfmt --write --space-redirects --indent=4" + entry: uv run --extra=dev doccmd --language=shell --language=console --skip-marker=shfmt + --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: mypy name: mypy @@ -95,7 +98,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: mypy-docs name: mypy-docs @@ -110,7 +113,7 @@ repos: entry: uv run --extra=dev -m check_manifest . language: python pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pyright name: pyright @@ -119,7 +122,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pyright-docs name: pyright-docs @@ -135,7 +138,7 @@ repos: language: python pass_filenames: false types_or: [python] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: vulture name: vulture @@ -143,7 +146,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: vulture-docs name: vulture docs @@ -151,7 +154,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pyroma name: pyroma @@ -159,14 +162,14 @@ repos: language: python pass_filenames: false types_or: [toml] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: deptry name: deptry entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pylint name: pylint @@ -174,7 +177,7 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pylint-docs name: pylint-docs @@ -188,7 +191,7 @@ repos: description: Runs hadolint Docker image to lint Dockerfiles language: docker_image types_or: [dockerfile] - stages: [manual] # Requires Docker to be running + stages: [manual] # Requires Docker to be running # We choose not to use a Python wrapper or alternative to hadolint as none # appear to be well maintained, and they require more setup than we would # want. @@ -199,35 +202,36 @@ repos: entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: ruff-check-fix-docs name: Ruff check fix docs entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: ruff-format-fix name: Ruff format entry: uv run --extra=dev -m ruff format language: python types_or: [python] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: ruff-format-fix-docs name: Ruff format docs - entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff format" + entry: uv run --extra=dev doccmd --language=python --no-pad-file --command="ruff + format" language: python types_or: [markdown, rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: doc8 name: doc8 entry: uv run --extra=dev -m doc8 language: python types_or: [rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: interrogate name: interrogate @@ -241,7 +245,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: pyproject-fmt-fix name: pyproject-fmt @@ -257,7 +261,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: spelling name: spelling @@ -266,7 +270,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] - id: docs name: Build Documentation @@ -274,7 +278,14 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: ["uv"] + additional_dependencies: [uv] + + - id: yamlfix + name: pyproject-fmt + entry: uv run --extra=dev yamlfix + language: python + types_or: [yaml] + additional_dependencies: [uv] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. diff --git a/pyproject.toml b/pyproject.toml index 3f048e727..baef325a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -461,3 +461,7 @@ ignore_decorators = [ "@*APP.before_request", "@*APP.errorhandler", ] + +[tool.yamlfix] +section_whitelines = 1 +whitelines = 1 diff --git a/readthedocs.yaml b/readthedocs.yaml index 4b8a4eb2b..bdd2bf053 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -4,14 +4,13 @@ version: 2 build: os: ubuntu-24.04 tools: - python: "3.12" + python: '3.12' python: install: - method: pip path: . - extra_requirements: - - dev + extra_requirements: [dev] sphinx: builder: html From 7080d8a679867b94b1940a1cfbb31b5ca15d0791 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 15:56:27 +0100 Subject: [PATCH 181/331] Remove yamlfmt config --- .yamlfmt | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 .yamlfmt diff --git a/.yamlfmt b/.yamlfmt deleted file mode 100644 index fbb6dd434..000000000 --- a/.yamlfmt +++ /dev/null @@ -1,5 +0,0 @@ -formatter: - include_document_start: true - retain_line_breaks_single: true - trim_trailing_whitespace: true - end_of_file_newline: true From 30c9bd6bca2b4cd4277e0e74e3e696c0090aa038 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:23:31 +0000 Subject: [PATCH 182/331] Bump pyright from 1.1.383 to 1.1.384 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.383 to 1.1.384. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.383...v1.1.384) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index baef325a1..2a151ec1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.2.4", - "pyright==1.1.383", + "pyright==1.1.384", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 55b10e192f1ef800ee576cc2b4e606e0ad57f288 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:23:57 +0000 Subject: [PATCH 183/331] Bump check-manifest from 0.49 to 0.50 Bumps [check-manifest](https://github.com/mgedmin/check-manifest) from 0.49 to 0.50. - [Changelog](https://github.com/mgedmin/check-manifest/blob/master/CHANGES.rst) - [Commits](https://github.com/mgedmin/check-manifest/compare/0.49...0.50) --- updated-dependencies: - dependency-name: check-manifest dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index baef325a1..2e204fbc3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ dependencies = [ ] optional-dependencies.dev = [ "actionlint-py==1.7.3.17", - "check-manifest==0.49", + "check-manifest==0.50", "check-wheel-contents==0.6.0", "deptry==0.20.0", "dirty-equals==0.8.0", From 7b5160df7decbf55ae573f3d3feb9d5e0ca9ea21 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 9 Oct 2024 22:49:57 +0100 Subject: [PATCH 184/331] Add Windows as a supported platform --- .gitattributes | 1 + .github/workflows/lint.yml | 7 +++++-- pyproject.toml | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitattributes b/.gitattributes index 00a7b00c9..ee0f759ba 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ .git_archival.txt export-subst +* text=auto eol=lf diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1d7e3e744..a24292376 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,13 +16,16 @@ on: jobs: build: - runs-on: ubuntu-latest - strategy: matrix: python-version: ['3.12'] + platform: [ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.platform }} + steps: - uses: actions/checkout@v4 + - name: Install uv uses: astral-sh/setup-uv@v3 diff --git a/pyproject.toml b/pyproject.toml index 1ee0a0786..6cad37348 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ classifiers = [ "Environment :: Web Environment", "Framework :: Pytest", "License :: OSI Approved :: MIT License", + "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.12", From a3e9d39571927d9e51cc43db54adcaa20fb650c2 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 08:31:54 +0100 Subject: [PATCH 185/331] Try removing $ --- docs/source/docker.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/source/docker.rst b/docs/source/docker.rst index e46c5d146..af2fe58e8 100644 --- a/docs/source/docker.rst +++ b/docs/source/docker.rst @@ -20,22 +20,25 @@ The VWS and VWQ containers must point to the target manager container using the Creating containers ^^^^^^^^^^^^^^^^^^^ -.. code-block:: console +.. code-block:: shell + + docker network create -d bridge vws-bridge-network - $ docker network create -d bridge vws-bridge-network - $ docker run \ + docker run \ --detach \ --publish 5005:5000 \ --name vuforia-target-manager-mock \ --network vws-bridge-network \ adamtheturtle/vuforia-target-manager-mock - $ docker run \ + + docker run \ --detach \ --publish 5006:5000 \ -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ --network vws-bridge-network \ adamtheturtle/vuforia-vws-mock - $ docker run \ + + docker run \ --detach \ --publish 5007:5000 \ -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ From a001ff646278f5c71ac0df99b329d9d6e062ecda Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 08:43:40 +0100 Subject: [PATCH 186/331] For now, ignore false positive error --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 665b95adc..a44cb7e05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,8 +70,9 @@ repos: - id: shellcheck-docs name: shellcheck-docs + # We exclude SC2215 as it is a false positive for an unknown reason on Windows. entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck - --shell=bash --exclude=SC1017" + --shell=bash --exclude=SC1017 --exclude=SC2215" language: python types_or: [markdown, rst] additional_dependencies: [uv] From 452060f61f6c5b1259f7b6c6825d85eb444da899 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 08:56:49 +0100 Subject: [PATCH 187/331] Try using hadolint official pre-commit hook --- .pre-commit-config.yaml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a44cb7e05..f306789da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,6 +35,11 @@ repos: - id: text-unicode-replacement-char - id: rst-backticks + - repo: https://github.com/hadolint/hadolint + rev: v2.10.0 + hooks: + - id: hadolint + - repo: local hooks: - id: custom-linters @@ -187,17 +192,6 @@ repos: stages: [manual] types_or: [markdown, rst, python, toml] - - id: hadolint-docker - name: Lint Dockerfiles - description: Runs hadolint Docker image to lint Dockerfiles - language: docker_image - types_or: [dockerfile] - stages: [manual] # Requires Docker to be running - # We choose not to use a Python wrapper or alternative to hadolint as none - # appear to be well maintained, and they require more setup than we would - # want. - entry: ghcr.io/hadolint/hadolint hadolint - - id: ruff-check-fix name: Ruff check fix entry: uv run --extra=dev -m ruff check --fix From f9f745c7f62d85780cae64bed2b7d92c739b39d1 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 08:57:26 +0100 Subject: [PATCH 188/331] Bump hadolint --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f306789da..c9c080917 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,7 +36,7 @@ repos: - id: rst-backticks - repo: https://github.com/hadolint/hadolint - rev: v2.10.0 + rev: v2.12.0 hooks: - id: hadolint From abecc86e4b778be22d5ea266ffe87a1eeb21587a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 09:01:28 +0100 Subject: [PATCH 189/331] Try a hadolint pre-commit hook which downloads the binary --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9c080917..0968c0ee4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,8 +35,8 @@ repos: - id: text-unicode-replacement-char - id: rst-backticks - - repo: https://github.com/hadolint/hadolint - rev: v2.12.0 + - repo: https://github.com/AleksaC/hadolint-py + rev: v2.12.1b3 hooks: - id: hadolint From 28495fd848f13512e3e9389201fb3faaf6080bb5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 10 Oct 2024 09:04:19 +0100 Subject: [PATCH 190/331] Revert bad attempt at fixing shellcheck issue --- docs/source/docker.rst | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/docs/source/docker.rst b/docs/source/docker.rst index af2fe58e8..e46c5d146 100644 --- a/docs/source/docker.rst +++ b/docs/source/docker.rst @@ -20,25 +20,22 @@ The VWS and VWQ containers must point to the target manager container using the Creating containers ^^^^^^^^^^^^^^^^^^^ -.. code-block:: shell - - docker network create -d bridge vws-bridge-network +.. code-block:: console - docker run \ + $ docker network create -d bridge vws-bridge-network + $ docker run \ --detach \ --publish 5005:5000 \ --name vuforia-target-manager-mock \ --network vws-bridge-network \ adamtheturtle/vuforia-target-manager-mock - - docker run \ + $ docker run \ --detach \ --publish 5006:5000 \ -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ --network vws-bridge-network \ adamtheturtle/vuforia-vws-mock - - docker run \ + $ docker run \ --detach \ --publish 5007:5000 \ -e TARGET_MANAGER_BACKEND=vuforia-target-manager-mock:5000 \ From 18b3e6fdab5fd093685379488bfb4a4cf2ec943c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 05:17:20 +0000 Subject: [PATCH 191/331] Bump sphinx-toolbox from 3.8.0 to 3.8.1 Bumps [sphinx-toolbox](https://github.com/sphinx-toolbox/sphinx-toolbox) from 3.8.0 to 3.8.1. - [Release notes](https://github.com/sphinx-toolbox/sphinx-toolbox/releases) - [Changelog](https://github.com/sphinx-toolbox/sphinx-toolbox/blob/master/doc-source/changelog.rst) - [Commits](https://github.com/sphinx-toolbox/sphinx-toolbox/compare/v3.8.0...v3.8.1) --- updated-dependencies: - dependency-name: sphinx-toolbox dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6cad37348..998fc2c48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", "sphinx-substitution-extensions==2024.8.6", - "sphinx-toolbox==3.8.0", + "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", "sybil==8.0.0", From 2e366844312840f51f4021d9235ff6d3e7c85191 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 08:47:48 +0000 Subject: [PATCH 192/331] Bump sphinx from 8.0.2 to 8.1.0 Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 8.0.2 to 8.1.0. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v8.0.2...v8.1.0) --- updated-dependencies: - dependency-name: sphinx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 998fc2c48..319ffabab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ optional-dependencies.dev = [ # use it to lint shell commands in GitHub workflow files. "shellcheck-py==0.10.0.1", "shfmt-py==3.7.0.1", - "sphinx==8.0.2", + "sphinx==8.1.0", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", "sphinx-substitution-extensions==2024.8.6", From f8d5d1d26ce719a2a26f98baa32c788a55cc166b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 11 Oct 2024 10:10:00 +0100 Subject: [PATCH 193/331] Use max supported Python version for explicit pyproject-fmt configuration --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 998fc2c48..39b9adc79 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -340,6 +340,7 @@ DEP002 = [ [tool.pyproject-fmt] indent = 4 keep_full_version = true +max_supported_python = "3.12" [tool.pytest.ini_options] From 70623039359667dbd941a253259c137ea7a84a76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:15:59 +0000 Subject: [PATCH 194/331] Bump pyproject-fmt from 2.2.4 to 2.3.0 Bumps [pyproject-fmt](https://github.com/tox-dev/pyproject-fmt) from 2.2.4 to 2.3.0. - [Release notes](https://github.com/tox-dev/pyproject-fmt/releases) - [Commits](https://github.com/tox-dev/pyproject-fmt/compare/2.2.4...2.3.0) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b256ede0a..7dc34b4dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ optional-dependencies.dev = [ "pyenchant==3.3.0rc1", "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", - "pyproject-fmt==2.2.4", + "pyproject-fmt==2.3.0", "pyright==1.1.384", "pyroma==4.2", "pytest==8.3.3", From 1f56a272f0a034f3d6b542c2ac2721ae218f6f26 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 11 Oct 2024 13:24:57 +0100 Subject: [PATCH 195/331] Remove workaround for CRLF line endings now we tell git to check out with lf --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b256ede0a..6760b3568 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -406,8 +406,7 @@ ignore_path = [ "./src/*/_setuptools_scm_version.txt", ] -# See https://github.com/PyCQA/doc8/issues/78 -ignore = [ "D004" ] + [tool.vulture] # Ideally we would limit the paths to the source code where we want to ignore names, From 51735f7665adb34c5ca2deacf88ed89fdcd97e09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:27:34 +0000 Subject: [PATCH 196/331] [pre-commit.ci lite] apply automatic fixes --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6760b3568..c91167c69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -406,8 +406,6 @@ ignore_path = [ "./src/*/_setuptools_scm_version.txt", ] - - [tool.vulture] # Ideally we would limit the paths to the source code where we want to ignore names, # but Vulture does not enable this. From 42426287dbabf55983c0ac982d946c6c1eca2143 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 11 Oct 2024 14:00:17 +0100 Subject: [PATCH 197/331] Move shellcheck settings to rc file --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0968c0ee4..61c050e2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -68,7 +68,7 @@ repos: - id: shellcheck name: shellcheck - entry: uv run --extra=dev shellcheck --shell=bash --exclude=SC1017 + entry: uv run --extra=dev shellcheck --shell=bash language: python types_or: [shell] additional_dependencies: [uv] @@ -77,7 +77,7 @@ repos: name: shellcheck-docs # We exclude SC2215 as it is a false positive for an unknown reason on Windows. entry: uv run --extra=dev doccmd --language=shell --language=console --command="shellcheck - --shell=bash --exclude=SC1017 --exclude=SC2215" + --shell=bash --exclude=SC2215" language: python types_or: [markdown, rst] additional_dependencies: [uv] From 4c50453844c7469028cee6a3d925d44145c1ccf9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 11 Oct 2024 21:19:45 +0100 Subject: [PATCH 198/331] Bump doccmd --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e9d298c5e..8d17035d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.8.12", + "doccmd==2024.10.11", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From dc697c69b7dcb63e50cf090f3003acb3b8053096 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 12 Oct 2024 16:16:54 +0100 Subject: [PATCH 199/331] Configure VSCode to run tests in its UI --- .vscode/settings.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 98f94ef23..9ca5c7894 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -7,5 +7,10 @@ "editor.formatOnSave": true }, "esbonio.sphinx.confDir": "", - "rewrap.wrappingColumn": 79 + "rewrap.wrappingColumn": 79, + "python.testing.pytestArgs": [ + "." + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true } From 0a67335b286e646f54a28ab44c8a33428ecb203f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 12 Oct 2024 17:08:45 +0100 Subject: [PATCH 200/331] Move mypy file definitions to pyproject.toml --- .pre-commit-config.yaml | 2 +- pyproject.toml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61c050e2f..635af9b5f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -100,7 +100,7 @@ repos: - id: mypy name: mypy stages: [pre-push] - entry: uv run --extra=dev -m mypy . + entry: uv run --extra=dev -m mypy language: python types_or: [python, toml] pass_filenames: false diff --git a/pyproject.toml b/pyproject.toml index 8d17035d1..456e29fff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -375,6 +375,8 @@ exclude_also = [ [tool.mypy] strict = true +files = [ "." ] +exclude = [ "build" ] plugins = [ "pydantic.mypy", ] From 1b4c5590f128585f70906ec51b0737e2940d9c1f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 12 Oct 2024 17:49:06 +0100 Subject: [PATCH 201/331] No need to give directory to check-manifest --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 61c050e2f..5f49e7242 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -116,7 +116,7 @@ repos: - id: check-manifest name: check-manifest stages: [pre-push] - entry: uv run --extra=dev -m check_manifest . + entry: uv run --extra=dev -m check_manifest language: python pass_filenames: false additional_dependencies: [uv] From 1af611c9eead322f8315cd8de33b4ded37c0ad44 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 05:17:20 +0000 Subject: [PATCH 202/331] Bump pre-commit-ci/lite-action from 1.0.3 to 1.1.0 Bumps [pre-commit-ci/lite-action](https://github.com/pre-commit-ci/lite-action) from 1.0.3 to 1.1.0. - [Release notes](https://github.com/pre-commit-ci/lite-action/releases) - [Commits](https://github.com/pre-commit-ci/lite-action/compare/v1.0.3...v1.1.0) --- updated-dependencies: - dependency-name: pre-commit-ci/lite-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a24292376..919e846a1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -37,5 +37,5 @@ jobs: env: UV_PYTHON: ${{ matrix.python-version }} - - uses: pre-commit-ci/lite-action@v1.0.3 + - uses: pre-commit-ci/lite-action@v1.1.0 if: always() From 01d32c6126b5719aa94464be0b9f2c10821d029b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 05:31:29 +0000 Subject: [PATCH 203/331] Bump sphinx from 8.1.0 to 8.1.3 Bumps [sphinx](https://github.com/sphinx-doc/sphinx) from 8.1.0 to 8.1.3. - [Release notes](https://github.com/sphinx-doc/sphinx/releases) - [Changelog](https://github.com/sphinx-doc/sphinx/blob/master/CHANGES.rst) - [Commits](https://github.com/sphinx-doc/sphinx/compare/v8.1.0...v8.1.3) --- updated-dependencies: - dependency-name: sphinx dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 456e29fff..3a04f6eaa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ optional-dependencies.dev = [ # use it to lint shell commands in GitHub workflow files. "shellcheck-py==0.10.0.1", "shfmt-py==3.7.0.1", - "sphinx==8.1.0", + "sphinx==8.1.3", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", "sphinx-substitution-extensions==2024.8.6", From 695fe80ffff5ce9090d26bc5be32f53e5ff22c45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 05:31:39 +0000 Subject: [PATCH 204/331] Bump doccmd from 2024.10.11 to 2024.10.13.1 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.10.11 to 2024.10.13.1. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.10.11...2024.10.13.1) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 456e29fff..e6aef8e3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.11", + "doccmd==2024.10.13.1", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From a5fc99e4992b13497de883c4d484f93ca40fb388 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:17:55 +0000 Subject: [PATCH 205/331] Bump pyproject-fmt from 2.3.0 to 2.3.1 Bumps [pyproject-fmt](https://github.com/tox-dev/pyproject-fmt) from 2.3.0 to 2.3.1. - [Release notes](https://github.com/tox-dev/pyproject-fmt/releases) - [Commits](https://github.com/tox-dev/pyproject-fmt/compare/2.3.0...2.3.1) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 770e84597..a5c623531 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ optional-dependencies.dev = [ "pyenchant==3.3.0rc1", "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", - "pyproject-fmt==2.3.0", + "pyproject-fmt==2.3.1", "pyright==1.1.384", "pyroma==4.2", "pytest==8.3.3", From 3683561b6e7664aee3160308b9e86f8b8ea3cd30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:18:04 +0000 Subject: [PATCH 206/331] Bump doccmd from 2024.10.13.1 to 2024.10.14.2 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.10.13.1 to 2024.10.14.2. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.10.13.1...2024.10.14.2) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 770e84597..a8ed11ddd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -60,7 +60,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.13.1", + "doccmd==2024.10.14.2", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From aeb18857a56b0d4a9baf06caf791f250898a4e8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:18:13 +0000 Subject: [PATCH 207/331] Bump mypy from 1.11.2 to 1.12.0 Bumps [mypy](https://github.com/python/mypy) from 1.11.2 to 1.12.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.11.2...v1.12.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 770e84597..3e57d733f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy==1.11.2", + "mypy==1.12.0", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 8d344acd96997f4872b35f7594374aad56222b9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Oct 2024 05:33:56 +0000 Subject: [PATCH 208/331] Bump types-requests from 2.32.0.20240914 to 2.32.0.20241016 Bumps [types-requests](https://github.com/python/typeshed) from 2.32.0.20240914 to 2.32.0.20241016. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-requests dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8d62f0298..31aad291a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,7 +100,7 @@ optional-dependencies.dev = [ "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pyyaml==6.0.12.20240917", - "types-requests==2.32.0.20240914", + "types-requests==2.32.0.20241016", "urllib3==2.2.3", "vulture==2.13", "vws-python==2024.9.21", From 177a704b37cec22c27de4434b8e12423d3280624 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 05:35:01 +0000 Subject: [PATCH 209/331] Bump pyright from 1.1.384 to 1.1.385 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.384 to 1.1.385. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.384...v1.1.385) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31aad291a..ece760c72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.3.1", - "pyright==1.1.384", + "pyright==1.1.385", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From d773042ca13217d3f73fc9438d6cc9af7393e2e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 05:43:21 +0000 Subject: [PATCH 210/331] Bump sphinx-substitution-extensions from 2024.8.6 to 2024.10.17 Bumps [sphinx-substitution-extensions](https://github.com/adamtheturtle/sphinx-substitution-extensions) from 2024.8.6 to 2024.10.17. - [Release notes](https://github.com/adamtheturtle/sphinx-substitution-extensions/releases) - [Changelog](https://github.com/adamtheturtle/sphinx-substitution-extensions/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/sphinx-substitution-extensions/compare/2024.08.06...2024.10.17) --- updated-dependencies: - dependency-name: sphinx-substitution-extensions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31aad291a..724208280 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ optional-dependencies.dev = [ "sphinx==8.1.3", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", - "sphinx-substitution-extensions==2024.8.6", + "sphinx-substitution-extensions==2024.10.17", "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", From faed5ffd9ee2df49fb7ffdc03c88ca1cfcbd8bfa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 06:19:15 +0000 Subject: [PATCH 211/331] Bump pyproject-fmt from 2.3.1 to 2.4.3 Bumps [pyproject-fmt](https://github.com/tox-dev/toml-fmt) from 2.3.1 to 2.4.3. - [Release notes](https://github.com/tox-dev/toml-fmt/releases) - [Commits](https://github.com/tox-dev/toml-fmt/commits/pyproject-fmt/2.4.3) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b797c9277..bbca7670a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ optional-dependencies.dev = [ "pyenchant==3.3.0rc1", "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", - "pyproject-fmt==2.3.1", + "pyproject-fmt==2.4.3", "pyright==1.1.385", "pyroma==4.2", "pytest==8.3.3", From 23e17c225c4b4764f5424ecdbb70f8862425057c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 18 Oct 2024 23:23:25 +0200 Subject: [PATCH 212/331] Update version scheme to produce good documentation --- docs/source/conf.py | 6 ++++-- pyproject.toml | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index a48ab8ac3..308d9bbf1 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -40,8 +40,10 @@ # Use ``importlib.metadata.version`` as per # https://setuptools-scm.readthedocs.io/en/latest/usage/#usage-from-sphinx. version = importlib.metadata.version(distribution_name=project) -_month, _day, _year, *_ = version.split(sep=".") -release = f"{_month}.{_day}.{_year}" +# This method of getting the release from the version goes hand in hand with +# the ``post-release`` versioning scheme chosen in the ``setuptools-scm`` +# configuration. +release = version.split(".post")[0] project_metadata = importlib.metadata.metadata(distribution_name=project) diff --git a/pyproject.toml b/pyproject.toml index b797c9277..01b040939 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -137,6 +137,13 @@ universal = true # This must be a PEP 440 compliant version. fallback_version = "0.0.0" +# This keeps the start of the version the same as the last release. +# This is useful for our documentation to include e.g. binary links +# to the latest released binary. +# +# Code to match this is in ``conf.py``. +version_scheme = "post-release" + [tool.ruff] target-version = "py311" From 53b3ed3d5bd776eae4709cd9b961e042a8703c84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 19 Oct 2024 07:04:24 +0000 Subject: [PATCH 213/331] Bump ruff from 0.6.9 to 0.7.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.6.9 to 0.7.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.6.9...0.7.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 01b040939..e69a8f6c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -83,7 +83,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.6.9", + "ruff==0.7.0", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From f1492f9bb0c04d2f2f4ecf8483b1a37ecf35c26f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 20 Oct 2024 10:27:05 +0200 Subject: [PATCH 214/331] Cap pydantic-settings version See https://github.com/VWS-Python/vws-python-mock/issues/2407 for removing this cap. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e69a8f6c3..c315adccf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,7 +44,7 @@ dependencies = [ "numpy<2.0.0", "pillow", "piq", - "pydantic-settings", + "pydantic-settings<2.6.0", "requests", "responses", "torch", From 66a3ec114b69e3ef64bc5b34e871744dc7ec77dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 05:32:14 +0000 Subject: [PATCH 215/331] Bump mypy from 1.12.0 to 1.12.1 Bumps [mypy](https://github.com/python/mypy) from 1.12.0 to 1.12.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.12.0...v1.12.1) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61f75a537..b00ad6993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy==1.12.0", + "mypy==1.12.1", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From d87d7e1b8fe0e05f2ed430c39696dc471bf49ba6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 05:32:19 +0000 Subject: [PATCH 216/331] Bump doccmd from 2024.10.14.2 to 2024.10.18 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.10.14.2 to 2024.10.18. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.10.14.2...2024.10.18) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 61f75a537..db741ce9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.14.2", + "doccmd==2024.10.18", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From df6b5e48a726e2f55d2a7e6affb3577a973b8ed4 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 21 Oct 2024 23:10:29 +0100 Subject: [PATCH 217/331] Pin uv for pre-commit hook --- .pre-commit-config.yaml | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4c6b4738..a925d7c6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,7 +49,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: actionlint name: actionlint @@ -57,21 +57,21 @@ repos: language: python pass_filenames: false types_or: [yaml] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: docformatter name: docformatter entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash language: python types_or: [shell] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: shellcheck-docs name: shellcheck-docs @@ -80,14 +80,14 @@ repos: --shell=bash --exclude=SC2215" language: python types_or: [markdown, rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 language: python types_or: [shell] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: shfmt-docs name: shfmt-docs @@ -95,7 +95,7 @@ repos: --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: mypy name: mypy @@ -104,7 +104,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: mypy-docs name: mypy-docs @@ -119,7 +119,7 @@ repos: entry: uv run --extra=dev -m check_manifest language: python pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pyright name: pyright @@ -128,7 +128,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pyright-docs name: pyright-docs @@ -144,7 +144,7 @@ repos: language: python pass_filenames: false types_or: [python] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: vulture name: vulture @@ -152,7 +152,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: vulture-docs name: vulture docs @@ -160,7 +160,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pyroma name: pyroma @@ -168,14 +168,14 @@ repos: language: python pass_filenames: false types_or: [toml] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: deptry name: deptry entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pylint name: pylint @@ -183,7 +183,7 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pylint-docs name: pylint-docs @@ -197,21 +197,21 @@ repos: entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: ruff-check-fix-docs name: Ruff check fix docs entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: ruff-format-fix name: Ruff format entry: uv run --extra=dev -m ruff format language: python types_or: [python] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: ruff-format-fix-docs name: Ruff format docs @@ -219,14 +219,14 @@ repos: format" language: python types_or: [markdown, rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: doc8 name: doc8 entry: uv run --extra=dev -m doc8 language: python types_or: [rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: interrogate name: interrogate @@ -240,7 +240,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: pyproject-fmt-fix name: pyproject-fmt @@ -256,7 +256,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: spelling name: spelling @@ -265,7 +265,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: docs name: Build Documentation @@ -273,14 +273,14 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] - id: yamlfix name: pyproject-fmt entry: uv run --extra=dev yamlfix language: python types_or: [yaml] - additional_dependencies: [uv] + additional_dependencies: [uv==0.4.25] # We use system Python, with required dependencies specified in pyproject.toml. # We therefore cannot use those dependencies in pre-commit CI. From 090c35d8ae9830cc2793014a74e2019177fd46b8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 05:12:19 +0000 Subject: [PATCH 218/331] Bump mypy from 1.12.1 to 1.13.0 Bumps [mypy](https://github.com/python/mypy) from 1.12.1 to 1.13.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.12.1...v1.13.0) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b3e31e3f5..475d7b237 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy==1.12.1", + "mypy==1.13.0", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 19d51e0c0756ddd916e361cd5b33ff86daf2ce2f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Oct 2024 07:59:51 +0100 Subject: [PATCH 219/331] Remove unnecessary build dependency - pip --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b3e31e3f5..641970531 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] build-backend = "setuptools.build_meta" requires = [ - "pip", "setuptools", "setuptools-scm[toml]==7.1", "wheel", From 2ef547ff7ec6815432fa349907d4818eab72d35d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Oct 2024 08:15:45 +0100 Subject: [PATCH 220/331] Remove unnecessary build dependency - pip --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b3e31e3f5..641970531 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,6 @@ [build-system] build-backend = "setuptools.build_meta" requires = [ - "pip", "setuptools", "setuptools-scm[toml]==7.1", "wheel", From fb7cadfbc5e47dce8ab1e97bb2c5e150ac7a985d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 23 Oct 2024 08:38:07 +0100 Subject: [PATCH 221/331] Use faster mypy cache --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8659dab80..709efd442 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy==1.13.0", + "mypy[faster-cache]==1.13.0", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 9371655fdbdd0e9d5e08b10b32f428a66f8109c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Oct 2024 05:32:54 +0000 Subject: [PATCH 222/331] Bump pyright from 1.1.385 to 1.1.386 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.385 to 1.1.386. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.385...v1.1.386) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 709efd442..07d618dcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.4.3", - "pyright==1.1.385", + "pyright==1.1.386", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 993f102829b7665820a651e0802371b96409b39d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 05:42:01 +0000 Subject: [PATCH 223/331] Bump ruff from 0.7.0 to 0.7.1 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.0...0.7.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 07d618dcb..caf8256bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.7.0", + "ruff==0.7.1", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 59da4b774a3cbf95c45bf448128065346f25b8e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 05:10:04 +0000 Subject: [PATCH 224/331] Bump sybil from 8.0.0 to 8.0.1 Bumps [sybil](https://github.com/simplistix/sybil) from 8.0.0 to 8.0.1. - [Changelog](https://github.com/simplistix/sybil/blob/master/CHANGELOG.rst) - [Commits](https://github.com/simplistix/sybil/compare/8.0.0...8.0.1) --- updated-dependencies: - dependency-name: sybil dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index caf8256bc..d2825da17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", - "sybil==8.0.0", + "sybil==8.0.1", "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pyyaml==6.0.12.20240917", From befc24ad1d31dc64595840eba1321afd9272da43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 05:10:21 +0000 Subject: [PATCH 225/331] Bump pyproject-fmt from 2.4.3 to 2.5.0 Bumps [pyproject-fmt](https://github.com/tox-dev/toml-fmt) from 2.4.3 to 2.5.0. - [Release notes](https://github.com/tox-dev/toml-fmt/releases) - [Commits](https://github.com/tox-dev/toml-fmt/compare/pyproject-fmt/2.4.3...pyproject-fmt/2.5.0) --- updated-dependencies: - dependency-name: pyproject-fmt dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index caf8256bc..62d7b3962 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ optional-dependencies.dev = [ "pyenchant==3.3.0rc1", "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", - "pyproject-fmt==2.4.3", + "pyproject-fmt==2.5.0", "pyright==1.1.386", "pyroma==4.2", "pytest==8.3.3", From 2885f80514d7d50b47b061f1b6440196d2116955 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:51:19 +0000 Subject: [PATCH 226/331] Bump pyright from 1.1.386 to 1.1.387 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.386 to 1.1.387. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.386...v1.1.387) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4640d810a..63e119b58 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.386", + "pyright==1.1.387", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==5.0.0", From 04290b7721f9042c3ef21fe7b81d68deecfdb610 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 05:24:17 +0000 Subject: [PATCH 227/331] Bump ruff from 0.7.1 to 0.7.2 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.1 to 0.7.2. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.1...0.7.2) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4640d810a..4e6d46474 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.7.1", + "ruff==0.7.2", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From ba0ee84bf4e6a6aeacdf06b8f82cbb293e2e1f7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 07:14:14 +0000 Subject: [PATCH 228/331] Bump pytest-cov from 5.0.0 to 6.0.0 Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 5.0.0 to 6.0.0. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v5.0.0...v6.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b9cd99bce..0ba5a0828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,7 +74,7 @@ optional-dependencies.dev = [ "pyright==1.1.387", "pyroma==4.2", "pytest==8.3.3", - "pytest-cov==5.0.0", + "pytest-cov==6.0.0", "pytest-retry==1.6.3", "pytest-xdist==3.6.1", "python-dotenv==1.0.1", From f03c528e0d26012dd9ecb4e8b3ef0a9fb9c8217c Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 4 Nov 2024 07:16:36 +0000 Subject: [PATCH 229/331] Add minimum version for pydantic-settings --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b9cd99bce..718db460c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ dependencies = [ "numpy", "pillow", "piq", - "pydantic-settings<2.6.0", + "pydantic-settings>=2.6.1", "requests", "responses", "torch", From 87d850ca67df20db3e10b7e1c05d415c03f21e66 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 4 Nov 2024 16:16:45 +0000 Subject: [PATCH 230/331] Use @unique to ensure and communicate enum uniqueness --- src/mock_vws/_constants.py | 4 +++- src/mock_vws/states.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mock_vws/_constants.py b/src/mock_vws/_constants.py index 25753ed58..61443bbc7 100644 --- a/src/mock_vws/_constants.py +++ b/src/mock_vws/_constants.py @@ -2,12 +2,13 @@ Constants used to make the VWS mock. """ -from enum import Enum +from enum import Enum, unique from beartype import beartype @beartype +@unique class ResultCodes(Enum): """Constants representing various VWS result codes. @@ -42,6 +43,7 @@ class ResultCodes(Enum): @beartype +@unique class TargetStatuses(Enum): """Constants representing VWS target statuses. diff --git a/src/mock_vws/states.py b/src/mock_vws/states.py index c3f55b019..7233fd8c9 100644 --- a/src/mock_vws/states.py +++ b/src/mock_vws/states.py @@ -2,12 +2,13 @@ Vuforia database states. """ -from enum import StrEnum, auto +from enum import StrEnum, auto, unique from beartype import beartype @beartype +@unique class States(StrEnum): """ Constants representing various web service states. From b30410c1c5dec6b96d6cf0b198e559ca6506c20e Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 4 Nov 2024 22:38:52 +0000 Subject: [PATCH 231/331] Add minimum versions for dependencies --- pyproject.toml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8015188c7..f46784bff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,19 +36,19 @@ dynamic = [ "version", ] dependencies = [ - "beartype", - "flask", - "numpy", - "pillow", - "piq", + "beartype>=0.19.0", + "flask>=3.0.3", + "numpy>=1.26.4", + "pillow>=11.0.0", + "piq>=0.8.0", "pydantic-settings>=2.6.1", - "requests", - "responses", - "torch", - "torchmetrics", + "requests>=2.32.3", + "responses>=0.25.3", + "torch>=2.5.1", + "torchmetrics>=1.5.1", "tzdata; sys_platform=='win32'", - "vws-auth-tools", - "werkzeug", + "vws-auth-tools>=2024.7.12", + "werkzeug>=3.1.2", ] optional-dependencies.dev = [ "actionlint-py==1.7.3.17", From 8306241fb2e1bf9649597ae576c082124c4a5091 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Nov 2024 05:34:30 +0000 Subject: [PATCH 232/331] Bump doccmd from 2024.10.18 to 2024.11.4 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.10.18 to 2024.11.4. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.10.18...2024.11.04) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8015188c7..8ccb10c97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.10.18", + "doccmd==2024.11.4", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From f60132d20c4f0aa1a27eb34c0db56efcfad23223 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 5 Nov 2024 22:34:47 +0000 Subject: [PATCH 233/331] Do not run doccmd against Python or toml files --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a925d7c6b..9799e0563 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -111,7 +111,7 @@ repos: stages: [pre-push] entry: uv run --extra=dev doccmd --language=python --command="mypy" language: python - types_or: [markdown, rst, python, toml] + types_or: [markdown, rst] - id: check-manifest name: check-manifest @@ -135,7 +135,7 @@ repos: stages: [pre-push] entry: uv run --extra=dev doccmd --language=python --command="pyright" language: python - types_or: [markdown, rst, python, toml] + types_or: [markdown, rst] - id: pyright-verifytypes name: pyright-verifytypes @@ -190,7 +190,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="pylint" language: python stages: [manual] - types_or: [markdown, rst, python, toml] + types_or: [markdown, rst] - id: ruff-check-fix name: Ruff check fix From 81f1a5679de44d5b906911f3f75e4b68ba2a6550 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 05:48:21 +0000 Subject: [PATCH 234/331] Bump actionlint-py from 1.7.3.17 to 1.7.4.18 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.3.17 to 1.7.4.18. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.3.17...v1.7.4.18) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8ccb10c97..4f02a7cdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "werkzeug", ] optional-dependencies.dev = [ - "actionlint-py==1.7.3.17", + "actionlint-py==1.7.4.18", "check-manifest==0.50", "check-wheel-contents==0.6.0", "deptry==0.20.0", From 2ffc0fc30c7ab6ee76980335e18ae74d7847512e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Nov 2024 06:04:49 +0000 Subject: [PATCH 235/331] Bump doccmd from 2024.11.4 to 2024.11.5 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.11.4 to 2024.11.5. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.11.04...2024.11.05) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4f02a7cdf..ac019f896 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.11.4", + "doccmd==2024.11.5", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From 25c6bc22a2606a1ded68dd1ae856e5cff54b41e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 05:39:34 +0000 Subject: [PATCH 236/331] Bump pyright from 1.1.387 to 1.1.388 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.387 to 1.1.388. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.387...v1.1.388) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ac019f896..61810b912 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.387", + "pyright==1.1.388", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==6.0.0", From 4a50cfcf4dda01315a8dbf69c45c11b396eaadbf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 05:39:39 +0000 Subject: [PATCH 237/331] Bump doccmd from 2024.11.5 to 2024.11.6.1 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.11.5 to 2024.11.6.1. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.11.05...2024.11.06.1) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ac019f896..2392c7287 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.11.5", + "doccmd==2024.11.6.1", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From e3d8f679dc64cb3b5535b73a85758c9c342b666f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 05:16:08 +0000 Subject: [PATCH 238/331] Bump doccmd from 2024.11.6.1 to 2024.11.7 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.11.6.1 to 2024.11.7. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.11.06.1...2024.11.07) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1384abc5a..81b7caafe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.20.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.11.6.1", + "doccmd==2024.11.7", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From 5265092d5cc8396b338bf59a1e96225adc4e7e34 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 05:25:47 +0000 Subject: [PATCH 239/331] Bump setuptools-scm[toml] from 7.1 to 8.1.0 Bumps [setuptools-scm[toml]](https://github.com/pypa/setuptools_scm) from 7.1 to 8.1.0. - [Release notes](https://github.com/pypa/setuptools_scm/releases) - [Changelog](https://github.com/pypa/setuptools-scm/blob/main/CHANGELOG.md) - [Commits](https://github.com/pypa/setuptools_scm/compare/v7.1.0...v8.1.0) --- updated-dependencies: - dependency-name: setuptools-scm[toml] dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 81b7caafe..c4b4cc78c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools", - "setuptools-scm[toml]==7.1", + "setuptools-scm[toml]==8.1.0", "wheel", ] From 455f14f6638f29f9581dce013d1d477e23000f3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 05:26:07 +0000 Subject: [PATCH 240/331] Bump ruff from 0.7.2 to 0.7.3 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.2 to 0.7.3. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.2...0.7.3) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 81b7caafe..37e638ea2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.7.2", + "ruff==0.7.3", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 125038cbadb0b6e1314df702925ac1263d242f9b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 05:26:12 +0000 Subject: [PATCH 241/331] Bump deptry from 0.20.0 to 0.21.0 Bumps [deptry](https://github.com/fpgmaas/deptry) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.20.0...0.21.0) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 81b7caafe..057b26b7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ optional-dependencies.dev = [ "actionlint-py==1.7.4.18", "check-manifest==0.50", "check-wheel-contents==0.6.0", - "deptry==0.20.0", + "deptry==0.21.0", "dirty-equals==0.8.0", "doc8==1.1.1", "doccmd==2024.11.7", From 04ddae9a4a12226146e31d83febcf1ff59e502a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 05:32:02 +0000 Subject: [PATCH 242/331] Bump sybil from 8.0.1 to 9.0.0 Bumps [sybil](https://github.com/simplistix/sybil) from 8.0.1 to 9.0.0. - [Changelog](https://github.com/simplistix/sybil/blob/master/CHANGELOG.rst) - [Commits](https://github.com/simplistix/sybil/compare/8.0.1...9.0.0) --- updated-dependencies: - dependency-name: sybil dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 50605d1bd..18376b9d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,7 +93,7 @@ optional-dependencies.dev = [ "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8", - "sybil==8.0.1", + "sybil==9.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", "types-pyyaml==6.0.12.20240917", From 80abd7205a8e26285930b31f758a128156220725 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 05:10:11 +0000 Subject: [PATCH 243/331] Bump pyright from 1.1.388 to 1.1.389 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.388 to 1.1.389. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.388...v1.1.389) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 18376b9d3..375dc9744 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.1", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.388", + "pyright==1.1.389", "pyroma==4.2", "pytest==8.3.3", "pytest-cov==6.0.0", From 27484da19c15b6f8704bd81aa5b157a58396444d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 05:50:10 +0000 Subject: [PATCH 244/331] Bump codecov/codecov-action from 4 to 5 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4 to 5. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v4...v5) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- .github/workflows/skip-tests.yml | 2 +- .github/workflows/windows-ci.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ebba1e06..f1788e2f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -189,7 +189,7 @@ jobs: echo ${{ github.event_name }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: fail_ci_if_error: true token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index 3c6d21a7f..c2816f319 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -77,7 +77,7 @@ jobs: echo ${{ github.event_name }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: fail_ci_if_error: true # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index dc72a0a17..4fdd943c6 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -66,7 +66,7 @@ jobs: echo ${{ github.event_name }} - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@v5 with: fail_ci_if_error: true # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 From 99707482796d23350bdf3695043efd9862cf5536 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 05:57:17 +0000 Subject: [PATCH 245/331] Bump doccmd from 2024.11.7 to 2024.11.14 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.11.7 to 2024.11.14. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.11.07...2024.11.14) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 375dc9744..1f240ded8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.21.0", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.11.7", + "doccmd==2024.11.14", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From 2409c18588757e1d7ad2c8a209d43329f0b41f70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 05:38:21 +0000 Subject: [PATCH 246/331] Bump deptry from 0.21.0 to 0.21.1 Bumps [deptry](https://github.com/fpgmaas/deptry) from 0.21.0 to 0.21.1. - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.21.0...0.21.1) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1f240ded8..ae0322c0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ optional-dependencies.dev = [ "actionlint-py==1.7.4.18", "check-manifest==0.50", "check-wheel-contents==0.6.0", - "deptry==0.21.0", + "deptry==0.21.1", "dirty-equals==0.8.0", "doc8==1.1.1", "doccmd==2024.11.14", From 8edc78ed25b46214d04da2e5ca827ea7f7bf2fe4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 05:38:42 +0000 Subject: [PATCH 247/331] Bump ruff from 0.7.3 to 0.7.4 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.3 to 0.7.4. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.3...0.7.4) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1f240ded8..25f5df138 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.7.3", + "ruff==0.7.4", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 303a75926de52f803892574936b558e6ced1190c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 05:11:39 +0000 Subject: [PATCH 248/331] Bump astral-sh/setup-uv from 3 to 4 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 3 to 4. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v3...v4) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/skip-tests.yml | 2 +- .github/workflows/windows-ci.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f1788e2f6..026461ba9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 - name: Set secrets file run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 919e846a1..13d97d953 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 - name: Lint run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e4e48812..ebf5a8bb2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 - name: Calver calculate version uses: StephaneBour/actions-calver@master diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index c2816f319..ed3a3e160 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -32,7 +32,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 - name: Set secrets file run: | diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 4fdd943c6..3e8b03a94 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -30,7 +30,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v3 + uses: astral-sh/setup-uv@v4 - name: Set secrets file run: | From ac46bd401d799b91f7f64c2498295bea7033a681 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 05:13:19 +0000 Subject: [PATCH 249/331] Bump actionlint-py from 1.7.4.18 to 1.7.4.20 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.4.18 to 1.7.4.20. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.4.18...v1.7.4.20) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c02015051..5f4e9fea1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "werkzeug", ] optional-dependencies.dev = [ - "actionlint-py==1.7.4.18", + "actionlint-py==1.7.4.20", "check-manifest==0.50", "check-wheel-contents==0.6.0", "deptry==0.21.1", From 1af4abb5728bead25af3fb42b589be64412592b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 27 Nov 2024 05:24:39 +0000 Subject: [PATCH 250/331] Bump docker/build-push-action from 6.9.0 to 6.10.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.9.0 to 6.10.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.9.0...v6.10.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index d05815633..725d9cc18 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.9.0 + uses: docker/build-push-action@v6.10.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4e4e48812..accdc85ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -103,7 +103,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.9.0 + uses: docker/build-push-action@v6.10.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -114,7 +114,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.9.0 + uses: docker/build-push-action@v6.10.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -125,7 +125,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.9.0 + uses: docker/build-push-action@v6.10.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From ea68065869674db98b69a92c6bf3bd5823c1dc81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 05:54:48 +0000 Subject: [PATCH 251/331] Bump ruff from 0.7.4 to 0.8.1 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.7.4 to 0.8.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.7.4...0.8.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f4e9fea1..3711d665d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.7.4", + "ruff==0.8.1", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From cfb72bd8a3dbc63bf26875577b29a7e35e8165cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 05:55:42 +0000 Subject: [PATCH 252/331] Bump pylint from 3.3.1 to 3.3.2 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.3.1 to 3.3.2. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.3.1...v3.3.2) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f4e9fea1..89e5a02a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ optional-dependencies.dev = [ "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", - "pylint==3.3.1", + "pylint==3.3.2", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", "pyright==1.1.389", From 45aad55e2a27de7bb5e5f58d012f40799ff39cbe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 05:55:55 +0000 Subject: [PATCH 253/331] Bump pytest from 8.3.3 to 8.3.4 Bumps [pytest](https://github.com/pytest-dev/pytest) from 8.3.3 to 8.3.4. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/8.3.3...8.3.4) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f4e9fea1..d29fbf633 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -73,7 +73,7 @@ optional-dependencies.dev = [ "pyproject-fmt==2.5.0", "pyright==1.1.389", "pyroma==4.2", - "pytest==8.3.3", + "pytest==8.3.4", "pytest-cov==6.0.0", "pytest-retry==1.6.3", "pytest-xdist==3.6.1", From ce79d98b93ed84fcb6d018505af55ba2b1db6d8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 05:56:10 +0000 Subject: [PATCH 254/331] Bump check-wheel-contents from 0.6.0 to 0.6.1 Bumps [check-wheel-contents](https://github.com/jwodder/check-wheel-contents) from 0.6.0 to 0.6.1. - [Release notes](https://github.com/jwodder/check-wheel-contents/releases) - [Changelog](https://github.com/jwodder/check-wheel-contents/blob/master/CHANGELOG.md) - [Commits](https://github.com/jwodder/check-wheel-contents/compare/v0.6.0...v0.6.1) --- updated-dependencies: - dependency-name: check-wheel-contents dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5f4e9fea1..a80f6151c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ dependencies = [ optional-dependencies.dev = [ "actionlint-py==1.7.4.20", "check-manifest==0.50", - "check-wheel-contents==0.6.0", + "check-wheel-contents==0.6.1", "deptry==0.21.1", "dirty-equals==0.8.0", "doc8==1.1.1", @@ -105,7 +105,7 @@ optional-dependencies.dev = [ "vws-web-tools==2024.10.6.1", "yamlfix==1.17.0", ] -optional-dependencies.release = [ "check-wheel-contents==0.6.0" ] +optional-dependencies.release = [ "check-wheel-contents==0.6.1" ] urls.Documentation = "https://vws-python-mock.readthedocs.io" urls.Source = "https://github.com/VWS-Python/vws-python-mock" From a3c4e9d1b02fbc8d2f4e59b8ded1279cef6c3557 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 2 Dec 2024 19:32:30 +0000 Subject: [PATCH 255/331] Sort __all__ --- src/mock_vws/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mock_vws/__init__.py b/src/mock_vws/__init__.py index 04d861f1a..357f764b7 100644 --- a/src/mock_vws/__init__.py +++ b/src/mock_vws/__init__.py @@ -8,6 +8,6 @@ ) __all__ = [ - "MockVWS", "MissingSchemeError", + "MockVWS", ] From 41237fce4ee2b36ae59b1490498fad4e2faf41ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 06:04:48 +0000 Subject: [PATCH 256/331] Bump pyright from 1.1.389 to 1.1.390 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.389 to 1.1.390. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.389...v1.1.390) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bb51fd1f3..e3b07b38c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.2", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.389", + "pyright==1.1.390", "pyroma==4.2", "pytest==8.3.4", "pytest-cov==6.0.0", From 9198d9ba0aa06c3018213f29bf2550263cedf7d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 05:20:12 +0000 Subject: [PATCH 257/331] Bump ruff from 0.8.1 to 0.8.2 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.1 to 0.8.2. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.1...0.8.2) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e3b07b38c..6f9b6fc93 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.1", + "ruff==0.8.2", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 20ec32ea722c6ae2fee13895bc3d90c42c05f075 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 05:04:55 +0000 Subject: [PATCH 258/331] Bump vulture from 2.13 to 2.14 Bumps [vulture](https://github.com/jendrikseipp/vulture) from 2.13 to 2.14. - [Release notes](https://github.com/jendrikseipp/vulture/releases) - [Changelog](https://github.com/jendrikseipp/vulture/blob/main/CHANGELOG.md) - [Commits](https://github.com/jendrikseipp/vulture/compare/v2.13...v2.14) --- updated-dependencies: - dependency-name: vulture dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6f9b6fc93..471dd7ee3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -99,7 +99,7 @@ optional-dependencies.dev = [ "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20241016", "urllib3==2.2.3", - "vulture==2.13", + "vulture==2.14", "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", "vws-web-tools==2024.10.6.1", From c2bcbb96312fbd66d705dba3eb45fd1d92cd721b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:52:24 +0000 Subject: [PATCH 259/331] Bump ruff from 0.8.2 to 0.8.3 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.2 to 0.8.3. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.2...0.8.3) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6f9b6fc93..721753eb7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.2", + "ruff==0.8.3", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From ec5469ee1f8d253926c3d914baacd6729dd49b41 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 18 Dec 2024 16:18:03 +0000 Subject: [PATCH 260/331] Update RTD config with new requirements --- readthedocs.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/readthedocs.yaml b/readthedocs.yaml index bdd2bf053..8f093abcc 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -14,4 +14,5 @@ python: sphinx: builder: html + configuration: docs/source/conf.py fail_on_warning: true From cebde372468302b575588a401f7f354996a7eae1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 05:50:49 +0000 Subject: [PATCH 261/331] Bump pyright from 1.1.390 to 1.1.391 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.390 to 1.1.391. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.390...v1.1.391) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 721753eb7..645d8e20f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ optional-dependencies.dev = [ "pylint==3.3.2", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.390", + "pyright==1.1.391", "pyroma==4.2", "pytest==8.3.4", "pytest-cov==6.0.0", From a7531860af13867419f76ba4a4c808a582bc9507 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:44:11 +0000 Subject: [PATCH 262/331] Bump deptry from 0.21.1 to 0.21.2 Bumps [deptry](https://github.com/fpgmaas/deptry) from 0.21.1 to 0.21.2. - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.21.1...0.21.2) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b216035d5..21d927110 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ optional-dependencies.dev = [ "actionlint-py==1.7.4.20", "check-manifest==0.50", "check-wheel-contents==0.6.1", - "deptry==0.21.1", + "deptry==0.21.2", "dirty-equals==0.8.0", "doc8==1.1.1", "doccmd==2024.11.14", From 63dd50accccec923d3017df194394422a786f7bb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:44:17 +0000 Subject: [PATCH 263/331] Bump sphinxcontrib-spelling from 8 to 8.0.1 Bumps [sphinxcontrib-spelling](https://github.com/sphinx-contrib/spelling) from 8 to 8.0.1. - [Release notes](https://github.com/sphinx-contrib/spelling/releases) - [Commits](https://github.com/sphinx-contrib/spelling/compare/8.0.0...8.0.1) --- updated-dependencies: - dependency-name: sphinxcontrib-spelling dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b216035d5..d5db405d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ optional-dependencies.dev = [ "sphinx-substitution-extensions==2024.10.17", "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", - "sphinxcontrib-spelling==8", + "sphinxcontrib-spelling==8.0.1", "sybil==9.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", From e300db5b5122895fad9a01e1e8a302a2fe5e10f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 05:44:33 +0000 Subject: [PATCH 264/331] Bump ruff from 0.8.3 to 0.8.4 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.3 to 0.8.4. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.3...0.8.4) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b216035d5..929b6f117 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.3", + "ruff==0.8.4", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 82c14c8e36c2e513bbf7de5c181bfd0c5ab55d51 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 21 Dec 2024 11:48:51 +0000 Subject: [PATCH 265/331] Do not use now-useless toml specifier for setuptools-scm --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2069b358e..444fbf0dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ build-backend = "setuptools.build_meta" requires = [ "setuptools", - "setuptools-scm[toml]==8.1.0", + "setuptools-scm>=8.1.0", "wheel", ] From 08ef1e341b8c68bb28a75da281483f5be6f372e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Dec 2024 22:33:17 +0000 Subject: [PATCH 266/331] Bump astral-sh/setup-uv from 4 to 5 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 4 to 5. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/v4...v5) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/skip-tests.yml | 2 +- .github/workflows/windows-ci.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 026461ba9..ebe8ccabf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,7 +125,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 - name: Set secrets file run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 13d97d953..116a9c18c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 - name: Lint run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ceda97587..3332fb373 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: - uses: actions/checkout@v4 - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 - name: Calver calculate version uses: StephaneBour/actions-calver@master diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index ed3a3e160..56cabaff8 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -32,7 +32,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 - name: Set secrets file run: | diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 3e8b03a94..6d128f96e 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -30,7 +30,7 @@ jobs: fetch-depth: 2 - name: Install uv - uses: astral-sh/setup-uv@v4 + uses: astral-sh/setup-uv@v5 - name: Set secrets file run: | From a49172f5ee7ec8bd318a428d3b967ee9937a271b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 22 Dec 2024 06:42:26 +0000 Subject: [PATCH 267/331] Remove the final type: ignore! --- pyproject.toml | 3 ++- src/mock_vws/target_raters.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 444fbf0dd..d55eb9735 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy[faster-cache]==1.13.0", + "mypy[faster-cache]==1.14.0", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", @@ -384,6 +384,7 @@ exclude = [ "build" ] plugins = [ "pydantic.mypy", ] +follow_untyped_imports = true [tool.pyright] reportUnnecessaryTypeIgnoreComment = true diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index 40f877aa6..29b607de3 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -9,10 +9,10 @@ from typing import Protocol, runtime_checkable import numpy as np -import piq # type: ignore[import-untyped] import torch from beartype import beartype from PIL import Image +from piq.brisque import brisque @functools.cache @@ -38,7 +38,7 @@ def _get_brisque_target_tracking_rating(*, image_content: bytes) -> int: ) image_tensor = image_tensor.permute(2, 0, 1).unsqueeze(dim=0) try: - brisque_score = piq.brisque(x=image_tensor, data_range=255) + brisque_score = brisque(x=image_tensor, data_range=255) except (AssertionError, IndexError): return 0 return math.ceil(int(brisque_score.item()) / 20) From 4264e3a84d26bbb26331928edb8a67b19bb519d6 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 22 Dec 2024 06:45:49 +0000 Subject: [PATCH 268/331] Ignore pyright error --- src/mock_vws/target_raters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index 29b607de3..8e2cb1d65 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -12,7 +12,7 @@ import torch from beartype import beartype from PIL import Image -from piq.brisque import brisque +from piq.brisque import brisque # pyright: ignore[reportMissingTypeStubs] @functools.cache From ae885879cae94f5bfdaf9ff33921a7e8d243b343 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 05:35:34 +0000 Subject: [PATCH 269/331] Bump urllib3 from 2.2.3 to 2.3.0 Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.2.3 to 2.3.0. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/2.2.3...2.3.0) --- updated-dependencies: - dependency-name: urllib3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d55eb9735..21f01ac4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,7 +98,7 @@ optional-dependencies.dev = [ "types-docker==7.1.0.20240827", "types-pyyaml==6.0.12.20240917", "types-requests==2.32.0.20241016", - "urllib3==2.2.3", + "urllib3==2.3.0", "vulture==2.14", "vws-python==2024.9.21", "vws-test-fixtures==2023.3.5", From 9d3cccc64159f8abb4ef49f4dfc796c68a9f8137 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 05:35:48 +0000 Subject: [PATCH 270/331] Bump types-pyyaml from 6.0.12.20240917 to 6.0.12.20241221 Bumps [types-pyyaml](https://github.com/python/typeshed) from 6.0.12.20240917 to 6.0.12.20241221. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-pyyaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d55eb9735..3b3f37764 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,7 @@ optional-dependencies.dev = [ "sybil==9.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", - "types-pyyaml==6.0.12.20240917", + "types-pyyaml==6.0.12.20241221", "types-requests==2.32.0.20241016", "urllib3==2.2.3", "vulture==2.14", From 46d5a99ddd9cf31b7ccf6b5997b01f6ff2a04767 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 19:50:16 +0000 Subject: [PATCH 271/331] Start of using keyword arguments everywhere --- admin/create_secrets_files.py | 2 +- pyproject.toml | 2 + src/mock_vws/_flask_server/target_manager.py | 10 ++--- src/mock_vws/_flask_server/vws.py | 9 ++-- .../content_type_validators.py | 2 +- src/mock_vws/_query_validators/exceptions.py | 42 +++++++++---------- .../mock_web_query_api.py | 2 +- .../mock_web_services_api.py | 16 +++---- .../_services_validators/exceptions.py | 32 +++++++------- tests/mock_vws/fixtures/prepared_requests.py | 18 ++++---- tests/mock_vws/fixtures/vuforia_backends.py | 2 +- tests/mock_vws/test_content_length.py | 14 ++++--- tests/mock_vws/test_database_summary.py | 2 +- tests/mock_vws/test_docker.py | 12 +++--- tests/mock_vws/test_flask_app_usage.py | 2 +- tests/mock_vws/test_invalid_json.py | 4 +- tests/mock_vws/test_requests_mock_usage.py | 4 +- tests/mock_vws/test_unexpected_json.py | 2 +- tests/mock_vws/utils/assertions.py | 8 ++-- 19 files changed, 97 insertions(+), 88 deletions(-) diff --git a/admin/create_secrets_files.py b/admin/create_secrets_files.py index 58aca18fe..402f17dc0 100644 --- a/admin/create_secrets_files.py +++ b/admin/create_secrets_files.py @@ -108,7 +108,7 @@ def main() -> None: """, ) - file.write_text(file_contents) + file.write_text(data=file_contents) sys.stdout.write(f"Created database {file.name}\n") files_to_create.pop() diff --git a/pyproject.toml b/pyproject.toml index 635017fb8..f4090dcea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy[faster-cache]==1.14.0", + "mypy-strict-kwargs==2024.12.23.2", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", @@ -383,6 +384,7 @@ files = [ "." ] exclude = [ "build" ] plugins = [ "pydantic.mypy", + "mypy_strict_kwargs", ] follow_untyped_imports = true diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index 78f944eb1..eed237669 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -66,7 +66,7 @@ class TargetManagerSettings(BaseSettings): @TARGET_MANAGER_FLASK_APP.route( - "/databases/", + rule="/databases/", methods=[HTTPMethod.DELETE], ) @beartype @@ -184,7 +184,7 @@ def create_database() -> Response: TARGET_MANAGER.add_database(database=database) except ValueError as exc: return Response( - response=str(exc), + response=str(object=exc), status=HTTPStatus.CONFLICT, ) @@ -195,7 +195,7 @@ def create_database() -> Response: @TARGET_MANAGER_FLASK_APP.route( - "/databases//targets", + rule="/databases//targets", methods=[HTTPMethod.POST], ) @beartype @@ -233,7 +233,7 @@ def create_target(database_name: str) -> Response: @TARGET_MANAGER_FLASK_APP.route( - "/databases//targets/", + rule="/databases//targets/", methods={HTTPMethod.DELETE}, ) @beartype @@ -258,7 +258,7 @@ def delete_target(database_name: str, target_id: str) -> Response: @TARGET_MANAGER_FLASK_APP.route( - "/databases//targets/", + rule="/databases//targets/", methods=[HTTPMethod.PUT], ) def update_target(database_name: str, target_id: str) -> Response: diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index 402b41e2c..7bcbf18e6 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -283,7 +283,7 @@ def get_target(target_id: str) -> Response: @VWS_FLASK_APP.route( - "/targets/", + rule="/targets/", methods=[HTTPMethod.DELETE], ) def delete_target(target_id: str) -> Response: @@ -390,7 +390,10 @@ def database_summary() -> Response: ) -@VWS_FLASK_APP.route("/summary/", methods=[HTTPMethod.GET]) +@VWS_FLASK_APP.route( + rule="/summary/", + methods=[HTTPMethod.GET], +) def target_summary(target_id: str) -> Response: """Get a summary report for a target. @@ -441,7 +444,7 @@ def target_summary(target_id: str) -> Response: @VWS_FLASK_APP.route( - "/duplicates/", + rule="/duplicates/", methods=[HTTPMethod.GET], ) @beartype diff --git a/src/mock_vws/_query_validators/content_type_validators.py b/src/mock_vws/_query_validators/content_type_validators.py index 89b8dddd8..aa6eeeb1d 100644 --- a/src/mock_vws/_query_validators/content_type_validators.py +++ b/src/mock_vws/_query_validators/content_type_validators.py @@ -38,7 +38,7 @@ def validate_content_type_header( NoContentTypeError: The content type header is either empty or not given. """ - content_type_header = request_headers.get("Content-Type", "") + content_type_header = request_headers.get("Content-Type", default="") if not content_type_header: _LOGGER.warning(msg="The content type header is empty.") raise NoContentTypeError diff --git a/src/mock_vws/_query_validators/exceptions.py b/src/mock_vws/_query_validators/exceptions.py index bf1cb7b37..87b87390a 100644 --- a/src/mock_vws/_query_validators/exceptions.py +++ b/src/mock_vws/_query_validators/exceptions.py @@ -53,7 +53,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -85,7 +85,7 @@ def __init__(self) -> None: "Server": "nginx", "Date": date, "WWW-Authenticate": "KWS", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -121,7 +121,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -164,7 +164,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -207,7 +207,7 @@ def __init__(self) -> None: "Server": "nginx", "Date": date, "WWW-Authenticate": "VWS", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -245,7 +245,7 @@ def __init__(self) -> None: "Server": "nginx", "Date": date, "WWW-Authenticate": "VWS", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -277,7 +277,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -310,7 +310,7 @@ def __init__(self) -> None: "Server": "nginx", "Date": date, "WWW-Authenticate": "KWS", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -344,7 +344,7 @@ def __init__(self) -> None: "Server": "nginx", "Date": date, "WWW-Authenticate": "KWS", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -376,7 +376,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -418,7 +418,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -455,7 +455,7 @@ def __init__(self, given_value: str) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -492,7 +492,7 @@ def __init__(self, given_value: str) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -531,7 +531,7 @@ def __init__(self, given_value: str) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -562,7 +562,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -593,7 +593,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -628,7 +628,7 @@ def __init__(self) -> None: "Connection": "keep-alive", "Server": "nginx", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -652,7 +652,7 @@ def __init__(self) -> None: # pragma: no cover self.response_text = "" self.headers = { "Connection": "keep-alive", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -675,7 +675,7 @@ def __init__(self) -> None: self.response_text = "" self.headers = { "Connection": "Close", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -719,7 +719,7 @@ def __init__(self) -> None: # pragma: no cover "Date": date, "Server": "nginx", "Content-Type": "text/html", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -771,5 +771,5 @@ def __init__(self) -> None: "Server": "nginx", "Cache-Control": "must-revalidate,no-cache,no-store", "Date": date, - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index abc125c5c..bbe00b7a5 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -136,6 +136,6 @@ def query(self, request: PreparedRequest) -> _ResponseType: "Content-Type": "application/json", "Server": "nginx", "Date": date, - "Content-Length": str(len(response_text)), + "Content-Length": str(object=len(response_text)), } return HTTPStatus.OK, headers, response_text diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index 7aea34ad6..c520025c0 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -195,7 +195,7 @@ def add_target(self, request: PreparedRequest) -> _ResponseType: "Content-Type": "application/json", "server": "envoy", "Date": date, - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "x-envoy-upstream-service-time": "5", "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", @@ -260,7 +260,7 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", @@ -321,7 +321,7 @@ def database_summary(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", @@ -375,7 +375,7 @@ def target_list(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", @@ -440,7 +440,7 @@ def get_target(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", @@ -510,7 +510,7 @@ def get_duplicates(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", @@ -626,7 +626,7 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: "Content-Type": "application/json", "server": "envoy", "Date": date, - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "x-envoy-upstream-service-time": "5", "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", @@ -686,7 +686,7 @@ def target_summary(self, request: PreparedRequest) -> _ResponseType: body_json = json_dump(body=body) headers = { "Connection": "keep-alive", - "Content-Length": str(len(body_json)), + "Content-Length": str(object=len(body_json)), "Content-Type": "application/json", "Date": date, "server": "envoy", diff --git a/src/mock_vws/_services_validators/exceptions.py b/src/mock_vws/_services_validators/exceptions.py index 0eeda683f..c978ad25d 100644 --- a/src/mock_vws/_services_validators/exceptions.py +++ b/src/mock_vws/_services_validators/exceptions.py @@ -59,7 +59,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -99,7 +99,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -139,7 +139,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -178,7 +178,7 @@ def __init__(self, *, status_code: HTTPStatus) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -218,7 +218,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -258,7 +258,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -287,7 +287,7 @@ def __init__(self) -> None: resources_dir = Path(__file__).parent.parent / "resources" filename = "oops_error_occurred_response.html" oops_resp_file = resources_dir / filename - text = str(oops_resp_file.read_text()) + text = str(object=oops_resp_file.read_text()) self.response_text = text date = email.utils.formatdate( timeval=None, @@ -300,7 +300,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -340,7 +340,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -380,7 +380,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -420,7 +420,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -451,7 +451,7 @@ def __init__(self) -> None: # pragma: no cover ) self.response_text = "stream timeout" self.headers = { - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "Date": date, "server": "envoy", "Content-Type": "text/plain", @@ -492,7 +492,7 @@ def __init__(self) -> None: ) self.headers = { "Connection": "close", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "Date": date, "Server": "awselb/2.0", "Content-Type": "text/html", @@ -525,7 +525,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), } @@ -562,7 +562,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", @@ -601,7 +601,7 @@ def __init__(self) -> None: "server": "envoy", "Date": date, "x-envoy-upstream-service-time": "5", - "Content-Length": str(len(self.response_text)), + "Content-Length": str(object=len(self.response_text)), "strict-transport-security": "max-age=31536000", "x-aws-region": "us-east-2, us-west-2", "x-content-type-options": "nosniff", diff --git a/tests/mock_vws/fixtures/prepared_requests.py b/tests/mock_vws/fixtures/prepared_requests.py index dac456b0b..b9c8e4f50 100644 --- a/tests/mock_vws/fixtures/prepared_requests.py +++ b/tests/mock_vws/fixtures/prepared_requests.py @@ -76,7 +76,7 @@ def add_target( headers = { "Authorization": authorization_string, "Date": date, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Content-Type": content_type, } @@ -124,7 +124,7 @@ def delete_target( headers = { "Authorization": authorization_string, "Date": date, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), } return Endpoint( @@ -166,7 +166,7 @@ def database_summary(vuforia_database: VuforiaDatabase) -> Endpoint: headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } @@ -215,7 +215,7 @@ def get_duplicates( headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } @@ -263,7 +263,7 @@ def get_target( headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } @@ -306,7 +306,7 @@ def target_list(vuforia_database: VuforiaDatabase) -> Endpoint: headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } @@ -354,7 +354,7 @@ def target_summary( headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } @@ -404,7 +404,7 @@ def update_target( headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Content-Type": content_type, "Date": date, } @@ -454,7 +454,7 @@ def query( headers = { "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, "Content-Type": content_type_header, } diff --git a/tests/mock_vws/fixtures/vuforia_backends.py b/tests/mock_vws/fixtures/vuforia_backends.py index 23f70d7e3..2c67081f7 100644 --- a/tests/mock_vws/fixtures/vuforia_backends.py +++ b/tests/mock_vws/fixtures/vuforia_backends.py @@ -232,7 +232,7 @@ def pytest_collection_modifyitems( if config.getoption(name=skip_docker_build_tests_option): for item in items: if "requires_docker_build" in item.keywords: - item.add_marker(skip_docker_build_tests_marker) + item.add_marker(marker=skip_docker_build_tests_marker) @beartype diff --git a/tests/mock_vws/test_content_length.py b/tests/mock_vws/test_content_length.py index 264900328..12160dc2e 100644 --- a/tests/mock_vws/test_content_length.py +++ b/tests/mock_vws/test_content_length.py @@ -63,7 +63,7 @@ def test_not_integer(endpoint: Endpoint) -> None: if netloc == "cloudreco.vuforia.com": assert not response.text assert response.headers == { - "Content-Length": str(len(response.text)), + "Content-Length": str(object=len(response.text)), "Connection": "Close", } return @@ -81,7 +81,7 @@ def test_not_integer(endpoint: Endpoint) -> None: ) assert response.text == expected_response_text expected_headers = { - "Content-Length": str(len(response.text)), + "Content-Length": str(object=len(response.text)), "Content-Type": "text/html", "Connection": "close", "Server": "awselb/2.0", @@ -99,7 +99,9 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover pytest.skip(reason="No Content-Type header for this request") netloc = urlparse(url=endpoint.base_url).netloc - content_length = str(int(endpoint.headers["Content-Length"]) + 1) + content_length = str( + object=int(endpoint.headers["Content-Length"]) + 1 + ) new_headers = { **endpoint.headers, @@ -126,7 +128,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover assert response.status_code == HTTPStatus.GATEWAY_TIMEOUT assert not response.text assert response.headers == { - "Content-Length": str(len(response.text)), + "Content-Length": str(object=len(response.text)), "Connection": "keep-alive", } return @@ -136,7 +138,7 @@ def test_too_large(endpoint: Endpoint) -> None: # pragma: no cover # We have seen both of these response texts. assert response.text in {"stream timeout", ""} expected_headers = { - "Content-Length": str(len(response.text)), + "Content-Length": str(object=len(response.text)), "Connection": "close", "Content-Type": "text/plain", "server": "envoy", @@ -159,7 +161,7 @@ def test_too_small(endpoint: Endpoint) -> None: new_headers = { **endpoint.headers, - "Content-Length": str(content_length), + "Content-Length": str(object=content_length), } new_endpoint = Endpoint( diff --git a/tests/mock_vws/test_database_summary.py b/tests/mock_vws/test_database_summary.py index cf43d5a1b..d1ce06f32 100644 --- a/tests/mock_vws/test_database_summary.py +++ b/tests/mock_vws/test_database_summary.py @@ -37,7 +37,7 @@ def _log_attempt_number(retry_state: RetryCallState) -> None: # We wait 0.2 seconds rather than less than that to decrease the number # of calls made to the API, to decrease the likelihood of hitting the # request quota. - wait=wait_fixed(0.2), + wait=wait_fixed(wait=0.2), # Wait up to 700 seconds (arbitrary, though we saw timeouts with 500 # seconds) for the number of images in various categories to match the # expected number. This is necessary because the database summary endpoint diff --git a/tests/mock_vws/test_docker.py b/tests/mock_vws/test_docker.py index 9f254b126..68f3bdbfa 100644 --- a/tests/mock_vws/test_docker.py +++ b/tests/mock_vws/test_docker.py @@ -111,8 +111,8 @@ def test_build_and_run( try: target_manager_image, _ = client.images.build( - path=str(repository_root), - dockerfile=str(dockerfile), + path=str(object=repository_root), + dockerfile=str(object=dockerfile), tag=target_manager_tag, target="target-manager", rm=True, @@ -132,16 +132,16 @@ def test_build_and_run( ) vwq_image, _ = client.images.build( - path=str(repository_root), - dockerfile=str(dockerfile), + path=str(object=repository_root), + dockerfile=str(object=dockerfile), tag=vwq_tag, target="vwq", rm=True, ) vws_image, _ = client.images.build( - path=str(repository_root), - dockerfile=str(dockerfile), + path=str(object=repository_root), + dockerfile=str(object=dockerfile), tag=vws_tag, target="vws", rm=True, diff --git a/tests/mock_vws/test_flask_app_usage.py b/tests/mock_vws/test_flask_app_usage.py index a10f4e82c..551dc9907 100644 --- a/tests/mock_vws/test_flask_app_usage.py +++ b/tests/mock_vws/test_flask_app_usage.py @@ -101,7 +101,7 @@ def test_custom( seconds = 5.0 monkeypatch.setenv( name="PROCESSING_TIME_SECONDS", - value=str(seconds), + value=str(object=seconds), ) database = VuforiaDatabase() databases_url = _EXAMPLE_URL_FOR_TARGET_MANAGER + "/databases" diff --git a/tests/mock_vws/test_invalid_json.py b/tests/mock_vws/test_invalid_json.py index fd2d68110..afc3b75ea 100644 --- a/tests/mock_vws/test_invalid_json.py +++ b/tests/mock_vws/test_invalid_json.py @@ -55,7 +55,7 @@ def test_invalid_json(endpoint: Endpoint) -> None: **endpoint.headers, "Authorization": authorization_string, "Date": date, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), } new_endpoint = Endpoint( @@ -135,7 +135,7 @@ def test_invalid_json_with_skewed_time(endpoint: Endpoint) -> None: new_headers = { **endpoint.headers, "Authorization": authorization_string, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), "Date": date, } diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index 0da5d1789..09ddbc14e 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -247,14 +247,14 @@ def test_no_scheme() -> None: 'Invalid URL "vuforia.vws.example.com": No scheme supplied. ' 'Perhaps you meant "https://vuforia.vws.example.com".' ) - assert str(vws_exc.value) == expected + assert str(object=vws_exc.value) == expected with pytest.raises(expected_exception=MissingSchemeError) as vwq_exc: MockVWS(base_vwq_url="vuforia.vwq.example.com") expected = ( 'Invalid URL "vuforia.vwq.example.com": No scheme supplied. ' 'Perhaps you meant "https://vuforia.vwq.example.com".' ) - assert str(vwq_exc.value) == expected + assert str(object=vwq_exc.value) == expected class TestTargets: diff --git a/tests/mock_vws/test_unexpected_json.py b/tests/mock_vws/test_unexpected_json.py index beaac61f9..c7f96856e 100644 --- a/tests/mock_vws/test_unexpected_json.py +++ b/tests/mock_vws/test_unexpected_json.py @@ -52,7 +52,7 @@ def test_does_not_take_data(endpoint: Endpoint) -> None: "Authorization": authorization_string, "Date": date, "Content-Type": content_type, - "Content-Length": str(len(content)), + "Content-Length": str(object=len(content)), } new_endpoint = Endpoint( diff --git a/tests/mock_vws/utils/assertions.py b/tests/mock_vws/utils/assertions.py index 2ad4752cf..936e207bb 100644 --- a/tests/mock_vws/utils/assertions.py +++ b/tests/mock_vws/utils/assertions.py @@ -154,7 +154,7 @@ def assert_vws_response( "x-envoy-upstream-service-time", } assert {str.lower(key) for key in response.headers} == response_header_keys - assert response.headers["Content-Length"] == str(len(response.text)) + assert response.headers["Content-Length"] == str(object=len(response.text)) assert response.headers["Content-Type"] == "application/json" assert response.headers["server"] == "envoy" assert response.headers["x-content-type-options"] == "nosniff" @@ -201,7 +201,7 @@ def assert_query_success(*, response: Response) -> None: expected_response_header_not_chunked = { "Connection": "keep-alive", - "Content-Length": str(response.tell_position), + "Content-Length": str(object=response.tell_position), "Content-Type": "application/json", "Server": "nginx", } @@ -276,7 +276,9 @@ def assert_vwq_failure( assert response.headers.get("transfer-encoding", "chunked") == "chunked" assert response.headers["Connection"] == connection if "Content-Length" in response.headers: # pragma: no cover - assert response.headers["Content-Length"] == str(len(response.text)) + assert response.headers["Content-Length"] == str( + object=len(response.text) + ) # In some tests we see that sometimes there is no Content-Length header # here. else: # pragma: no cover From 174be277f4e9019f6304bbcc09f6853a311b0de7 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 20:53:47 +0000 Subject: [PATCH 272/331] Add more keyword arguments --- docs/source/conf.py | 2 +- src/mock_vws/_database_matchers.py | 11 +++++++---- src/mock_vws/_flask_server/healthcheck.py | 4 ++-- src/mock_vws/_flask_server/target_manager.py | 4 ++-- src/mock_vws/_flask_server/vwq.py | 4 ++-- src/mock_vws/_flask_server/vws.py | 18 +++++++++++------- src/mock_vws/_query_tools.py | 7 +++++-- .../_query_validators/date_validators.py | 2 +- .../_query_validators/image_validators.py | 2 +- .../include_target_data_validators.py | 2 +- .../num_results_validators.py | 2 +- .../mock_web_services_api.py | 2 +- .../content_length_validators.py | 5 ++++- src/mock_vws/image_matchers.py | 11 +++++++---- src/mock_vws/target_raters.py | 4 ++-- tests/mock_vws/test_date_header.py | 2 +- tests/mock_vws/test_get_duplicates.py | 2 +- tests/mock_vws/test_query.py | 6 +++--- tests/mock_vws/test_target_summary.py | 2 +- 19 files changed, 54 insertions(+), 38 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 308d9bbf1..d02c56bbc 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -43,7 +43,7 @@ # This method of getting the release from the version goes hand in hand with # the ``post-release`` versioning scheme chosen in the ``setuptools-scm`` # configuration. -release = version.split(".post")[0] +release = version.split(sep=".post")[0] project_metadata = importlib.metadata.metadata(distribution_name=project) diff --git a/src/mock_vws/_database_matchers.py b/src/mock_vws/_database_matchers.py index 5e78cf083..41a0316ae 100644 --- a/src/mock_vws/_database_matchers.py +++ b/src/mock_vws/_database_matchers.py @@ -35,9 +35,11 @@ def get_database_matching_client_keys( Raises: ValueError: No database matches the given request. """ - content_type = request_headers.get("Content-Type", "").split(sep=";")[0] + content_type = request_headers.get("Content-Type", default="").split( + sep=";" + )[0] auth_header = request_headers.get("Authorization") - date = request_headers.get("Date", "") + date = request_headers.get("Date", default="") for database in databases: expected_authorization_header = authorization_header( @@ -80,9 +82,10 @@ def get_database_matching_server_keys( Raises: ValueError: No database matches the given request. """ - content_type = request_headers.get("Content-Type", "").split(sep=";")[0] + content_type_header = request_headers.get("Content-Type", default="") + content_type = content_type_header.split(sep=";")[0] auth_header = request_headers.get("Authorization") - date = request_headers.get("Date", "") + date = request_headers.get("Date", default="") for database in databases: expected_authorization_header = authorization_header( diff --git a/src/mock_vws/_flask_server/healthcheck.py b/src/mock_vws/_flask_server/healthcheck.py index a20f3a8cc..39c37a5e2 100644 --- a/src/mock_vws/_flask_server/healthcheck.py +++ b/src/mock_vws/_flask_server/healthcheck.py @@ -15,9 +15,9 @@ def flask_app_healthy(port: int) -> bool: """ Check if the Flask app is healthy. """ - conn = http.client.HTTPConnection("localhost", port) + conn = http.client.HTTPConnection(host="localhost", port=port) try: - conn.request("GET", "/some-random-endpoint") + conn.request(method="GET", url="/some-random-endpoint") response = conn.getresponse() except (TimeoutError, http.client.HTTPException, socket.gaierror): return False diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index eed237669..8c06246f0 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -88,7 +88,7 @@ def delete_database(database_name: str) -> Response: return Response(response="", status=HTTPStatus.OK) -@TARGET_MANAGER_FLASK_APP.route("/databases", methods=[HTTPMethod.GET]) +@TARGET_MANAGER_FLASK_APP.route(rule="/databases", methods=[HTTPMethod.GET]) @beartype def get_databases() -> Response: """ @@ -101,7 +101,7 @@ def get_databases() -> Response: ) -@TARGET_MANAGER_FLASK_APP.route("/databases", methods=[HTTPMethod.POST]) +@TARGET_MANAGER_FLASK_APP.route(rule="/databases", methods=[HTTPMethod.POST]) @beartype def create_database() -> Response: """Create a new database. diff --git a/src/mock_vws/_flask_server/vwq.py b/src/mock_vws/_flask_server/vwq.py index 924941bca..dee12db42 100644 --- a/src/mock_vws/_flask_server/vwq.py +++ b/src/mock_vws/_flask_server/vwq.py @@ -109,7 +109,7 @@ def set_terminate_wsgi_input() -> None: request.environ["wsgi.input_terminated"] = True -@CLOUDRECO_FLASK_APP.errorhandler(ValidatorError) +@CLOUDRECO_FLASK_APP.errorhandler(code_or_exception=ValidatorError) def handle_exceptions(exc: ValidatorError) -> Response: """ Return the error response associated with the given exception. @@ -125,7 +125,7 @@ def handle_exceptions(exc: ValidatorError) -> Response: return response -@CLOUDRECO_FLASK_APP.route("/v1/query", methods=[HTTPMethod.POST]) +@CLOUDRECO_FLASK_APP.route(rule="/v1/query", methods=[HTTPMethod.POST]) def query() -> Response: """ Perform an image recognition query. diff --git a/src/mock_vws/_flask_server/vws.py b/src/mock_vws/_flask_server/vws.py index 7bcbf18e6..2d2f9ac9f 100644 --- a/src/mock_vws/_flask_server/vws.py +++ b/src/mock_vws/_flask_server/vws.py @@ -140,7 +140,7 @@ def validate_request() -> None: ) -@VWS_FLASK_APP.errorhandler(ValidatorError) +@VWS_FLASK_APP.errorhandler(code_or_exception=ValidatorError) def handle_exceptions(exc: ValidatorError) -> Response: """ Return the error response associated with the given exception. @@ -156,7 +156,7 @@ def handle_exceptions(exc: ValidatorError) -> Response: return response -@VWS_FLASK_APP.route("/targets", methods=[HTTPMethod.POST]) +@VWS_FLASK_APP.route(rule="/targets", methods=[HTTPMethod.POST]) @beartype def add_target() -> Response: """Add a target. @@ -228,7 +228,9 @@ def add_target() -> Response: ) -@VWS_FLASK_APP.route("/targets/", methods=[HTTPMethod.GET]) +@VWS_FLASK_APP.route( + rule="/targets/", methods=[HTTPMethod.GET] +) @beartype def get_target(target_id: str) -> Response: """Get details of a target. @@ -337,7 +339,7 @@ def delete_target(target_id: str) -> Response: ) -@VWS_FLASK_APP.route("/summary", methods=[HTTPMethod.GET]) +@VWS_FLASK_APP.route(rule="/summary", methods=[HTTPMethod.GET]) @beartype def database_summary() -> Response: """Get a database summary report. @@ -418,7 +420,7 @@ def target_summary(target_id: str) -> Response: "result_code": ResultCodes.SUCCESS.value, "database_name": database.database_name, "target_name": target.name, - "upload_date": target.upload_date.strftime("%Y-%m-%d"), + "upload_date": target.upload_date.strftime(format="%Y-%m-%d"), "active_flag": target.active_flag, "tracking_rating": target.tracking_rating, "total_recos": target.total_recos, @@ -506,7 +508,7 @@ def get_duplicates(target_id: str) -> Response: ) -@VWS_FLASK_APP.route("/targets", methods=[HTTPMethod.GET]) +@VWS_FLASK_APP.route(rule="/targets", methods=[HTTPMethod.GET]) def target_list() -> Response: """Get a list of all targets. @@ -546,7 +548,9 @@ def target_list() -> Response: ) -@VWS_FLASK_APP.route("/targets/", methods=[HTTPMethod.PUT]) +@VWS_FLASK_APP.route( + rule="/targets/", methods=[HTTPMethod.PUT] +) def update_target(target_id: str) -> Response: """Update a target. diff --git a/src/mock_vws/_query_tools.py b/src/mock_vws/_query_tools.py index 9a4a7a0a0..520afd9ab 100644 --- a/src/mock_vws/_query_tools.py +++ b/src/mock_vws/_query_tools.py @@ -54,8 +54,11 @@ def get_query_match_response_text( content_length=len(request_body), ) - max_num_results = fields.get("max_num_results", "1") - include_target_data = fields.get("include_target_data", "top").lower() + max_num_results = fields.get(key="max_num_results", default="1") + include_target_data = fields.get( + key="include_target_data", + default="top", + ).lower() image_part = files["image"] image_value = image_part.stream.read() diff --git a/src/mock_vws/_query_validators/date_validators.py b/src/mock_vws/_query_validators/date_validators.py index b5cfb2dea..d02e44aaa 100644 --- a/src/mock_vws/_query_validators/date_validators.py +++ b/src/mock_vws/_query_validators/date_validators.py @@ -88,7 +88,7 @@ def validate_date_in_range(*, request_headers: Mapping[str, str]) -> None: date_header = request_headers["Date"] gmt = ZoneInfo(key="GMT") - date = datetime.datetime.fromtimestamp(0, tz=gmt) + date = datetime.datetime.fromtimestamp(timestamp=0, tz=gmt) for date_format in _accepted_date_formats(): with contextlib.suppress(ValueError): date = datetime.datetime.strptime( diff --git a/src/mock_vws/_query_validators/image_validators.py b/src/mock_vws/_query_validators/image_validators.py index e299b4384..203c606de 100644 --- a/src/mock_vws/_query_validators/image_validators.py +++ b/src/mock_vws/_query_validators/image_validators.py @@ -44,7 +44,7 @@ def validate_image_field_given( boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) - if files.get("image") is not None: + if files.get(key="image") is not None: return _LOGGER.warning(msg="The image field is not given.") diff --git a/src/mock_vws/_query_validators/include_target_data_validators.py b/src/mock_vws/_query_validators/include_target_data_validators.py index 684a880e8..5f8277ade 100644 --- a/src/mock_vws/_query_validators/include_target_data_validators.py +++ b/src/mock_vws/_query_validators/include_target_data_validators.py @@ -40,7 +40,7 @@ def validate_include_target_data( boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) - include_target_data = fields.get("include_target_data", "top") + include_target_data = fields.get(key="include_target_data", default="top") allowed_included_target_data = {"top", "all", "none"} if include_target_data.lower() in allowed_included_target_data: return diff --git a/src/mock_vws/_query_validators/num_results_validators.py b/src/mock_vws/_query_validators/num_results_validators.py index bbfe12d0c..ff4b99ae1 100644 --- a/src/mock_vws/_query_validators/num_results_validators.py +++ b/src/mock_vws/_query_validators/num_results_validators.py @@ -46,7 +46,7 @@ def validate_max_num_results( boundary=boundary.encode(encoding="utf-8"), content_length=len(request_body), ) - max_num_results = fields.get("max_num_results", "1") + max_num_results = fields.get(key="max_num_results", default="1") try: max_num_results_int = int(max_num_results) diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index c520025c0..dbe81ac11 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -676,7 +676,7 @@ def target_summary(self, request: PreparedRequest) -> _ResponseType: "result_code": ResultCodes.SUCCESS.value, "database_name": database.database_name, "target_name": target.name, - "upload_date": target.upload_date.strftime("%Y-%m-%d"), + "upload_date": target.upload_date.strftime(format="%Y-%m-%d"), "active_flag": target.active_flag, "tracking_rating": target.tracking_rating, "total_recos": target.total_recos, diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index a9728e4d6..9cebab515 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -84,7 +84,10 @@ def validate_content_length_header_not_too_small( the content length is smaller than the body length. """ body_length = len(request_body) - given_content_length = request_headers.get("Content-Length", body_length) + given_content_length = request_headers.get( + "Content-Length", + default=body_length, + ) given_content_length_value = int(given_content_length) if given_content_length_value < body_length: diff --git a/src/mock_vws/image_matchers.py b/src/mock_vws/image_matchers.py index b1a3c2fc2..eba39996a 100644 --- a/src/mock_vws/image_matchers.py +++ b/src/mock_vws/image_matchers.py @@ -83,16 +83,19 @@ def __call__( first_image_resized = first_image.resize(size=target_size) second_image_resized = second_image.resize(size=target_size) - first_image_np = np.array(first_image_resized, dtype=np.float32) - first_image_tensor = torch.tensor(first_image_np).float() / 255 + first_image_np = np.array(object=first_image_resized, dtype=np.float32) + first_image_tensor = torch.tensor(data=first_image_np).float() / 255 first_image_tensor = first_image_tensor.view( first_image_resized.size[1], first_image_resized.size[0], len(first_image_resized.getbands()), ) - second_image_np = np.array(second_image_resized, dtype=np.float32) - second_image_tensor = torch.tensor(second_image_np).float() / 255 + second_image_np = np.array( + object=second_image_resized, + dtype=np.float32, + ) + second_image_tensor = torch.tensor(data=second_image_np).float() / 255 second_image_tensor = second_image_tensor.view( second_image_resized.size[1], second_image_resized.size[0], diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index 8e2cb1d65..f3c74068f 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -29,8 +29,8 @@ def _get_brisque_target_tracking_rating(*, image_content: bytes) -> int: """ image_file = io.BytesIO(initial_bytes=image_content) image = Image.open(fp=image_file) - image_np = np.array(image, dtype=np.float32) - image_tensor = torch.tensor(image_np).float() / 255 + image_np = np.array(object=image, dtype=np.float32) + image_tensor = torch.tensor(data=image_np).float() / 255 image_tensor = image_tensor.view( image.size[1], image.size[0], diff --git a/tests/mock_vws/test_date_header.py b/tests/mock_vws/test_date_header.py index 4556ca53d..9c4c2302d 100644 --- a/tests/mock_vws/test_date_header.py +++ b/tests/mock_vws/test_date_header.py @@ -110,7 +110,7 @@ def test_incorrect_date_format(endpoint: Endpoint) -> None: gmt = ZoneInfo(key="GMT") with freeze_time(time_to_freeze=datetime.now(tz=gmt)): now = datetime.now(tz=gmt) - date_incorrect_format = now.strftime("%a %b %d %H:%M:%S") + date_incorrect_format = now.strftime(format="%a %b %d %H:%M:%S") authorization_string = authorization_header( access_key=endpoint.access_key, diff --git a/tests/mock_vws/test_get_duplicates.py b/tests/mock_vws/test_get_duplicates.py index 671c90d58..c52b64730 100644 --- a/tests/mock_vws/test_get_duplicates.py +++ b/tests/mock_vws/test_get_duplicates.py @@ -78,7 +78,7 @@ def test_duplicates_not_same( similar_image_buffer = io.BytesIO() pil_similar_image = Image.open(fp=similar_image_data) # Re-save means similar but not identical. - pil_similar_image.save(similar_image_buffer, format="JPEG") + pil_similar_image.save(fp=similar_image_buffer, format="JPEG") assert similar_image_buffer.getvalue() != image_data.getvalue() original_target_id = vws_client.add_target( diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 84457a62f..d12fa5a7e 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -573,7 +573,7 @@ def test_match_exact( application_metadata=metadata_encoded, ) - approximate_target_created = calendar.timegm(time.gmtime()) + approximate_target_created = calendar.timegm(tuple=time.gmtime()) vws_client.wait_for_target_processed(target_id=target_id) @@ -1829,7 +1829,7 @@ def test_updated_target( application_metadata=metadata_encoded, ) - calendar.timegm(time.gmtime()) + calendar.timegm(tuple=time.gmtime()) vws_client.wait_for_target_processed(target_id=target_id) @@ -1851,7 +1851,7 @@ def test_updated_target( application_metadata=new_metadata_encoded, ) - approximate_target_updated = calendar.timegm(time.gmtime()) + approximate_target_updated = calendar.timegm(tuple=time.gmtime()) vws_client.wait_for_target_processed(target_id=target_id) diff --git a/tests/mock_vws/test_target_summary.py b/tests/mock_vws/test_target_summary.py index f1d61c237..c432e78b4 100644 --- a/tests/mock_vws/test_target_summary.py +++ b/tests/mock_vws/test_target_summary.py @@ -94,7 +94,7 @@ def test_after_processing( It also shows that ``reco_rating`` is not provided even when the status is success. """ - image_file = request.getfixturevalue(image_fixture_name) + image_file = request.getfixturevalue(argname=image_fixture_name) target_id = vws_client.add_target( name="example", From d2c98eda85036c25cce5b0767fb02a16e4a26697 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 20:59:54 +0000 Subject: [PATCH 273/331] Add more keyword arguments --- .../_services_validators/content_length_validators.py | 10 ++++++++-- tests/conftest.py | 2 +- tests/mock_vws/test_query.py | 6 +++--- tests/mock_vws/test_requests_mock_usage.py | 9 +++++++-- tests/mock_vws/utils/__init__.py | 2 +- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index 9cebab515..0cf0f372a 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -33,7 +33,10 @@ def validate_content_length_header_is_int( integer """ body_length = len(request_body) - given_content_length = request_headers.get("Content-Length", body_length) + given_content_length = request_headers.get( + "Content-Length", + default=body_length, + ) try: int(given_content_length) @@ -59,7 +62,10 @@ def validate_content_length_header_not_too_large( that the content length is greater than the body length. """ body_length = len(request_body) - given_content_length = request_headers.get("Content-Length", body_length) + given_content_length = request_headers.get( + "Content-Length", + default=body_length, + ) given_content_length_value = int(given_content_length) # We skip coverage here as running a test to cover this is very slow. if given_content_length_value > body_length: # pragma: no cover diff --git a/tests/conftest.py b/tests/conftest.py index b8c06558f..4c05f7cc1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -108,7 +108,7 @@ def endpoint(request: pytest.FixtureRequest) -> Endpoint: """ Return details of an endpoint for the Target API or the Query API. """ - endpoint_fixture: Endpoint = request.getfixturevalue(request.param) + endpoint_fixture: Endpoint = request.getfixturevalue(argname=request.param) return endpoint_fixture diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index d12fa5a7e..151240777 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -665,7 +665,7 @@ def test_match_similar( similar_image_data = copy.copy(x=high_quality_image) pil_similar_image = Image.open(fp=similar_image_data) # Re-save means similar but not identical. - pil_similar_image.save(similar_image_buffer, format="JPEG") + pil_similar_image.save(fp=similar_image_buffer, format="JPEG") (matching_target,) = cloud_reco_client.query( image=similar_image_buffer, @@ -1910,7 +1910,7 @@ def test_deleted_active( # # We retry to allow for this difference. for attempt in Retrying( - wait=wait_fixed(0.1), + wait=wait_fixed(wait=0.1), stop=stop_after_delay(max_delay=3), retry=retry_if_exception_type( exception_types=(AssertionError,), @@ -2018,7 +2018,7 @@ def test_date_formats( gmt = ZoneInfo(key="GMT") now = datetime.datetime.now(tz=gmt) - date = now.strftime(datetime_format) + date = now.strftime(format=datetime_format) request_path = "/v1/query" content, content_type_header = encode_multipart_formdata(fields=body) method = HTTPMethod.POST diff --git a/tests/mock_vws/test_requests_mock_usage.py b/tests/mock_vws/test_requests_mock_usage.py index 09ddbc14e..3cb3471f6 100644 --- a/tests/mock_vws/test_requests_mock_usage.py +++ b/tests/mock_vws/test_requests_mock_usage.py @@ -376,7 +376,12 @@ def test_date_changes() -> None: The date that the response is sent is in the response Date header. """ new_year = 2012 - new_time = datetime.datetime(new_year, 1, 1, tzinfo=datetime.UTC) + new_time = datetime.datetime( + year=new_year, + month=1, + day=1, + tzinfo=datetime.UTC, + ) with MockVWS(), freeze_time(time_to_freeze=new_time): response = requests.get( url="https://vws.vuforia.com/summary", @@ -445,7 +450,7 @@ def test_duplicate_keys() -> None: (bad_database_name_db, database_name_conflict_error), ): with pytest.raises( - ValueError, + expected_exception=ValueError, match=expected_message + "$", ): mock.add_database(database=bad_database) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 3edc7507e..487bbb5b3 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -82,7 +82,7 @@ def auth_header_content_type(self) -> str: """ The content type to use for the `Authorization` header. """ - full_content_type = self.headers.get("Content-Type", "") + full_content_type = self.headers.get("Content-Type", default="") return full_content_type.split(sep=";")[0] From 61dcec25ac18ff96e5311aef921bc0a76992b373 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 21:00:24 +0000 Subject: [PATCH 274/331] Use keyword arguments in more places --- pyproject.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f4090dcea..635017fb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,6 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy[faster-cache]==1.14.0", - "mypy-strict-kwargs==2024.12.23.2", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", @@ -384,7 +383,6 @@ files = [ "." ] exclude = [ "build" ] plugins = [ "pydantic.mypy", - "mypy_strict_kwargs", ] follow_untyped_imports = true From fd2124c927ef2146f4ebc437c401f5077b97e685 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 23 Dec 2024 23:30:02 +0000 Subject: [PATCH 275/331] Work around the fact that dict does not truly implement Mapping (get needs positional args in dict) --- src/mock_vws/_database_matchers.py | 18 ++++++++++-------- .../content_type_validators.py | 3 ++- .../content_length_validators.py | 15 +++++++++------ .../content_type_validators.py | 6 +++++- tests/mock_vws/utils/__init__.py | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/mock_vws/_database_matchers.py b/src/mock_vws/_database_matchers.py index 41a0316ae..211e4c70f 100644 --- a/src/mock_vws/_database_matchers.py +++ b/src/mock_vws/_database_matchers.py @@ -35,11 +35,12 @@ def get_database_matching_client_keys( Raises: ValueError: No database matches the given request. """ - content_type = request_headers.get("Content-Type", default="").split( - sep=";" - )[0] - auth_header = request_headers.get("Authorization") - date = request_headers.get("Date", default="") + request_headers_dict = dict(request_headers) + content_type = request_headers_dict.get("Content-Type", "").split(sep=";")[ + 0 + ] + auth_header = request_headers_dict.get("Authorization") + date = request_headers_dict.get("Date", "") for database in databases: expected_authorization_header = authorization_header( @@ -82,10 +83,11 @@ def get_database_matching_server_keys( Raises: ValueError: No database matches the given request. """ - content_type_header = request_headers.get("Content-Type", default="") + request_headers_dict = dict(request_headers) + content_type_header = request_headers_dict.get("Content-Type", "") content_type = content_type_header.split(sep=";")[0] - auth_header = request_headers.get("Authorization") - date = request_headers.get("Date", default="") + auth_header = request_headers_dict.get("Authorization") + date = request_headers_dict.get("Date", "") for database in databases: expected_authorization_header = authorization_header( diff --git a/src/mock_vws/_query_validators/content_type_validators.py b/src/mock_vws/_query_validators/content_type_validators.py index aa6eeeb1d..bd474c6ab 100644 --- a/src/mock_vws/_query_validators/content_type_validators.py +++ b/src/mock_vws/_query_validators/content_type_validators.py @@ -38,7 +38,8 @@ def validate_content_type_header( NoContentTypeError: The content type header is either empty or not given. """ - content_type_header = request_headers.get("Content-Type", default="") + request_headers_dict = dict(request_headers) + content_type_header = request_headers_dict.get("Content-Type", "") if not content_type_header: _LOGGER.warning(msg="The content type header is empty.") raise NoContentTypeError diff --git a/src/mock_vws/_services_validators/content_length_validators.py b/src/mock_vws/_services_validators/content_length_validators.py index 0cf0f372a..9e2cc966b 100644 --- a/src/mock_vws/_services_validators/content_length_validators.py +++ b/src/mock_vws/_services_validators/content_length_validators.py @@ -33,9 +33,10 @@ def validate_content_length_header_is_int( integer """ body_length = len(request_body) - given_content_length = request_headers.get( + request_headers_dict = dict(request_headers) + given_content_length = request_headers_dict.get( "Content-Length", - default=body_length, + body_length, ) try: @@ -62,9 +63,10 @@ def validate_content_length_header_not_too_large( that the content length is greater than the body length. """ body_length = len(request_body) - given_content_length = request_headers.get( + request_headers_dict = dict(request_headers) + given_content_length = request_headers_dict.get( "Content-Length", - default=body_length, + body_length, ) given_content_length_value = int(given_content_length) # We skip coverage here as running a test to cover this is very slow. @@ -90,9 +92,10 @@ def validate_content_length_header_not_too_small( the content length is smaller than the body length. """ body_length = len(request_body) - given_content_length = request_headers.get( + request_headers_dict = dict(request_headers) + given_content_length = request_headers_dict.get( "Content-Length", - default=body_length, + body_length, ) given_content_length_value = int(given_content_length) diff --git a/src/mock_vws/_services_validators/content_type_validators.py b/src/mock_vws/_services_validators/content_type_validators.py index 0e98eb8bd..4c97c4cdf 100644 --- a/src/mock_vws/_services_validators/content_type_validators.py +++ b/src/mock_vws/_services_validators/content_type_validators.py @@ -30,10 +30,14 @@ def validate_content_type_header_given( AuthenticationFailureError: No ``Content-Type`` header is given and the request requires one. """ + request_headers_dict = dict(request_headers) request_needs_content_type = bool( request_method in {HTTPMethod.POST, HTTPMethod.PUT}, ) - if request_headers.get("Content-Type") or not request_needs_content_type: + if ( + request_headers_dict.get("Content-Type") + or not request_needs_content_type + ): return _LOGGER.warning(msg="No Content-Type header is given.") diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 487bbb5b3..3edc7507e 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -82,7 +82,7 @@ def auth_header_content_type(self) -> str: """ The content type to use for the `Authorization` header. """ - full_content_type = self.headers.get("Content-Type", default="") + full_content_type = self.headers.get("Content-Type", "") return full_content_type.split(sep=";")[0] From 384cf2f90dc7e77c008959f14255915cdbdbc8a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 06:02:48 +0000 Subject: [PATCH 276/331] Bump pylint from 3.3.2 to 3.3.3 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.3.2 to 3.3.3. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.3.2...v3.3.3) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 635017fb8..7d5a26bb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,7 @@ optional-dependencies.dev = [ "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", - "pylint==3.3.2", + "pylint==3.3.3", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", "pyright==1.1.391", From 8753d910397a12f831fb4e3605a658ceacc9c862 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Dec 2024 06:24:09 +0000 Subject: [PATCH 277/331] Add new plugin --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 635017fb8..f4090dcea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,6 +65,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy[faster-cache]==1.14.0", + "mypy-strict-kwargs==2024.12.23.2", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", @@ -383,6 +384,7 @@ files = [ "." ] exclude = [ "build" ] plugins = [ "pydantic.mypy", + "mypy_strict_kwargs", ] follow_untyped_imports = true From f4d122f54cdb813106fad7ae830c7a64493b1514 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Dec 2024 10:12:44 +0000 Subject: [PATCH 278/331] Fix one keyword argument --- tests/mock_vws/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mock_vws/utils/__init__.py b/tests/mock_vws/utils/__init__.py index 3edc7507e..b3b92db61 100644 --- a/tests/mock_vws/utils/__init__.py +++ b/tests/mock_vws/utils/__init__.py @@ -82,7 +82,7 @@ def auth_header_content_type(self) -> str: """ The content type to use for the `Authorization` header. """ - full_content_type = self.headers.get("Content-Type", "") + full_content_type = dict(self.headers).get("Content-Type", "") return full_content_type.split(sep=";")[0] From 90a57438cb28010bdea1582fdaebe0c1572b88ab Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Dec 2024 12:15:39 +0000 Subject: [PATCH 279/331] Only allow asserts in tests --- admin/create_secrets_files.py | 4 +++- docs/source/conf.py | 6 +++++- pyproject.toml | 7 +++++++ src/mock_vws/_requests_mock_server/decorators.py | 2 +- src/mock_vws/_requests_mock_server/mock_web_query_api.py | 3 +-- .../_requests_mock_server/mock_web_services_api.py | 1 - src/mock_vws/target_raters.py | 4 ++-- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/admin/create_secrets_files.py b/admin/create_secrets_files.py index 402f17dc0..702091c87 100644 --- a/admin/create_secrets_files.py +++ b/admin/create_secrets_files.py @@ -34,7 +34,9 @@ def main() -> None: existing_secrets_file = Path( os.environ["EXISTING_SECRETS_FILE"] ).expanduser() - assert existing_secrets_file.exists(), existing_secrets_file + if not existing_secrets_file.exists(): + msg = f"Existing secrets file does not exist: {existing_secrets_file}" + raise FileNotFoundError(msg) load_dotenv(dotenv_path=existing_secrets_file) new_secrets_dir.mkdir(exist_ok=True) diff --git a/docs/source/conf.py b/docs/source/conf.py index d02c56bbc..510bf6860 100755 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -50,7 +50,11 @@ requires_python = project_metadata["Requires-Python"] specifiers = SpecifierSet(specifiers=requires_python) (specifier,) = specifiers -assert specifier.operator == ">=" +if specifier.operator != ">=": + msg = ( + f"We only support '>=' for Requires-Python, got {specifier.operator}." + ) + raise ValueError(msg) minimum_python_version = specifier.version language = "en" diff --git a/pyproject.toml b/pyproject.toml index 7d5a26bb8..f8e9e6483 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -165,10 +165,17 @@ lint.ignore = [ # Also, allow 'assert' in other code as it is the standard for Python type hint # narrowing - see # https://mypy.readthedocs.io/en/stable/type_narrowing.html#type-narrowing-expressions. + # "S101", +] + +lint.per-file-ignores."ci/test_custom_linters.py" = [ + # Allow asserts in tests. "S101", ] lint.per-file-ignores."tests/**" = [ + # Allow asserts in tests. + "S101", # Allow possible hardcoded passwords in tests. "S105", "S106", diff --git a/src/mock_vws/_requests_mock_server/decorators.py b/src/mock_vws/_requests_mock_server/decorators.py index b9423b451..6acdd899d 100644 --- a/src/mock_vws/_requests_mock_server/decorators.py +++ b/src/mock_vws/_requests_mock_server/decorators.py @@ -192,7 +192,7 @@ def __exit__(self, *exc: object) -> Literal[False]: """ # __exit__ needs this to be passed in but vulture thinks that it is # unused, so we "use" it here. - assert isinstance(exc, tuple) + del exc self._mock.stop() return False diff --git a/src/mock_vws/_requests_mock_server/mock_web_query_api.py b/src/mock_vws/_requests_mock_server/mock_web_query_api.py index bbe00b7a5..f22cd9c69 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_query_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_query_api.py @@ -69,10 +69,9 @@ def _body_bytes(request: PreparedRequest) -> bytes: """ Return the body of a request as bytes. """ - if request.body is None: + if request.body is None or isinstance(request.body, str): return b"" - assert isinstance(request.body, bytes) return request.body diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index dbe81ac11..eab879a7a 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -90,7 +90,6 @@ def _body_bytes(request: PreparedRequest) -> bytes: if isinstance(request.body, str): return request.body.encode(encoding="utf-8") - assert isinstance(request.body, bytes) return request.body diff --git a/src/mock_vws/target_raters.py b/src/mock_vws/target_raters.py index f3c74068f..d52c48122 100644 --- a/src/mock_vws/target_raters.py +++ b/src/mock_vws/target_raters.py @@ -73,7 +73,7 @@ def __call__(self, image_content: bytes) -> int: Args: image_content: A target's image's content. """ - assert image_content + del image_content return secrets.randbelow(exclusive_upper_bound=6) @@ -96,7 +96,7 @@ def __call__(self, image_content: bytes) -> int: Args: image_content: A target's image's content. """ - assert image_content + del image_content return self._rating From ea2a58974e1164d240674e928fb9cfaeef9e5787 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Tue, 24 Dec 2024 23:05:22 +0000 Subject: [PATCH 280/331] Bump plugin --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 814e278f1..dac8abf23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy[faster-cache]==1.14.0", - "mypy-strict-kwargs==2024.12.23.2", + "mypy-strict-kwargs==2024.12.24", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 41ff5c8b118b16294dbcde443abf415883480440 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 25 Dec 2024 00:10:34 +0000 Subject: [PATCH 281/331] Use more keyword arguments in docs --- README.rst | 2 +- docs/source/basic-example.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 52cd0dc66..d97f68f7d 100644 --- a/README.rst +++ b/README.rst @@ -32,7 +32,7 @@ This requires Python |minimum-python-version|\+. database = VuforiaDatabase() mock.add_database(database=database) # This will use the Vuforia mock. - requests.get("https://vws.vuforia.com/summary", timeout=30) + requests.get(url="https://vws.vuforia.com/summary", timeout=30) By default, an exception will be raised if any requests to unmocked addresses are made. diff --git a/docs/source/basic-example.rst b/docs/source/basic-example.rst index d7a28ed6b..35c12e200 100644 --- a/docs/source/basic-example.rst +++ b/docs/source/basic-example.rst @@ -13,7 +13,7 @@ Using the mock redirects requests to Vuforia made with `requests`_ to an in-memo database = VuforiaDatabase() mock.add_database(database=database) # This will use the Vuforia mock. - requests.get("https://vws.vuforia.com/summary", timeout=30) + requests.get(url="https://vws.vuforia.com/summary", timeout=30) By default, an exception will be raised if any requests to unmocked addresses are made. From 7a942ac66a33ad85815f8aa4da58dab0b824fd2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 25 Dec 2024 05:43:52 +0000 Subject: [PATCH 282/331] Bump mypy-strict-kwargs from 2024.12.24 to 2024.12.25 Bumps [mypy-strict-kwargs](https://github.com/adamtheturtle/mypy-strict-kwargs) from 2024.12.24 to 2024.12.25. - [Release notes](https://github.com/adamtheturtle/mypy-strict-kwargs/releases) - [Changelog](https://github.com/adamtheturtle/mypy-strict-kwargs/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/mypy-strict-kwargs/compare/2024.12.24...2024.12.25) --- updated-dependencies: - dependency-name: mypy-strict-kwargs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f60c07029..6322db872 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,7 +65,7 @@ optional-dependencies.dev = [ "furo==2024.8.6", "interrogate==1.7.0", "mypy[faster-cache]==1.14.0", - "mypy-strict-kwargs==2024.12.24", + "mypy-strict-kwargs==2024.12.25", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From d02b9acb7aa0aeab02ef37612924d51637156da5 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 26 Dec 2024 07:02:10 +0000 Subject: [PATCH 283/331] Disable type ignore comments for pyright --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 6322db872..6d9ef2c42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -396,6 +396,8 @@ plugins = [ follow_untyped_imports = true [tool.pyright] + +enableTypeIgnoreComments = false reportUnnecessaryTypeIgnoreComment = true typeCheckingMode = "strict" From b40b93bc4a79a88ceffcb99a264818eeb0f36cd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Dec 2024 05:28:27 +0000 Subject: [PATCH 284/331] Bump doccmd from 2024.11.14 to 2024.12.26 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.11.14 to 2024.12.26. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.11.14...2024.12.26) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6d9ef2c42..5d1cde91d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.21.2", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.11.14", + "doccmd==2024.12.26", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From 25065df2b6b1fb3261fe450561891920b7c3f35b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 05:42:05 +0000 Subject: [PATCH 285/331] Bump actionlint-py from 1.7.4.20 to 1.7.5.21 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.4.20 to 1.7.5.21. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.4.20...v1.7.5.21) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5d1cde91d..bb08001e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "werkzeug>=3.1.2", ] optional-dependencies.dev = [ - "actionlint-py==1.7.4.20", + "actionlint-py==1.7.5.21", "check-manifest==0.50", "check-wheel-contents==0.6.1", "deptry==0.21.2", From 294214a566b4db30d81f7142199a1e839924d3b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 05:42:09 +0000 Subject: [PATCH 286/331] Bump types-pyyaml from 6.0.12.20241221 to 6.0.12.20241230 Bumps [types-pyyaml](https://github.com/python/typeshed) from 6.0.12.20241221 to 6.0.12.20241230. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-pyyaml dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5d1cde91d..082771c14 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -97,7 +97,7 @@ optional-dependencies.dev = [ "sybil==9.0.0", "tenacity==9.0.0", "types-docker==7.1.0.20240827", - "types-pyyaml==6.0.12.20241221", + "types-pyyaml==6.0.12.20241230", "types-requests==2.32.0.20241016", "urllib3==2.3.0", "vulture==2.14", From 0d2c6f77ad5cae4c78a41a204be0079b258ed3f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 07:28:08 +0000 Subject: [PATCH 287/331] Bump types-docker from 7.1.0.20240827 to 7.1.0.20241229 Bumps [types-docker](https://github.com/python/typeshed) from 7.1.0.20240827 to 7.1.0.20241229. - [Commits](https://github.com/python/typeshed/commits) --- updated-dependencies: - dependency-name: types-docker dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3f7842016..d64b33c73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,7 @@ optional-dependencies.dev = [ "sphinxcontrib-spelling==8.0.1", "sybil==9.0.0", "tenacity==9.0.0", - "types-docker==7.1.0.20240827", + "types-docker==7.1.0.20241229", "types-pyyaml==6.0.12.20241230", "types-requests==2.32.0.20241016", "urllib3==2.3.0", From 59c9ef211db09d06b6114a9530bb710bf5373a0d Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Mon, 30 Dec 2024 11:04:10 +0000 Subject: [PATCH 288/331] Set release fetch-depth to 0 with a comment why --- .github/workflows/release.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3332fb373..7790aca81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,13 @@ jobs: steps: - uses: actions/checkout@v4 + with: + # Fetch all history including tags. + # Needed to find the latest tag. + # + # Also, avoids + # https://github.com/stefanzweifel/git-auto-commit-action/issues/99. + fetch-depth: 0 - name: Install uv uses: astral-sh/setup-uv@v5 From c34a159587f0248440c197aebd63d9810301212e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 31 Dec 2024 05:26:13 +0000 Subject: [PATCH 289/331] Bump mypy[faster-cache] from 1.14.0 to 1.14.1 Bumps [mypy[faster-cache]](https://github.com/python/mypy) from 1.14.0 to 1.14.1. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.14.0...v1.14.1) --- updated-dependencies: - dependency-name: mypy[faster-cache] dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d64b33c73..13ed74fe2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy[faster-cache]==1.14.0", + "mypy[faster-cache]==1.14.1", "mypy-strict-kwargs==2024.12.25", "pre-commit==4.0.1", "pydocstyle==6.3", From 17d7b93fc6609c7d59d81169b965d34a36e05f0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 05:34:17 +0000 Subject: [PATCH 290/331] Bump ruff from 0.8.4 to 0.8.5 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.4 to 0.8.5. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.4...0.8.5) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 13ed74fe2..48f0eac65 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.4", + "ruff==0.8.5", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 65430525cb4b72d4da4ae7ac9db19fd81c296b5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 05:34:36 +0000 Subject: [PATCH 291/331] Bump sphinx-substitution-extensions from 2024.10.17 to 2025.1.2 Bumps [sphinx-substitution-extensions](https://github.com/adamtheturtle/sphinx-substitution-extensions) from 2024.10.17 to 2025.1.2. - [Release notes](https://github.com/adamtheturtle/sphinx-substitution-extensions/releases) - [Changelog](https://github.com/adamtheturtle/sphinx-substitution-extensions/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/sphinx-substitution-extensions/compare/2024.10.17...2025.01.02) --- updated-dependencies: - dependency-name: sphinx-substitution-extensions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 13ed74fe2..3562ca5ab 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,7 +90,7 @@ optional-dependencies.dev = [ "sphinx==8.1.3", "sphinx-copybutton==0.5.2", "sphinx-paramlinks==0.6", - "sphinx-substitution-extensions==2024.10.17", + "sphinx-substitution-extensions==2025.1.2", "sphinx-toolbox==3.8.1", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8.0.1", From 132b322a593da883769b8a892ea94d4055652d0a Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 5 Jan 2025 10:26:14 +0000 Subject: [PATCH 292/331] Git ignore DS_Store files --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0a4d3ec0c..556e31308 100644 --- a/.gitignore +++ b/.gitignore @@ -98,8 +98,9 @@ secrets.tar # mypy .mypy_cache/ -# macOS attributes -*.DS_Store +# Ignore Mac DS_Store files +.DS_Store +**/.DS_Store # pyre .pyre/ From fce961283227c4206af852545ea0d464f42019f0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 5 Jan 2025 12:45:17 +0000 Subject: [PATCH 293/331] Add sphinx-lint --- .pre-commit-config.yaml | 129 +++++++++++++++++++++------------------- pyproject.toml | 1 + 2 files changed, 70 insertions(+), 60 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9799e0563..8008273f8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,42 @@ --- fail_fast: true +# We use system Python, with required dependencies specified in pyproject.toml. +# We therefore cannot use those dependencies in pre-commit CI. +ci: + skip: + - actionlint + - sphinx-lint + - check-manifest + - custom-linters + - deptry + - doc8 + - docs + - interrogate + - interrogate-docs + - linkcheck + - mypy + - mypy-docs + - pylint + - pyproject-fmt-fix + - pyright + - pyright-docs + - pyright-verifytypes + - pyroma + - ruff-check-fix + - ruff-check-fix-docs + - ruff-format-fix + - ruff-format-fix-docs + - docformatter + - shellcheck + - shellcheck-docs + - shfmt + - shfmt-docs + - spelling + - vulture + - vulture-docs + - yamlfix + # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks default_install_hook_types: [pre-commit, pre-push, commit-msg] @@ -49,7 +85,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: actionlint name: actionlint @@ -57,21 +93,21 @@ repos: language: python pass_filenames: false types_or: [yaml] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: docformatter name: docformatter entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash language: python types_or: [shell] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: shellcheck-docs name: shellcheck-docs @@ -80,14 +116,14 @@ repos: --shell=bash --exclude=SC2215" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 language: python types_or: [shell] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: shfmt-docs name: shfmt-docs @@ -95,7 +131,7 @@ repos: --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: mypy name: mypy @@ -104,7 +140,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: mypy-docs name: mypy-docs @@ -119,7 +155,7 @@ repos: entry: uv run --extra=dev -m check_manifest language: python pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pyright name: pyright @@ -128,7 +164,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pyright-docs name: pyright-docs @@ -144,7 +180,7 @@ repos: language: python pass_filenames: false types_or: [python] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: vulture name: vulture @@ -152,7 +188,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: vulture-docs name: vulture docs @@ -160,7 +196,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pyroma name: pyroma @@ -168,14 +204,14 @@ repos: language: python pass_filenames: false types_or: [toml] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: deptry name: deptry entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pylint name: pylint @@ -183,7 +219,7 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pylint-docs name: pylint-docs @@ -197,21 +233,21 @@ repos: entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: ruff-check-fix-docs name: Ruff check fix docs entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: ruff-format-fix name: Ruff format entry: uv run --extra=dev -m ruff format language: python types_or: [python] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: ruff-format-fix-docs name: Ruff format docs @@ -219,14 +255,14 @@ repos: format" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: doc8 name: doc8 entry: uv run --extra=dev -m doc8 language: python types_or: [rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: interrogate name: interrogate @@ -240,7 +276,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: pyproject-fmt-fix name: pyproject-fmt @@ -256,7 +292,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: spelling name: spelling @@ -265,7 +301,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: docs name: Build Documentation @@ -273,46 +309,19 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] - id: yamlfix name: pyproject-fmt entry: uv run --extra=dev yamlfix language: python types_or: [yaml] - additional_dependencies: [uv==0.4.25] + additional_dependencies: [uv==0.5.14] -# We use system Python, with required dependencies specified in pyproject.toml. -# We therefore cannot use those dependencies in pre-commit CI. -ci: - skip: - - actionlint - - check-manifest - - custom-linters - - deptry - - doc8 - - docs - - interrogate - - interrogate-docs - - linkcheck - - mypy - - mypy-docs - - pylint - - pyproject-fmt-fix - - pyright - - pyright-docs - - pyright-verifytypes - - pyroma - - ruff-check-fix - - ruff-check-fix-docs - - ruff-format-fix - - ruff-format-fix-docs - - docformatter - - shellcheck - - shellcheck-docs - - shfmt - - shfmt-docs - - spelling - - vulture - - vulture-docs - - yamlfix + - id: sphinx-lint + name: sphinx-lint + entry: uv run --extra=dev sphinx-lint --enable=all --disable=line-too-long + *.rst + language: python + types_or: [rst] + additional_dependencies: [uv==0.5.14] diff --git a/pyproject.toml b/pyproject.toml index f5d79abc1..c97244e1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,6 +89,7 @@ optional-dependencies.dev = [ "shfmt-py==3.7.0.1", "sphinx==8.1.3", "sphinx-copybutton==0.5.2", + "sphinx-lint==1.0.0", "sphinx-paramlinks==0.6", "sphinx-substitution-extensions==2025.1.2", "sphinx-toolbox==3.8.1", From d502e500555eb4b38012e92724ee31e6d33b6301 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 5 Jan 2025 12:49:42 +0000 Subject: [PATCH 294/331] Add sphinx-lint --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8008273f8..93438701d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -321,7 +321,7 @@ repos: - id: sphinx-lint name: sphinx-lint entry: uv run --extra=dev sphinx-lint --enable=all --disable=line-too-long - *.rst + README.rst CHANGELOG.rst language: python types_or: [rst] additional_dependencies: [uv==0.5.14] From d281764ed04afc459844be0d97b905ead68f64ea Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sun, 5 Jan 2025 13:02:17 +0000 Subject: [PATCH 295/331] Add sphinx-lint --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 93438701d..958af8ee1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -321,7 +321,6 @@ repos: - id: sphinx-lint name: sphinx-lint entry: uv run --extra=dev sphinx-lint --enable=all --disable=line-too-long - README.rst CHANGELOG.rst language: python types_or: [rst] additional_dependencies: [uv==0.5.14] From 58de237f7ebff86c1e0840bba902c0bbed14ad21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 05:30:26 +0000 Subject: [PATCH 296/331] Bump ruff from 0.8.5 to 0.8.6 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.5 to 0.8.6. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.5...0.8.6) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c97244e1b..fb1e659be 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.5", + "ruff==0.8.6", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From e4db3b8dc03f303bc89c70bb189a83098a07b442 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 05:29:47 +0000 Subject: [PATCH 297/331] Bump actionlint-py from 1.7.5.21 to 1.7.6.22 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.5.21 to 1.7.6.22. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.5.21...v1.7.6.22) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fb1e659be..41a94e8ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "werkzeug>=3.1.2", ] optional-dependencies.dev = [ - "actionlint-py==1.7.5.21", + "actionlint-py==1.7.6.22", "check-manifest==0.50", "check-wheel-contents==0.6.1", "deptry==0.21.2", From dffcc6dd24ca4d93341caf9bb1485ffd0f65020b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 05:30:44 +0000 Subject: [PATCH 298/331] Bump docker/build-push-action from 6.10.0 to 6.11.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.10.0 to 6.11.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.10.0...v6.11.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 725d9cc18..a667b6f83 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7790aca81..349767e76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,7 +110,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -121,7 +121,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -132,7 +132,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.10.0 + uses: docker/build-push-action@v6.11.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From bf93ea100d043a6161bf7ec01bbf9757e1da1aef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 05:35:11 +0000 Subject: [PATCH 299/331] Bump ruff from 0.8.6 to 0.9.0 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.8.6 to 0.9.0. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.8.6...0.9.0) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 41a94e8ad..e0ed1afcb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2024.8.30.1", - "ruff==0.8.6", + "ruff==0.9.0", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From a41ecc6285eba28cf49c1174f4f5b21bd246b2f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 05:29:43 +0000 Subject: [PATCH 300/331] Bump doccmd from 2024.12.26 to 2025.1.11 Bumps [doccmd](https://github.com/adamtheturtle/doccmd) from 2024.12.26 to 2025.1.11. - [Release notes](https://github.com/adamtheturtle/doccmd/releases) - [Changelog](https://github.com/adamtheturtle/doccmd/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/doccmd/compare/2024.12.26...2025.01.11) --- updated-dependencies: - dependency-name: doccmd dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e0ed1afcb..216b494f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ optional-dependencies.dev = [ "deptry==0.21.2", "dirty-equals==0.8.0", "doc8==1.1.1", - "doccmd==2024.12.26", + "doccmd==2025.1.11", "docformatter==1.7.5", "docker==7.1.0", "enum-tools[sphinx]==0.12.0", From 80310294d52ed44a809726e3cea7b27418b5487b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:05:12 +0000 Subject: [PATCH 301/331] Bump requests-mock-flask from 2024.8.30.1 to 2025.1.13 Bumps [requests-mock-flask](https://github.com/adamtheturtle/requests-mock-flask) from 2024.8.30.1 to 2025.1.13. - [Release notes](https://github.com/adamtheturtle/requests-mock-flask/releases) - [Changelog](https://github.com/adamtheturtle/requests-mock-flask/blob/main/CHANGELOG.rst) - [Commits](https://github.com/adamtheturtle/requests-mock-flask/compare/2024.08.30.1...2025.01.13) --- updated-dependencies: - dependency-name: requests-mock-flask dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 216b494f4..8ea8323d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,7 +80,7 @@ optional-dependencies.dev = [ "pytest-xdist==3.6.1", "python-dotenv==1.0.1", "pyyaml==6.0.2", - "requests-mock-flask==2024.8.30.1", + "requests-mock-flask==2025.1.13", "ruff==0.9.0", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will From c2045d94d82faed9a9bc12b74b6dbb02d9a72ef3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:43:01 +0000 Subject: [PATCH 302/331] Bump ruff from 0.9.0 to 0.9.1 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.0 to 0.9.1. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.0...0.9.1) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8ea8323d5..5084f837b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.0", + "ruff==0.9.1", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 117db43645c30c7aa76efc0021fc28a7cad93314 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:53:36 +0000 Subject: [PATCH 303/331] Bump dirty-equals from 0.8.0 to 0.9.0 Bumps [dirty-equals](https://github.com/samuelcolvin/dirty-equals) from 0.8.0 to 0.9.0. - [Release notes](https://github.com/samuelcolvin/dirty-equals/releases) - [Commits](https://github.com/samuelcolvin/dirty-equals/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: dirty-equals dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8ea8323d5..22dbfa59a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ optional-dependencies.dev = [ "check-manifest==0.50", "check-wheel-contents==0.6.1", "deptry==0.21.2", - "dirty-equals==0.8.0", + "dirty-equals==0.9.0", "doc8==1.1.1", "doccmd==2025.1.11", "docformatter==1.7.5", From e71045e323a3119bd5bd9bf95444349d3860da43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:04:16 +0000 Subject: [PATCH 304/331] Bump deptry from 0.21.2 to 0.22.0 Bumps [deptry](https://github.com/fpgmaas/deptry) from 0.21.2 to 0.22.0. - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.21.2...0.22.0) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 51b96465a..c408adbbf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ optional-dependencies.dev = [ "actionlint-py==1.7.6.22", "check-manifest==0.50", "check-wheel-contents==0.6.1", - "deptry==0.21.2", + "deptry==0.22.0", "dirty-equals==0.9.0", "doc8==1.1.1", "doccmd==2025.1.11", From 8af488931d5c416f3f935df17dfb38a578d2fd1f Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 16 Jan 2025 08:30:11 +0000 Subject: [PATCH 305/331] Bump uv in pre-commit hooks to 0.5.20 --- .pre-commit-config.yaml | 54 ++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 958af8ee1..342a9d887 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -85,7 +85,7 @@ repos: language: python types_or: [yaml, python] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: actionlint name: actionlint @@ -93,21 +93,21 @@ repos: language: python pass_filenames: false types_or: [yaml] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: docformatter name: docformatter entry: uv run --extra=dev -m docformatter --in-place language: python types_or: [python] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: shellcheck name: shellcheck entry: uv run --extra=dev shellcheck --shell=bash language: python types_or: [shell] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: shellcheck-docs name: shellcheck-docs @@ -116,14 +116,14 @@ repos: --shell=bash --exclude=SC2215" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: shfmt name: shfmt entry: shfmt --write --space-redirects --indent=4 language: python types_or: [shell] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: shfmt-docs name: shfmt-docs @@ -131,7 +131,7 @@ repos: --no-pad-file --command="shfmt --write --space-redirects --indent=4" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: mypy name: mypy @@ -140,7 +140,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: mypy-docs name: mypy-docs @@ -155,7 +155,7 @@ repos: entry: uv run --extra=dev -m check_manifest language: python pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pyright name: pyright @@ -164,7 +164,7 @@ repos: language: python types_or: [python, toml] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pyright-docs name: pyright-docs @@ -180,7 +180,7 @@ repos: language: python pass_filenames: false types_or: [python] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: vulture name: vulture @@ -188,7 +188,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: vulture-docs name: vulture docs @@ -196,7 +196,7 @@ repos: language: python types_or: [python] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pyroma name: pyroma @@ -204,14 +204,14 @@ repos: language: python pass_filenames: false types_or: [toml] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: deptry name: deptry entry: uv run --extra=dev -m deptry src/ language: python pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pylint name: pylint @@ -219,7 +219,7 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pylint-docs name: pylint-docs @@ -233,21 +233,21 @@ repos: entry: uv run --extra=dev -m ruff check --fix language: python types_or: [python] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: ruff-check-fix-docs name: Ruff check fix docs entry: uv run --extra=dev doccmd --language=python --command="ruff check --fix" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: ruff-format-fix name: Ruff format entry: uv run --extra=dev -m ruff format language: python types_or: [python] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: ruff-format-fix-docs name: Ruff format docs @@ -255,14 +255,14 @@ repos: format" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: doc8 name: doc8 entry: uv run --extra=dev -m doc8 language: python types_or: [rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: interrogate name: interrogate @@ -276,7 +276,7 @@ repos: entry: uv run --extra=dev doccmd --language=python --command="interrogate" language: python types_or: [markdown, rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: pyproject-fmt-fix name: pyproject-fmt @@ -292,7 +292,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: spelling name: spelling @@ -301,7 +301,7 @@ repos: types_or: [rst] stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: docs name: Build Documentation @@ -309,18 +309,18 @@ repos: language: python stages: [manual] pass_filenames: false - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: yamlfix name: pyproject-fmt entry: uv run --extra=dev yamlfix language: python types_or: [yaml] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] - id: sphinx-lint name: sphinx-lint entry: uv run --extra=dev sphinx-lint --enable=all --disable=line-too-long language: python types_or: [rst] - additional_dependencies: [uv==0.5.14] + additional_dependencies: [uv==0.5.20] From fc8e8fb1ce34c6daf698ef830fd4cf2b2142ca5c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 05:27:29 +0000 Subject: [PATCH 306/331] Bump ruff from 0.9.1 to 0.9.2 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.1 to 0.9.2. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.1...0.9.2) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c408adbbf..76d5f64cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.1", + "ruff==0.9.2", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From f6bd726cd9d0769fd7ba9cbac60f43870d25aeb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:36:30 +0000 Subject: [PATCH 307/331] Bump docker/build-push-action from 6.11.0 to 6.12.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.11.0 to 6.12.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.11.0...v6.12.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index a667b6f83..047c3928f 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 349767e76..58e0dbc5d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,7 +110,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -121,7 +121,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -132,7 +132,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.11.0 + uses: docker/build-push-action@v6.12.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From 64051af4e73c738a2de962bb3aa298dbf543830d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 09:36:36 +0000 Subject: [PATCH 308/331] Bump pyright from 1.1.391 to 1.1.392.post0 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.391 to 1.1.392.post0. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.391...v1.1.392.post0) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c408adbbf..27c9c7dd3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.3.3", "pylint-per-file-ignores==1.3.2", "pyproject-fmt==2.5.0", - "pyright==1.1.391", + "pyright==1.1.392.post0", "pyroma==4.2", "pytest==8.3.4", "pytest-cov==6.0.0", From be6f6af67217ba6f9538359226a2a15150465217 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Fri, 17 Jan 2025 21:42:46 +0000 Subject: [PATCH 309/331] Use new format for pylint-per-file-ignores --- pyproject.toml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 963ec8bb8..3a3fd0659 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,7 +70,7 @@ optional-dependencies.dev = [ "pydocstyle==6.3", "pyenchant==3.3.0rc1", "pylint==3.3.3", - "pylint-per-file-ignores==1.3.2", + "pylint-per-file-ignores==1.4.0", "pyproject-fmt==2.5.0", "pyright==1.1.392.post0", "pyroma==4.2", @@ -228,16 +228,13 @@ load-plugins = [ 'pylint.extensions.typing', ] -# This format is described in the following issue: -# https://github.com/christopherpickering/pylint-per-file-ignores/issues/160 -# # We ignore invalid names because: # - We want to use generated module names, which may not be valid, but are never seen. # - We want to use global variables in documentation, which may not be uppercase -per-file-ignores = """ -docs/:invalid-name -doccmd_README_rst.*.py:invalid-name -""" +per-file-ignores = [ + "docs/:invalid-name", + "doccmd_README_rst.*.py:invalid-name", +] [tool.pylint.'MESSAGES CONTROL'] From b2fc09597b4c1ccff149a4609a78092bfb1eadfd Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 18 Jan 2025 17:51:23 +0000 Subject: [PATCH 310/331] Work around orjson breakage --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3a3fd0659..cc3d2b27f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,9 @@ optional-dependencies.dev = [ "interrogate==1.7.0", "mypy[faster-cache]==1.14.1", "mypy-strict-kwargs==2024.12.25", + # Dependency of mypy[faster-cache]. + # Versioned here to work around https://github.com/ijl/orjson/issues/548 + "orjson==3.10.14", "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 67798f0823983396bd8f66bfeb4795cb45bb1be9 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 18 Jan 2025 18:56:14 +0000 Subject: [PATCH 311/331] Remove workaround for orjson issue now fixed --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cc3d2b27f..2771b0e6d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,9 +66,7 @@ optional-dependencies.dev = [ "interrogate==1.7.0", "mypy[faster-cache]==1.14.1", "mypy-strict-kwargs==2024.12.25", - # Dependency of mypy[faster-cache]. - # Versioned here to work around https://github.com/ijl/orjson/issues/548 - "orjson==3.10.14", + "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 01aab61adcea824403c103ccc6acbf07fdf4030e Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 18 Jan 2025 18:57:54 +0000 Subject: [PATCH 312/331] Remove workaround for orjson issue now fixed --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2771b0e6d..3a3fd0659 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,6 @@ optional-dependencies.dev = [ "interrogate==1.7.0", "mypy[faster-cache]==1.14.1", "mypy-strict-kwargs==2024.12.25", - "pre-commit==4.0.1", "pydocstyle==6.3", "pyenchant==3.3.0rc1", From 523a38619cc3c3a0c42000bbe42a9816e1eabd3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 06:04:31 +0000 Subject: [PATCH 313/331] Bump pytest-retry from 1.6.3 to 1.7.0 Bumps [pytest-retry](https://github.com/str0zzapreti/pytest-retry) from 1.6.3 to 1.7.0. - [Release notes](https://github.com/str0zzapreti/pytest-retry/releases) - [Commits](https://github.com/str0zzapreti/pytest-retry/compare/1.6.3...1.7.0) --- updated-dependencies: - dependency-name: pytest-retry dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3a3fd0659..51a358463 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,7 +76,7 @@ optional-dependencies.dev = [ "pyroma==4.2", "pytest==8.3.4", "pytest-cov==6.0.0", - "pytest-retry==1.6.3", + "pytest-retry==1.7.0", "pytest-xdist==3.6.1", "python-dotenv==1.0.1", "pyyaml==6.0.2", From 6dab3cb7f040144c8dd73267147556d084d7ff2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jan 2025 05:52:49 +0000 Subject: [PATCH 314/331] Bump pre-commit from 4.0.1 to 4.1.0 Bumps [pre-commit](https://github.com/pre-commit/pre-commit) from 4.0.1 to 4.1.0. - [Release notes](https://github.com/pre-commit/pre-commit/releases) - [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md) - [Commits](https://github.com/pre-commit/pre-commit/compare/v4.0.1...v4.1.0) --- updated-dependencies: - dependency-name: pre-commit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 51a358463..9179c1661 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,7 +66,7 @@ optional-dependencies.dev = [ "interrogate==1.7.0", "mypy[faster-cache]==1.14.1", "mypy-strict-kwargs==2024.12.25", - "pre-commit==4.0.1", + "pre-commit==4.1.0", "pydocstyle==6.3", "pyenchant==3.3.0rc1", "pylint==3.3.3", From 2f99697ddbac29da0b7cfc4b2bb7b462e49a0b4c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 05:26:35 +0000 Subject: [PATCH 315/331] Bump ruff from 0.9.2 to 0.9.3 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.2 to 0.9.3. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.2...0.9.3) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 51a358463..3ee3dc172 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.2", + "ruff==0.9.3", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 90c53309758f26af94edfe17f6f7237d8823e4fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 08:54:04 +0000 Subject: [PATCH 316/331] Bump actionlint-py from 1.7.6.22 to 1.7.7.23 Bumps [actionlint-py](https://github.com/Mateusz-Grzelinski/actionlint-py) from 1.7.6.22 to 1.7.7.23. - [Commits](https://github.com/Mateusz-Grzelinski/actionlint-py/compare/v1.7.6.22...v1.7.7.23) --- updated-dependencies: - dependency-name: actionlint-py dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3ee3dc172..a2f0101e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "werkzeug>=3.1.2", ] optional-dependencies.dev = [ - "actionlint-py==1.7.6.22", + "actionlint-py==1.7.7.23", "check-manifest==0.50", "check-wheel-contents==0.6.1", "deptry==0.22.0", From 3028a083cf505be42c48b7e538d136ca43da349e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 05:05:31 +0000 Subject: [PATCH 317/331] Bump deptry from 0.22.0 to 0.23.0 Bumps [deptry](https://github.com/fpgmaas/deptry) from 0.22.0 to 0.23.0. - [Release notes](https://github.com/fpgmaas/deptry/releases) - [Changelog](https://github.com/fpgmaas/deptry/blob/main/CHANGELOG.md) - [Commits](https://github.com/fpgmaas/deptry/compare/0.22.0...0.23.0) --- updated-dependencies: - dependency-name: deptry dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ea7f6f1b4..08e515a68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ optional-dependencies.dev = [ "actionlint-py==1.7.7.23", "check-manifest==0.50", "check-wheel-contents==0.6.1", - "deptry==0.22.0", + "deptry==0.23.0", "dirty-equals==0.9.0", "doc8==1.1.1", "doccmd==2025.1.11", From 84a796eff823db01f39ab7f1f04f76fcb375689d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 05:45:48 +0000 Subject: [PATCH 318/331] Bump docker/build-push-action from 6.12.0 to 6.13.0 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 6.12.0 to 6.13.0. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v6.12.0...v6.13.0) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-build.yml | 2 +- .github/workflows/release.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 047c3928f..9a8343f30 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -39,7 +39,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 with: platforms: linux/amd64,linux/arm64 file: src/mock_vws/_flask_server/Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58e0dbc5d..0977bc89a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -110,7 +110,7 @@ jobs: uses: docker/setup-qemu-action@v3 - name: Build and push target manager Docker image - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -121,7 +121,7 @@ jobs: adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }} - name: Build and push VWS Docker image - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 @@ -132,7 +132,7 @@ jobs: adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }} - name: Build and push VWQ Docker image - uses: docker/build-push-action@v6.12.0 + uses: docker/build-push-action@v6.13.0 with: file: src/mock_vws/_flask_server/Dockerfile platforms: linux/amd64,linux/arm64 From 065d0ffa5bbf84828ebfccacf19d9433421ce2f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 05:37:17 +0000 Subject: [PATCH 319/331] Bump pylint from 3.3.3 to 3.3.4 Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.3.3 to 3.3.4. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/v3.3.3...v3.3.4) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 08e515a68..9b60cf8e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -69,7 +69,7 @@ optional-dependencies.dev = [ "pre-commit==4.1.0", "pydocstyle==6.3", "pyenchant==3.3.0rc1", - "pylint==3.3.3", + "pylint==3.3.4", "pylint-per-file-ignores==1.4.0", "pyproject-fmt==2.5.0", "pyright==1.1.392.post0", From b5fd00df7d27c560415e6727cee21615a4ec4fba Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 22:22:39 +0000 Subject: [PATCH 320/331] Bump pyright from 1.1.392.post0 to 1.1.393 Bumps [pyright](https://github.com/RobertCraigie/pyright-python) from 1.1.392.post0 to 1.1.393. - [Release notes](https://github.com/RobertCraigie/pyright-python/releases) - [Commits](https://github.com/RobertCraigie/pyright-python/compare/v1.1.392.post0...v1.1.393) --- updated-dependencies: - dependency-name: pyright dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9b60cf8e9..ec1c535f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ optional-dependencies.dev = [ "pylint==3.3.4", "pylint-per-file-ignores==1.4.0", "pyproject-fmt==2.5.0", - "pyright==1.1.392.post0", + "pyright==1.1.393", "pyroma==4.2", "pytest==8.3.4", "pytest-cov==6.0.0", From 147ac69d2ec910f82a85f1ce2669f9688b1fc306 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 29 Jan 2025 22:26:19 +0000 Subject: [PATCH 321/331] Bump to Python 3.13 minimum version --- .github/workflows/ci.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/skip-tests.yml | 2 +- .github/workflows/windows-ci.yml | 2 +- pyproject.toml | 6 +++--- readthedocs.yaml | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ebe8ccabf..47eb2d547 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.12'] + python-version: ['3.13'] ci_pattern: - tests/mock_vws/test_query.py::TestContentType - tests/mock_vws/test_query.py::TestSuccess diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 116a9c18c..b73a22dbd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - python-version: ['3.12'] + python-version: ['3.13'] platform: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0977bc89a..ebd5fa885 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,7 +22,7 @@ jobs: strategy: matrix: - python-version: ['3.12'] + python-version: ['3.13'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/skip-tests.yml b/.github/workflows/skip-tests.yml index 56cabaff8..db42e823b 100644 --- a/.github/workflows/skip-tests.yml +++ b/.github/workflows/skip-tests.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: - python-version: ['3.12'] + python-version: ['3.13'] platform: [ubuntu-latest] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/windows-ci.yml b/.github/workflows/windows-ci.yml index 6d128f96e..57d86c41a 100644 --- a/.github/workflows/windows-ci.yml +++ b/.github/workflows/windows-ci.yml @@ -18,7 +18,7 @@ jobs: strategy: matrix: - python-version: ['3.12'] + python-version: ['3.13'] platform: [windows-latest] runs-on: ${{ matrix.platform }} diff --git a/pyproject.toml b/pyproject.toml index 9b60cf8e9..1891d2b1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ license = { file = "LICENSE" } authors = [ { name = "Adam Dangoor", email = "adamdangoor@gmail.com" }, ] -requires-python = ">=3.12" +requires-python = ">=3.13" classifiers = [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", @@ -30,7 +30,7 @@ classifiers = [ "Operating System :: Microsoft :: Windows", "Operating System :: POSIX", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", ] dynamic = [ "version", @@ -350,7 +350,7 @@ DEP002 = [ [tool.pyproject-fmt] indent = 4 keep_full_version = true -max_supported_python = "3.12" +max_supported_python = "3.13" [tool.pytest.ini_options] diff --git a/readthedocs.yaml b/readthedocs.yaml index 8f093abcc..6fecd53f0 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -4,7 +4,7 @@ version: 2 build: os: ubuntu-24.04 tools: - python: '3.12' + python: '3.13' python: install: From 5c279133b9068e4fc8fcf46e8adc2d47c85e9b85 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Wed, 29 Jan 2025 23:37:39 +0000 Subject: [PATCH 322/331] Bump README and Dockerfile to Python 3.13 --- README.rst | 2 +- src/mock_vws/_flask_server/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index d97f68f7d..d7be18605 100644 --- a/README.rst +++ b/README.rst @@ -63,4 +63,4 @@ This includes details on how to use the mock, options, and details of the differ .. |Documentation Status| image:: https://readthedocs.org/projects/vws-python-mock/badge/?version=latest :target: https://vws-python-mock.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status -.. |minimum-python-version| replace:: 3.12 +.. |minimum-python-version| replace:: 3.13 diff --git a/src/mock_vws/_flask_server/Dockerfile b/src/mock_vws/_flask_server/Dockerfile index 19d145087..a08e67063 100644 --- a/src/mock_vws/_flask_server/Dockerfile +++ b/src/mock_vws/_flask_server/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.12-slim AS base +FROM python:3.13-slim AS base # We set this pretend version as we do not have Git in our path, and we do # not care enough about having the version correct inside the Docker container # to install it. From f3a7ca4847a4e9d03d09cdbdb7610d0f985a0601 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 30 Jan 2025 01:00:48 +0000 Subject: [PATCH 323/331] No longer skip maximum image file size test The bug which needed us to skip it is now resolved in Python 3.13 --- tests/mock_vws/test_query.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/tests/mock_vws/test_query.py b/tests/mock_vws/test_query.py index 151240777..82bb18c88 100644 --- a/tests/mock_vws/test_query.py +++ b/tests/mock_vws/test_query.py @@ -9,7 +9,6 @@ import datetime import io import json -import sys import textwrap import time import uuid @@ -1395,16 +1394,7 @@ class TestMaximumImageFileSize: """ @staticmethod - @pytest.mark.skipif( - sys.version_info > (3, 9), - reason=( - "There is a bug in urllib3: " - "https://github.com/urllib3/urllib3/issues/2733" - ), - ) - def test_png( - cloud_reco_client: CloudRecoService, - ) -> None: # pragma: no cover + def test_png(cloud_reco_client: CloudRecoService) -> None: """ According to https://developer.vuforia.com/library/web-api/vuforia-query-web-api. @@ -1474,16 +1464,7 @@ def test_png( assert response.text == _NGINX_REQUEST_ENTITY_TOO_LARGE_ERROR @staticmethod - @pytest.mark.skipif( - sys.version_info > (3, 9), - reason=( - "There is a bug in urllib3: " - "https://github.com/urllib3/urllib3/issues/2733" - ), - ) - def test_jpeg( - cloud_reco_client: CloudRecoService, - ) -> None: # pragma: no cover + def test_jpeg(cloud_reco_client: CloudRecoService) -> None: """ According to https://developer.vuforia.com/library/web-api/vuforia-query-web-api. From 9229f33b58e3771684ca1b7dc924f79c5c48062b Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 30 Jan 2025 13:27:25 +0000 Subject: [PATCH 324/331] Use pylint from environment in VSCode --- .vscode/settings.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9ca5c7894..57ee5a50a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ "." ], "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true + "python.testing.pytestEnabled": true, + "pylint.importStrategy": "fromEnvironment" } From 5434ede5f99f81d5d53460152d395f67bf3121a8 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Thu, 30 Jan 2025 13:33:22 +0000 Subject: [PATCH 325/331] Use 'copy.replace' rather than dataclasses.replace - do not expect forever that `target` is a dataclass --- src/mock_vws/_flask_server/target_manager.py | 6 +++--- src/mock_vws/_requests_mock_server/mock_web_services_api.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mock_vws/_flask_server/target_manager.py b/src/mock_vws/_flask_server/target_manager.py index 8c06246f0..3e97b86d4 100644 --- a/src/mock_vws/_flask_server/target_manager.py +++ b/src/mock_vws/_flask_server/target_manager.py @@ -3,7 +3,7 @@ """ import base64 -import dataclasses +import copy import datetime import json from enum import StrEnum, auto @@ -248,7 +248,7 @@ def delete_target(database_name: str, target_id: str) -> Response: ) target = database.get_target(target_id=target_id) now = datetime.datetime.now(tz=target.upload_date.tzinfo) - new_target = dataclasses.replace(target, delete_date=now) + new_target = copy.replace(target, delete_date=now) database.targets.remove(target) database.targets.add(new_target) return Response( @@ -289,7 +289,7 @@ def update_target(database_name: str, target_id: str) -> Response: gmt = ZoneInfo(key="GMT") last_modified_date = datetime.datetime.now(tz=gmt) - new_target = dataclasses.replace( + new_target = copy.replace( target, name=name, width=width, diff --git a/src/mock_vws/_requests_mock_server/mock_web_services_api.py b/src/mock_vws/_requests_mock_server/mock_web_services_api.py index eab879a7a..9a6b30a8d 100644 --- a/src/mock_vws/_requests_mock_server/mock_web_services_api.py +++ b/src/mock_vws/_requests_mock_server/mock_web_services_api.py @@ -5,7 +5,7 @@ """ import base64 -import dataclasses +import copy import datetime import email.utils import json @@ -243,7 +243,7 @@ def delete_target(self, request: PreparedRequest) -> _ResponseType: ) now = datetime.datetime.now(tz=target.upload_date.tzinfo) - new_target = dataclasses.replace(target, delete_date=now) + new_target = copy.replace(target, delete_date=now) database.targets.remove(target) database.targets.add(new_target) date = email.utils.formatdate( @@ -602,7 +602,7 @@ def update_target(self, request: PreparedRequest) -> _ResponseType: gmt = ZoneInfo(key="GMT") last_modified_date = datetime.datetime.now(tz=gmt) - new_target = dataclasses.replace( + new_target = copy.replace( target, name=name, width=width, From 148f490a472cb9042fa75793e965984dc83adef6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 31 Jan 2025 06:02:32 +0000 Subject: [PATCH 326/331] Bump ruff from 0.9.3 to 0.9.4 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.3 to 0.9.4. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.3...0.9.4) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e677dfe56..0930ea754 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.3", + "ruff==0.9.4", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 3518926e1fd537224d3b75285affae7f2ad9745b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 06:02:20 +0000 Subject: [PATCH 327/331] Bump mypy[faster-cache] from 1.14.1 to 1.15.0 Bumps [mypy[faster-cache]](https://github.com/python/mypy) from 1.14.1 to 1.15.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.14.1...v1.15.0) --- updated-dependencies: - dependency-name: mypy[faster-cache] dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 0930ea754..27034f164 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -64,7 +64,7 @@ optional-dependencies.dev = [ "freezegun==1.5.1", "furo==2024.8.6", "interrogate==1.7.0", - "mypy[faster-cache]==1.14.1", + "mypy[faster-cache]==1.15.0", "mypy-strict-kwargs==2024.12.25", "pre-commit==4.1.0", "pydocstyle==6.3", From 9b7078f485f49bfcbffc0dc62b693f5aaf87c59f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Feb 2025 05:10:32 +0000 Subject: [PATCH 328/331] Bump ruff from 0.9.4 to 0.9.5 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.4 to 0.9.5. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.4...0.9.5) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 27034f164..684bb4f27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.4", + "ruff==0.9.5", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From f9880fa4466c3db298596582109700b0d0b8ee0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 05:19:26 +0000 Subject: [PATCH 329/331] Bump sphinx-toolbox from 3.8.1 to 3.8.2 Bumps [sphinx-toolbox](https://github.com/sphinx-toolbox/sphinx-toolbox) from 3.8.1 to 3.8.2. - [Release notes](https://github.com/sphinx-toolbox/sphinx-toolbox/releases) - [Changelog](https://github.com/sphinx-toolbox/sphinx-toolbox/blob/master/doc-source/changelog.rst) - [Commits](https://github.com/sphinx-toolbox/sphinx-toolbox/compare/v3.8.1...v3.8.2) --- updated-dependencies: - dependency-name: sphinx-toolbox dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 684bb4f27..71d0e2c97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -92,7 +92,7 @@ optional-dependencies.dev = [ "sphinx-lint==1.0.0", "sphinx-paramlinks==0.6", "sphinx-substitution-extensions==2025.1.2", - "sphinx-toolbox==3.8.1", + "sphinx-toolbox==3.8.2", "sphinxcontrib-httpdomain==1.8.1", "sphinxcontrib-spelling==8.0.1", "sybil==9.0.0", From ea44a016d2659b3102e7404a48a6851b11c24123 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 05:29:17 +0000 Subject: [PATCH 330/331] Bump ruff from 0.9.5 to 0.9.6 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.9.5 to 0.9.6. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/0.9.5...0.9.6) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 684bb4f27..0c7808262 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ optional-dependencies.dev = [ "python-dotenv==1.0.1", "pyyaml==6.0.2", "requests-mock-flask==2025.1.13", - "ruff==0.9.5", + "ruff==0.9.6", # We add shellcheck-py not only for shell scripts and shell code blocks, # but also because having it installed means that ``actionlint-py`` will # use it to lint shell commands in GitHub workflow files. From 626e327cdfa962e612f416177e8d922d199f7d78 Mon Sep 17 00:00:00 2001 From: adamtheturtle <797801+adamtheturtle@users.noreply.github.com> Date: Tue, 18 Feb 2025 01:03:27 +0000 Subject: [PATCH 331/331] Bump CHANGELOG --- CHANGELOG.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6ce822fb5..10b99fe02 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,9 @@ Changelog Next ---- +2025.02.18 +---------- + 2024.08.30 ------------