vws-python 2024.2.19__tar.gz → 2024.9.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {vws-python-2024.2.19 → vws_python-2024.9.2}/.github/workflows/ci.yml +7 -6
  2. vws_python-2024.9.2/.github/workflows/dependabot-merge.yml +24 -0
  3. {vws-python-2024.2.19 → vws_python-2024.9.2}/.github/workflows/release.yml +7 -2
  4. {vws-python-2024.2.19 → vws_python-2024.9.2}/.github/workflows/windows-ci.yml +1 -4
  5. vws_python-2024.9.2/.pre-commit-config.yaml +184 -0
  6. {vws-python-2024.2.19 → vws_python-2024.9.2}/CHANGELOG.rst +9 -0
  7. {vws-python-2024.2.19 → vws_python-2024.9.2}/LICENSE +0 -1
  8. vws_python-2024.9.2/Makefile +12 -0
  9. {vws-python-2024.2.19/src/vws_python.egg-info → vws_python-2024.9.2}/PKG-INFO +25 -57
  10. {vws-python-2024.2.19 → vws_python-2024.9.2}/README.rst +0 -33
  11. vws_python-2024.9.2/conftest.py +71 -0
  12. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/conf.py +11 -1
  13. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/contributing.rst +24 -20
  14. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/index.rst +6 -57
  15. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/release-process.rst +2 -2
  16. vws_python-2024.9.2/pyproject.toml +320 -0
  17. {vws-python-2024.2.19 → vws_python-2024.9.2}/spelling_private_dict.txt +3 -2
  18. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/base_exceptions.py +7 -8
  19. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/cloud_reco_exceptions.py +12 -6
  20. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/custom_exceptions.py +9 -4
  21. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/response.py +3 -0
  22. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/vws_exceptions.py +38 -19
  23. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/include_target_data.py +3 -1
  24. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/query.py +39 -34
  25. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/reports.py +15 -6
  26. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/vws.py +202 -198
  27. {vws-python-2024.2.19 → vws_python-2024.9.2/src/vws_python.egg-info}/PKG-INFO +25 -57
  28. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws_python.egg-info/SOURCES.txt +2 -1
  29. vws_python-2024.9.2/src/vws_python.egg-info/requires.txt +35 -0
  30. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/conftest.py +23 -22
  31. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/test_cloud_reco_exceptions.py +26 -26
  32. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/test_query.py +12 -15
  33. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/test_vws.py +22 -25
  34. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/test_vws_exceptions.py +56 -49
  35. vws-python-2024.2.19/Makefile +0 -37
  36. vws-python-2024.2.19/conftest.py +0 -19
  37. vws-python-2024.2.19/lint.mk +0 -73
  38. vws-python-2024.2.19/pyproject.toml +0 -307
  39. vws-python-2024.2.19/src/vws_python.egg-info/requires.txt +0 -33
  40. {vws-python-2024.2.19 → vws_python-2024.9.2}/.git_archival.txt +0 -0
  41. {vws-python-2024.2.19 → vws_python-2024.9.2}/.gitattributes +0 -0
  42. {vws-python-2024.2.19 → vws_python-2024.9.2}/.github/dependabot.yml +0 -0
  43. {vws-python-2024.2.19 → vws_python-2024.9.2}/.gitignore +0 -0
  44. {vws-python-2024.2.19 → vws_python-2024.9.2}/.vscode/extensions.json +0 -0
  45. {vws-python-2024.2.19 → vws_python-2024.9.2}/.vscode/settings.json +0 -0
  46. {vws-python-2024.2.19 → vws_python-2024.9.2}/CODE_OF_CONDUCT.rst +0 -0
  47. {vws-python-2024.2.19 → vws_python-2024.9.2}/codecov.yaml +0 -0
  48. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/Makefile +0 -0
  49. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/__init__.py +0 -0
  50. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/api-reference.rst +0 -0
  51. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/changelog.rst +0 -0
  52. {vws-python-2024.2.19 → vws_python-2024.9.2}/docs/source/exceptions.rst +0 -0
  53. {vws-python-2024.2.19 → vws_python-2024.9.2}/readthedocs.yaml +0 -0
  54. {vws-python-2024.2.19 → vws_python-2024.9.2}/setup.cfg +0 -0
  55. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/__init__.py +0 -0
  56. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/exceptions/__init__.py +0 -0
  57. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws/py.typed +0 -0
  58. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws_python.egg-info/dependency_links.txt +0 -0
  59. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws_python.egg-info/not-zip-safe +0 -0
  60. {vws-python-2024.2.19 → vws_python-2024.9.2}/src/vws_python.egg-info/top_level.txt +0 -0
  61. {vws-python-2024.2.19 → vws_python-2024.9.2}/tests/__init__.py +0 -0
@@ -33,18 +33,16 @@ jobs:
33
33
  - name: "Install dependencies"
34
34
  run: |
35
35
  curl -LsSf https://astral.sh/uv/install.sh | sh
36
- uv venv /home/runner/.venv
37
- source /home/runner/.venv/bin/activate
38
- uv pip install --upgrade --editable .[dev]
36
+ uv pip install --system --upgrade --editable .[dev]
39
37
 
40
38
  - name: "Lint"
41
39
  run: |
42
- source /home/runner/.venv/bin/activate
43
- make lint
40
+ pre-commit run --all-files --hook-stage commit --verbose
41
+ pre-commit run --all-files --hook-stage push --verbose
42
+ pre-commit run --all-files --hook-stage manual --verbose
44
43
 
45
44
  - name: "Run tests"
46
45
  run: |
47
- source /home/runner/.venv/bin/activate
48
46
  # We run tests against "." and not the tests directory as we test the README
49
47
  # and documentation.
50
48
  pytest -s -vvv --cov-fail-under 100 --cov=src/ --cov=tests . --cov-report=xml
@@ -54,3 +52,6 @@ jobs:
54
52
  with:
55
53
  fail_ci_if_error: true
56
54
  token: ${{ secrets.CODECOV_TOKEN }}
55
+
56
+ - uses: pre-commit-ci/lite-action@v1.0.2
57
+ if: always()
@@ -0,0 +1,24 @@
1
+ ---
2
+
3
+ name: Dependabot auto-merge
4
+ on: pull_request
5
+
6
+ permissions:
7
+ contents: write
8
+ pull-requests: write
9
+
10
+ jobs:
11
+ dependabot:
12
+ runs-on: ubuntu-latest
13
+ if: github.actor == 'dependabot[bot]'
14
+ steps:
15
+ - name: Dependabot metadata
16
+ id: metadata
17
+ uses: dependabot/fetch-metadata@v2
18
+ with:
19
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
20
+ - name: Enable auto-merge for Dependabot PRs
21
+ run: gh pr merge --auto --merge "$PR_URL"
22
+ env:
23
+ PR_URL: ${{github.event.pull_request.html_url}}
24
+ GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -26,6 +26,10 @@ jobs:
26
26
 
27
27
  steps:
28
28
  - uses: actions/checkout@v4
29
+ with:
30
+ # See
31
+ # https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#push-to-protected-branches
32
+ token: ${{ secrets.RELEASE_PAT }}
29
33
 
30
34
  - name: "Set up Python"
31
35
  uses: actions/setup-python@v5
@@ -58,7 +62,7 @@ jobs:
58
62
 
59
63
  - name: Bump version and push tag
60
64
  id: tag_version
61
- uses: mathieudutour/github-tag-action@v6.1
65
+ uses: mathieudutour/github-tag-action@v6.2
62
66
  with:
63
67
  github_token: ${{ secrets.GITHUB_TOKEN }}
64
68
  custom_tag: ${{ steps.calver.outputs.release }}
@@ -77,8 +81,9 @@ jobs:
77
81
  # Checkout the latest tag - the one we just created.
78
82
  git fetch --tags
79
83
  git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")"
80
- python -m pip install build
84
+ python -m pip install build check-wheel-contents
81
85
  python -m build --sdist --wheel --outdir dist/ .
86
+ check-wheel-contents dist/*.whl
82
87
 
83
88
  # We use PyPI trusted publishing rather than a PyPI API token.
84
89
  # See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing.
@@ -33,13 +33,10 @@ jobs:
33
33
  - name: "Install dependencies"
34
34
  run: |
35
35
  irm https://astral.sh/uv/install.ps1 | iex
36
- uv venv C:/Users/runner/.venv
37
- C:/Users/runner/.venv/Scripts/Activate.ps1
38
- uv pip install --upgrade --editable .[dev]
36
+ uv pip install --system --upgrade --editable .[dev]
39
37
 
40
38
  - name: "Run tests"
41
39
  run: |
42
- C:/Users/runner/.venv/Scripts/Activate.ps1
43
40
  # We run tests against "." and not the tests directory as we test the README
44
41
  # and documentation.
45
42
  python -m pytest -s -vvv --cov-fail-under 100 --cov=src/ --cov=tests . --cov-report=xml
@@ -0,0 +1,184 @@
1
+ # See https://pre-commit.com for more information
2
+ # See https://pre-commit.com/hooks.html for more hooks
3
+
4
+ ci:
5
+ # We use system Python, with required dependencies specified in pyproject.toml.
6
+ # We therefore cannot use those dependencies in pre-commit CI.
7
+ skip:
8
+ - actionlint
9
+ - mypy
10
+ - check-manifest
11
+ - pyright
12
+ - vulture
13
+ - pyroma
14
+ - deptry
15
+ - pylint
16
+ - ruff-check
17
+ - ruff-format-check
18
+ - ruff-check-fix
19
+ - ruff-format-fix
20
+ - doc8
21
+ - interrogate
22
+ - pyproject-fmt-check
23
+ - pyproject-fmt-fix
24
+ - linkcheck
25
+ - spelling
26
+ - docs
27
+ - pyright-verifytypes
28
+
29
+ default_install_hook_types: [pre-commit, pre-push, commit-msg]
30
+ repos:
31
+ - repo: https://github.com/pre-commit/pre-commit-hooks
32
+ rev: v4.6.0
33
+ hooks:
34
+ - id: check-added-large-files
35
+ - id: check-case-conflict
36
+ - id: check-executables-have-shebangs
37
+ - id: check-merge-conflict
38
+ - id: check-shebang-scripts-are-executable
39
+ - id: check-symlinks
40
+ - id: check-toml
41
+ - id: check-vcs-permalinks
42
+ - id: check-yaml
43
+ - id: end-of-file-fixer
44
+ - id: file-contents-sorter
45
+ files: spelling_private_dict\.txt$
46
+ - id: trailing-whitespace
47
+ - repo: local
48
+ hooks:
49
+ - id: actionlint
50
+ name: actionlint
51
+ entry: actionlint
52
+ language: system
53
+ pass_filenames: false
54
+ types_or: [yaml]
55
+
56
+ - id: mypy
57
+ name: mypy
58
+ stages: [push]
59
+ entry: mypy .
60
+ language: system
61
+ types_or: [python, toml]
62
+ pass_filenames: false
63
+
64
+ - id: check-manifest
65
+ name: check-manifest
66
+ stages: [push]
67
+ entry: check-manifest .
68
+ language: system
69
+ pass_filenames: false
70
+
71
+ - id: pyright
72
+ name: pyright
73
+ stages: [push]
74
+ entry: pyright .
75
+ language: system
76
+ types_or: [python, toml]
77
+ pass_filenames: false
78
+
79
+ - id: vulture
80
+ name: vulture
81
+ entry: vulture --min-confidence 100 --exclude .eggs
82
+ language: system
83
+ types_or: [python]
84
+
85
+ - id: pyroma
86
+ name: pyroma
87
+ entry: pyroma --min 10 .
88
+ language: system
89
+ pass_filenames: false
90
+ types_or: [toml]
91
+
92
+ - id: deptry
93
+ name: deptry
94
+ entry: deptry src/
95
+ language: system
96
+ pass_filenames: false
97
+
98
+ - id: pylint
99
+ name: pylint
100
+ entry: pylint *.py src/ tests/ docs/
101
+ language: system
102
+ stages: [manual]
103
+ pass_filenames: false
104
+
105
+ - id: ruff-check
106
+ name: Ruff check
107
+ entry: ruff check
108
+ language: system
109
+ types_or: [python]
110
+
111
+ - id: ruff-format-check
112
+ name: Ruff format check
113
+ entry: ruff format --check
114
+ language: system
115
+ types_or: [python]
116
+
117
+ - id: ruff-check-fix
118
+ name: Ruff check fix
119
+ entry: ruff check --fix
120
+ language: system
121
+ types_or: [python]
122
+
123
+ - id: ruff-format-fix
124
+ name: Ruff format
125
+ entry: ruff format
126
+ language: system
127
+ types_or: [python]
128
+
129
+ - id: doc8
130
+ name: doc8
131
+ entry: doc8
132
+ language: system
133
+ types_or: [rst]
134
+
135
+ - id: interrogate
136
+ name: interrogate
137
+ entry: interrogate
138
+ language: system
139
+ types_or: [python]
140
+
141
+ - id: pyproject-fmt-check
142
+ name: pyproject-fmt check
143
+ entry: pyproject-fmt --check
144
+ language: system
145
+ types_or: [toml]
146
+ files: pyproject.toml
147
+
148
+ - id: pyproject-fmt-fix
149
+ name: pyproject-fmt
150
+ entry: pyproject-fmt
151
+ language: system
152
+ types_or: [toml]
153
+ files: pyproject.toml
154
+
155
+ - id: linkcheck
156
+ name: linkcheck
157
+ entry: make -C docs/ linkcheck SPHINXOPTS=-W
158
+ language: system
159
+ types_or: [rst]
160
+ stages: [manual]
161
+ pass_filenames: false
162
+
163
+ - id: spelling
164
+ name: spelling
165
+ entry: make -C docs/ spelling SPHINXOPTS=-W
166
+ language: system
167
+ types_or: [rst]
168
+ stages: [manual]
169
+ pass_filenames: false
170
+
171
+ - id: docs
172
+ name: Build Documentation
173
+ entry: make docs
174
+ language: system
175
+ stages: [manual]
176
+ pass_filenames: false
177
+
178
+ - id: pyright-verifytypes
179
+ name: pyright-verifytypes
180
+ stages: [push]
181
+ entry: pyright --verifytypes vws
182
+ language: system
183
+ pass_filenames: false
184
+ types_or: [python]
@@ -4,9 +4,18 @@ Changelog
4
4
  Next
5
5
  ----
6
6
 
7
+ 2024.09.02
8
+ ------------
9
+
10
+ * Breaking change: Exception names now end with ``Error``.
11
+ * Use a timeout (30 seconds) when making requests to the VWS API.
12
+ * Type hint changes: images are now ``io.BytesIO`` instances or ``io.BufferedRandom``.
13
+
7
14
  2024.02.19
8
15
  ------------
9
16
 
17
+ * Add exception response attribute to ``vws.exceptions.custom_exceptions.RequestEntityTooLarge``.
18
+
10
19
  2024.02.06
11
20
  ------------
12
21
 
@@ -17,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
  THE SOFTWARE.
20
-
@@ -0,0 +1,12 @@
1
+ SHELL := /bin/bash -euxo pipefail
2
+
3
+ # Treat Sphinx warnings as errors
4
+ SPHINXOPTS := -W
5
+
6
+ .PHONY: docs
7
+ docs:
8
+ make -C docs clean html SPHINXOPTS=$(SPHINXOPTS)
9
+
10
+ .PHONY: open-docs
11
+ open-docs:
12
+ python -c 'import os, webbrowser; webbrowser.open("file://" + os.path.abspath("docs/build/html/index.html"))'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vws-python
3
- Version: 2024.2.19
3
+ Version: 2024.9.2
4
4
  Summary: Interact with the Vuforia Web Services (VWS) API.
5
5
  Author-email: Adam Dangoor <adamdangoor@gmail.com>
6
6
  License: The MIT License
@@ -23,7 +23,6 @@ License: The MIT License
23
23
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
24
  THE SOFTWARE.
25
25
 
26
-
27
26
  Project-URL: Documentation, https://vws-python.readthedocs.io/en/latest/
28
27
  Project-URL: Source, https://github.com/VWS-Python/vws-python
29
28
  Keywords: client,vuforia,vws
@@ -36,38 +35,40 @@ Classifier: Programming Language :: Python :: 3.12
36
35
  Requires-Python: >=3.12
37
36
  Description-Content-Type: text/x-rst
38
37
  License-File: LICENSE
38
+ Requires-Dist: beartype>=0.18.5
39
39
  Requires-Dist: requests
40
40
  Requires-Dist: urllib3
41
- Requires-Dist: VWS-Auth-Tools
41
+ Requires-Dist: vws-auth-tools
42
42
  Provides-Extra: dev
43
- Requires-Dist: actionlint-py==1.6.26.11; extra == "dev"
43
+ Requires-Dist: actionlint-py==1.7.1.15; extra == "dev"
44
44
  Requires-Dist: check-manifest==0.49; extra == "dev"
45
+ Requires-Dist: deptry==0.20.0; extra == "dev"
45
46
  Requires-Dist: doc8==1.1.1; extra == "dev"
46
- Requires-Dist: freezegun==1.4.0; extra == "dev"
47
- Requires-Dist: furo==2024.1.29; extra == "dev"
48
- Requires-Dist: mypy==1.8.0; extra == "dev"
49
- Requires-Dist: pip_check_reqs==2.5.3; extra == "dev"
47
+ Requires-Dist: freezegun==1.5.1; extra == "dev"
48
+ Requires-Dist: furo==2024.8.6; extra == "dev"
49
+ Requires-Dist: interrogate==1.7.0; extra == "dev"
50
+ Requires-Dist: mypy==1.11.2; extra == "dev"
51
+ Requires-Dist: pre-commit==3.8.0; extra == "dev"
50
52
  Requires-Dist: pydocstyle==6.3; extra == "dev"
51
53
  Requires-Dist: pyenchant==3.2.2; extra == "dev"
52
- Requires-Dist: Pygments==2.17.2; extra == "dev"
53
- Requires-Dist: pylint==3.0.3; extra == "dev"
54
- Requires-Dist: pyproject-fmt==1.7.0; extra == "dev"
55
- Requires-Dist: pyright==1.1.350; extra == "dev"
54
+ Requires-Dist: pygments==2.18.0; extra == "dev"
55
+ Requires-Dist: pylint==3.2.7; extra == "dev"
56
+ Requires-Dist: pyproject-fmt==2.2.1; extra == "dev"
57
+ Requires-Dist: pyright==1.1.378; extra == "dev"
56
58
  Requires-Dist: pyroma==4.2; extra == "dev"
57
- Requires-Dist: pytest==8.0.1; extra == "dev"
58
- Requires-Dist: pytest-cov==4.1; extra == "dev"
59
- Requires-Dist: PyYAML==6.0.1; extra == "dev"
60
- Requires-Dist: ruff==0.2.2; extra == "dev"
61
- Requires-Dist: Sphinx==7.2.6; extra == "dev"
62
- Requires-Dist: sphinx-prompt==1.8; extra == "dev"
63
- Requires-Dist: Sphinx-Substitution-Extensions==2022.2.16; extra == "dev"
59
+ Requires-Dist: pytest==8.3.2; extra == "dev"
60
+ Requires-Dist: pytest-cov==5.0.0; extra == "dev"
61
+ Requires-Dist: pyyaml==6.0.2; extra == "dev"
62
+ Requires-Dist: ruff==0.6.3; extra == "dev"
63
+ Requires-Dist: sphinx==8.0.2; extra == "dev"
64
+ Requires-Dist: sphinx-copybutton==0.5.2; extra == "dev"
65
+ Requires-Dist: sphinx-substitution-extensions==2024.8.6; extra == "dev"
64
66
  Requires-Dist: sphinxcontrib-spelling==8; extra == "dev"
65
- Requires-Dist: sybil==6.0.3; extra == "dev"
66
- Requires-Dist: types-requests==2.31.0.20240125; extra == "dev"
67
- Requires-Dist: uv==0.1.5; extra == "dev"
67
+ Requires-Dist: sybil==6.1.1; extra == "dev"
68
+ Requires-Dist: types-requests==2.32.0.20240712; extra == "dev"
68
69
  Requires-Dist: vulture==2.11; extra == "dev"
69
- Requires-Dist: VWS-Python-Mock==2024.2.16; extra == "dev"
70
- Requires-Dist: VWS-Test-Fixtures==2023.3.5; extra == "dev"
70
+ Requires-Dist: vws-python-mock==2024.8.30; extra == "dev"
71
+ Requires-Dist: vws-test-fixtures==2023.3.5; extra == "dev"
71
72
 
72
73
  |Build Status| |codecov| |PyPI| |Documentation Status|
73
74
 
@@ -91,34 +92,6 @@ language.
91
92
  Getting Started
92
93
  ---------------
93
94
 
94
- .. invisible-code-block: python
95
-
96
- import contextlib
97
- import pathlib
98
- import shutil
99
-
100
- import vws_test_fixtures
101
- from mock_vws import MockVWS
102
- from mock_vws.database import VuforiaDatabase
103
-
104
- mock = MockVWS(real_http=False)
105
- database = VuforiaDatabase(
106
- server_access_key='[server-access-key]',
107
- server_secret_key='[server-secret-key]',
108
- client_access_key='[client-access-key]',
109
- client_secret_key='[client-secret-key]',
110
- )
111
- mock.add_database(database=database)
112
- stack = contextlib.ExitStack()
113
- stack.enter_context(mock)
114
-
115
- # We rely on implementation details of the fixtures package.
116
- image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg'
117
- assert image.exists(), image.resolve()
118
- new_image = pathlib.Path('high_quality_image.jpg')
119
- shutil.copy(image, new_image)
120
-
121
-
122
95
  .. code-block:: python
123
96
 
124
97
  import pathlib
@@ -154,11 +127,6 @@ Getting Started
154
127
 
155
128
  assert matching_targets[0].target_id == target_id
156
129
 
157
- .. invisible-code-block: python
158
- new_image = pathlib.Path('high_quality_image.jpg')
159
- new_image.unlink()
160
- stack.close()
161
-
162
130
  Full Documentation
163
131
  ------------------
164
132
 
@@ -20,34 +20,6 @@ language.
20
20
  Getting Started
21
21
  ---------------
22
22
 
23
- .. invisible-code-block: python
24
-
25
- import contextlib
26
- import pathlib
27
- import shutil
28
-
29
- import vws_test_fixtures
30
- from mock_vws import MockVWS
31
- from mock_vws.database import VuforiaDatabase
32
-
33
- mock = MockVWS(real_http=False)
34
- database = VuforiaDatabase(
35
- server_access_key='[server-access-key]',
36
- server_secret_key='[server-secret-key]',
37
- client_access_key='[client-access-key]',
38
- client_secret_key='[client-secret-key]',
39
- )
40
- mock.add_database(database=database)
41
- stack = contextlib.ExitStack()
42
- stack.enter_context(mock)
43
-
44
- # We rely on implementation details of the fixtures package.
45
- image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg'
46
- assert image.exists(), image.resolve()
47
- new_image = pathlib.Path('high_quality_image.jpg')
48
- shutil.copy(image, new_image)
49
-
50
-
51
23
  .. code-block:: python
52
24
 
53
25
  import pathlib
@@ -83,11 +55,6 @@ Getting Started
83
55
 
84
56
  assert matching_targets[0].target_id == target_id
85
57
 
86
- .. invisible-code-block: python
87
- new_image = pathlib.Path('high_quality_image.jpg')
88
- new_image.unlink()
89
- stack.close()
90
-
91
58
  Full Documentation
92
59
  ------------------
93
60
 
@@ -0,0 +1,71 @@
1
+ """Setup for Sybil."""
2
+
3
+ import io
4
+ from collections.abc import Generator
5
+ from doctest import ELLIPSIS
6
+ from pathlib import Path
7
+
8
+ import pytest
9
+ from beartype import beartype
10
+ from mock_vws import MockVWS
11
+ from mock_vws.database import VuforiaDatabase
12
+ from sybil import Sybil
13
+ from sybil.parsers.rest import (
14
+ ClearNamespaceParser,
15
+ DocTestParser,
16
+ PythonCodeBlockParser,
17
+ )
18
+
19
+
20
+ def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
21
+ """
22
+ Apply the beartype decorator to all collected test functions.
23
+ """
24
+ for item in items:
25
+ if isinstance(item, pytest.Function):
26
+ item.obj = beartype(obj=item.obj)
27
+
28
+
29
+ @pytest.fixture
30
+ def make_image_file(
31
+ high_quality_image: io.BytesIO,
32
+ ) -> Generator[None, None, None]:
33
+ """
34
+ Make an image file available in the test directory.
35
+ The path of this file matches the path in the documentation.
36
+ """
37
+ new_image = Path("high_quality_image.jpg")
38
+ buffer = high_quality_image.getvalue()
39
+ new_image.write_bytes(data=buffer)
40
+ yield
41
+ new_image.unlink()
42
+
43
+
44
+ @pytest.fixture
45
+ def mock_vws() -> Generator[None, None, None]:
46
+ """
47
+ Yield a mock VWS.
48
+
49
+ The keys used here match the keys in the documentation.
50
+ """
51
+ database = VuforiaDatabase(
52
+ server_access_key="[server-access-key]",
53
+ server_secret_key="[server-secret-key]",
54
+ client_access_key="[client-access-key]",
55
+ client_secret_key="[client-secret-key]",
56
+ )
57
+ # We use a low processing time so that tests run quickly.
58
+ with MockVWS(processing_time_seconds=0.2) as mock:
59
+ mock.add_database(database=database)
60
+ yield
61
+
62
+
63
+ pytest_collect_file = Sybil(
64
+ parsers=[
65
+ ClearNamespaceParser(),
66
+ DocTestParser(optionflags=ELLIPSIS),
67
+ PythonCodeBlockParser(),
68
+ ],
69
+ patterns=["*.rst", "*.py"],
70
+ fixtures=["make_image_file", "mock_vws"],
71
+ ).pytest()
@@ -12,10 +12,10 @@ project = "VWS-Python"
12
12
  author = "Adam Dangoor"
13
13
 
14
14
  extensions = [
15
+ "sphinx_copybutton",
15
16
  "sphinx.ext.autodoc",
16
17
  "sphinx.ext.intersphinx",
17
18
  "sphinx.ext.napoleon",
18
- "sphinx-prompt",
19
19
  "sphinx_substitution_extensions",
20
20
  "sphinxcontrib.spelling",
21
21
  ]
@@ -27,6 +27,10 @@ master_doc = "index"
27
27
  year = datetime.datetime.now(tz=datetime.UTC).year
28
28
  project_copyright = f"{year}, {author}"
29
29
 
30
+ # Exclude the prompt from copied code with sphinx_copybutton.
31
+ # https://sphinx-copybutton.readthedocs.io/en/latest/use.html#automatic-exclusion-of-prompts-from-the-copies.
32
+ copybutton_exclude = ".linenos, .gp"
33
+
30
34
  # The version info for the project you're documenting, acts as replacement for
31
35
  # |version| and |release|, also used in various other places throughout the
32
36
  # built documents.
@@ -58,6 +62,12 @@ intersphinx_mapping = {
58
62
  "python": ("https://docs.python.org/3.12", None),
59
63
  }
60
64
  nitpicky = True
65
+ nitpick_ignore = (
66
+ ("py:class", "BytesIO"),
67
+ ("py:class", "BufferedRandom"),
68
+ ("py:class", "_io.BytesIO"),
69
+ ("py:class", "_io.BufferedRandom"),
70
+ )
61
71
  warning_is_error = True
62
72
 
63
73
  autoclass_content = "both"
@@ -10,46 +10,50 @@ Install contribution dependencies
10
10
 
11
11
  Install Python dependencies in a virtual environment.
12
12
 
13
- .. prompt:: bash
13
+ .. code-block:: console
14
14
 
15
- pip install --editable '.[dev]'
15
+ $ pip install --editable '.[dev]'
16
16
 
17
17
  Spell checking requires ``enchant``.
18
- This can be installed on macOS, for example, with `Homebrew <https://brew.sh>`__:
18
+ This can be installed on macOS, for example, with `Homebrew`_:
19
19
 
20
- .. prompt:: bash
20
+ .. code-block:: console
21
21
 
22
- brew install enchant
22
+ $ brew install enchant
23
23
 
24
24
  and on Ubuntu with ``apt``:
25
25
 
26
- .. prompt:: bash
26
+ .. code-block:: console
27
27
 
28
- apt-get install -y enchant
28
+ $ apt-get install -y enchant
29
29
 
30
- Linting
31
- -------
30
+ Install ``pre-commit`` hooks:
31
+
32
+ .. code-block:: console
32
33
 
33
- Run lint tools:
34
+ $ pre-commit install
34
35
 
35
- .. prompt:: bash
36
+ Linting
37
+ -------
36
38
 
37
- make lint
39
+ Run lint tools either by committing, or with:
38
40
 
39
- To fix some lint errors, run the following:
41
+ .. code-block:: console
40
42
 
41
- .. prompt:: bash
43
+ $ pre-commit run --all-files --hook-stage commit --verbose
44
+ $ pre-commit run --all-files --hook-stage push --verbose
45
+ $ pre-commit run --all-files --hook-stage manual --verbose
42
46
 
43
- make fix-lint
47
+ .. _Homebrew: https://brew.sh
44
48
 
45
49
  Running tests
46
50
  -------------
47
51
 
48
52
  Run ``pytest``:
49
53
 
50
- .. prompt:: bash
54
+ .. code-block:: console
51
55
 
52
- pytest
56
+ $ pytest
53
57
 
54
58
  Documentation
55
59
  -------------
@@ -58,10 +62,10 @@ Documentation is built on Read the Docs.
58
62
 
59
63
  Run the following commands to build and view documentation locally:
60
64
 
61
- .. prompt:: bash
65
+ .. code-block:: console
62
66
 
63
- make docs
64
- make open-docs
67
+ $ make docs
68
+ $ make open-docs
65
69
 
66
70
  Continuous integration
67
71
  ----------------------