vws-python 2024.2.6__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.6 → vws_python-2024.9.2}/.github/workflows/ci.yml +12 -13
  2. vws_python-2024.9.2/.github/workflows/dependabot-merge.yml +24 -0
  3. {vws-python-2024.2.6 → vws_python-2024.9.2}/.github/workflows/release.yml +7 -2
  4. {vws-python-2024.2.6 → vws_python-2024.9.2}/.github/workflows/windows-ci.yml +4 -13
  5. vws_python-2024.9.2/.pre-commit-config.yaml +184 -0
  6. {vws-python-2024.2.6 → vws_python-2024.9.2}/CHANGELOG.rst +12 -0
  7. {vws-python-2024.2.6 → vws_python-2024.9.2}/LICENSE +0 -1
  8. vws_python-2024.9.2/Makefile +12 -0
  9. {vws-python-2024.2.6/src/vws_python.egg-info → vws_python-2024.9.2}/PKG-INFO +25 -58
  10. {vws-python-2024.2.6 → vws_python-2024.9.2}/README.rst +0 -33
  11. vws_python-2024.9.2/conftest.py +71 -0
  12. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/conf.py +11 -1
  13. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/contributing.rst +24 -20
  14. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/index.rst +6 -57
  15. {vws-python-2024.2.6 → 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.6 → vws_python-2024.9.2}/spelling_private_dict.txt +3 -2
  18. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/base_exceptions.py +7 -8
  19. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/cloud_reco_exceptions.py +12 -6
  20. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/custom_exceptions.py +24 -4
  21. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/response.py +3 -0
  22. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/vws_exceptions.py +38 -19
  23. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/include_target_data.py +3 -1
  24. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/query.py +39 -34
  25. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/reports.py +15 -6
  26. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/vws.py +202 -198
  27. {vws-python-2024.2.6 → vws_python-2024.9.2/src/vws_python.egg-info}/PKG-INFO +25 -58
  28. {vws-python-2024.2.6 → 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.6 → vws_python-2024.9.2}/tests/conftest.py +23 -22
  31. {vws-python-2024.2.6 → vws_python-2024.9.2}/tests/test_cloud_reco_exceptions.py +30 -26
  32. {vws-python-2024.2.6 → vws_python-2024.9.2}/tests/test_query.py +12 -15
  33. {vws-python-2024.2.6 → vws_python-2024.9.2}/tests/test_vws.py +22 -25
  34. {vws-python-2024.2.6 → vws_python-2024.9.2}/tests/test_vws_exceptions.py +56 -49
  35. vws-python-2024.2.6/Makefile +0 -37
  36. vws-python-2024.2.6/conftest.py +0 -19
  37. vws-python-2024.2.6/lint.mk +0 -73
  38. vws-python-2024.2.6/pyproject.toml +0 -308
  39. vws-python-2024.2.6/src/vws_python.egg-info/requires.txt +0 -34
  40. {vws-python-2024.2.6 → vws_python-2024.9.2}/.git_archival.txt +0 -0
  41. {vws-python-2024.2.6 → vws_python-2024.9.2}/.gitattributes +0 -0
  42. {vws-python-2024.2.6 → vws_python-2024.9.2}/.github/dependabot.yml +0 -0
  43. {vws-python-2024.2.6 → vws_python-2024.9.2}/.gitignore +0 -0
  44. {vws-python-2024.2.6 → vws_python-2024.9.2}/.vscode/extensions.json +0 -0
  45. {vws-python-2024.2.6 → vws_python-2024.9.2}/.vscode/settings.json +0 -0
  46. {vws-python-2024.2.6 → vws_python-2024.9.2}/CODE_OF_CONDUCT.rst +0 -0
  47. {vws-python-2024.2.6 → vws_python-2024.9.2}/codecov.yaml +0 -0
  48. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/Makefile +0 -0
  49. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/__init__.py +0 -0
  50. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/api-reference.rst +0 -0
  51. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/changelog.rst +0 -0
  52. {vws-python-2024.2.6 → vws_python-2024.9.2}/docs/source/exceptions.rst +0 -0
  53. {vws-python-2024.2.6 → vws_python-2024.9.2}/readthedocs.yaml +0 -0
  54. {vws-python-2024.2.6 → vws_python-2024.9.2}/setup.cfg +0 -0
  55. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/__init__.py +0 -0
  56. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/exceptions/__init__.py +0 -0
  57. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws/py.typed +0 -0
  58. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws_python.egg-info/dependency_links.txt +0 -0
  59. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws_python.egg-info/not-zip-safe +0 -0
  60. {vws-python-2024.2.6 → vws_python-2024.9.2}/src/vws_python.egg-info/top_level.txt +0 -0
  61. {vws-python-2024.2.6 → vws_python-2024.9.2}/tests/__init__.py +0 -0
@@ -29,24 +29,17 @@ jobs:
29
29
  with:
30
30
  python-version: ${{ matrix.python-version }}
31
31
 
32
- - uses: actions/cache@v4
33
- with:
34
- path: ~/.cache/pip
35
- key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
36
- restore-keys: |
37
- ${{ runner.os }}-pip-
38
-
32
+ # We do not use the cache action as uv is faster than the cache action.
39
33
  - name: "Install dependencies"
40
34
  run: |
41
- python -m pip install --upgrade pip setuptools wheel
42
- # We use '--ignore-installed' to avoid GitHub's cache which can cause
43
- # issues - we have seen packages from this cache be cause trouble with
44
- # pip-extra-reqs.
45
- python -m pip install --ignore-installed --upgrade --editable .[dev]
35
+ curl -LsSf https://astral.sh/uv/install.sh | sh
36
+ uv pip install --system --upgrade --editable .[dev]
46
37
 
47
38
  - name: "Lint"
48
39
  run: |
49
- 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
50
43
 
51
44
  - name: "Run tests"
52
45
  run: |
@@ -56,3 +49,9 @@ jobs:
56
49
 
57
50
  - name: "Upload coverage to Codecov"
58
51
  uses: "codecov/codecov-action@v4"
52
+ with:
53
+ fail_ci_if_error: true
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.
@@ -29,23 +29,14 @@ jobs:
29
29
  with:
30
30
  python-version: ${{ matrix.python-version }}
31
31
 
32
- - uses: actions/cache@v4
33
- with:
34
- path: ~\AppData\Local\pip\Cache
35
- key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
36
- restore-keys: |
37
- ${{ runner.os }}-pip-
38
-
32
+ # We do not use the cache action as uv is faster than the cache action.
39
33
  - name: "Install dependencies"
40
34
  run: |
41
- python -m pip install --upgrade pip setuptools wheel
42
- # We use '--ignore-installed' to avoid GitHub's cache which can cause
43
- # issues - we have seen packages from this cache be cause trouble with
44
- # pip-extra-reqs.
45
- python -m pip install --ignore-installed --upgrade --editable .[dev]
35
+ irm https://astral.sh/uv/install.ps1 | iex
36
+ uv pip install --system --upgrade --editable .[dev]
46
37
 
47
38
  - name: "Run tests"
48
39
  run: |
49
40
  # We run tests against "." and not the tests directory as we test the README
50
41
  # and documentation.
51
- pytest -s -vvv --cov-fail-under 100 --cov=src/ --cov=tests . --cov-report=xml
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,6 +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
+
14
+ 2024.02.19
15
+ ------------
16
+
17
+ * Add exception response attribute to ``vws.exceptions.custom_exceptions.RequestEntityTooLarge``.
18
+
7
19
  2024.02.06
8
20
  ------------
9
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.6
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,39 +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: dodgy==0.2.1; extra == "dev"
47
- Requires-Dist: freezegun==1.4.0; extra == "dev"
48
- Requires-Dist: furo==2024.1.29; extra == "dev"
49
- Requires-Dist: mypy==1.8.0; extra == "dev"
50
- Requires-Dist: pdm==2.12.3; extra == "dev"
51
- 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"
52
52
  Requires-Dist: pydocstyle==6.3; extra == "dev"
53
53
  Requires-Dist: pyenchant==3.2.2; extra == "dev"
54
- Requires-Dist: Pygments==2.17.2; extra == "dev"
55
- Requires-Dist: pylint==3.0.3; extra == "dev"
56
- Requires-Dist: pyproject-fmt==1.7.0; extra == "dev"
57
- 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"
58
58
  Requires-Dist: pyroma==4.2; extra == "dev"
59
- Requires-Dist: pytest==8.0.0; extra == "dev"
60
- Requires-Dist: pytest-cov==4.1; extra == "dev"
61
- Requires-Dist: PyYAML==6.0.1; extra == "dev"
62
- Requires-Dist: ruff==0.2.1; extra == "dev"
63
- Requires-Dist: Sphinx==7.2.6; extra == "dev"
64
- Requires-Dist: sphinx-prompt==1.8; extra == "dev"
65
- 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"
66
66
  Requires-Dist: sphinxcontrib-spelling==8; extra == "dev"
67
- Requires-Dist: sybil==6.0.3; extra == "dev"
68
- Requires-Dist: types-requests==2.31.0.20240125; extra == "dev"
67
+ Requires-Dist: sybil==6.1.1; extra == "dev"
68
+ Requires-Dist: types-requests==2.32.0.20240712; extra == "dev"
69
69
  Requires-Dist: vulture==2.11; extra == "dev"
70
- Requires-Dist: VWS-Python-Mock==2024.1.21; extra == "dev"
71
- 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"
72
72
 
73
73
  |Build Status| |codecov| |PyPI| |Documentation Status|
74
74
 
@@ -92,34 +92,6 @@ language.
92
92
  Getting Started
93
93
  ---------------
94
94
 
95
- .. invisible-code-block: python
96
-
97
- import contextlib
98
- import pathlib
99
- import shutil
100
-
101
- import vws_test_fixtures
102
- from mock_vws import MockVWS
103
- from mock_vws.database import VuforiaDatabase
104
-
105
- mock = MockVWS(real_http=False)
106
- database = VuforiaDatabase(
107
- server_access_key='[server-access-key]',
108
- server_secret_key='[server-secret-key]',
109
- client_access_key='[client-access-key]',
110
- client_secret_key='[client-secret-key]',
111
- )
112
- mock.add_database(database=database)
113
- stack = contextlib.ExitStack()
114
- stack.enter_context(mock)
115
-
116
- # We rely on implementation details of the fixtures package.
117
- image = pathlib.Path(vws_test_fixtures.__path__[0]) / 'high_quality_image.jpg'
118
- assert image.exists(), image.resolve()
119
- new_image = pathlib.Path('high_quality_image.jpg')
120
- shutil.copy(image, new_image)
121
-
122
-
123
95
  .. code-block:: python
124
96
 
125
97
  import pathlib
@@ -155,11 +127,6 @@ Getting Started
155
127
 
156
128
  assert matching_targets[0].target_id == target_id
157
129
 
158
- .. invisible-code-block: python
159
- new_image = pathlib.Path('high_quality_image.jpg')
160
- new_image.unlink()
161
- stack.close()
162
-
163
130
  Full Documentation
164
131
  ------------------
165
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"