Add "doctest" session ...
... to run `xdoctest` against the `velofy` package. Also, install `xdoctest` with only its "colors" extra as the notebooks do not contain doctests.
This commit is contained in:
parent
110c6f755b
commit
32f6540ec3
4 changed files with 68 additions and 61 deletions
26
noxfile.py
26
noxfile.py
|
|
@ -133,6 +133,7 @@ nox.options.sessions = (
|
|||
'format',
|
||||
'lint',
|
||||
'test',
|
||||
'doctest',
|
||||
)
|
||||
|
||||
# Make `uv` use its own Python no matter what
|
||||
|
|
@ -252,6 +253,31 @@ def test_code(session: Session) -> None:
|
|||
session.run('pytest', *(session.posargs or pytest_default_args))
|
||||
|
||||
|
||||
@nox.session(name='doctest', python=MAIN_PYTHON)
|
||||
def test_docstrings(session: Session) -> None:
|
||||
"""Test the code snippets in the docstrings with `xdoctest`.
|
||||
|
||||
By default, all docstrings in the package are checked.
|
||||
|
||||
Extra arguments are forwarded to `xdoctest`.
|
||||
"""
|
||||
start(session)
|
||||
|
||||
install_pinned(session, '.', 'xdoctest[colors]')
|
||||
|
||||
# As `pytest-env` does for `pytest`,
|
||||
# keep `velofy` from connecting to the production database
|
||||
session.env['TESTING'] = 'true'
|
||||
|
||||
session.run(
|
||||
'python',
|
||||
'-m',
|
||||
'xdoctest',
|
||||
PACKAGE_IMPORT_NAME,
|
||||
*(session.posargs or ('all',)),
|
||||
)
|
||||
|
||||
|
||||
@nox.session(name='deps-audit', python=MAIN_PYTHON, reuse_venv=False)
|
||||
def audit_pinned_dependencies(session: Session) -> None:
|
||||
"""Check dependencies for vulnerabilities with `pip-audit`.
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ test = [
|
|||
"pytest-env (>=1.8.8,<2.0.0)",
|
||||
"pytest-mock (>=3.17.0,<4.0.0)",
|
||||
"pytest (>=9.2.0,<10.0.0)",
|
||||
"xdoctest[optional] (>=1.3.2,<2.0.0)",
|
||||
"xdoctest[colors] (>=1.3.2,<2.0.0)",
|
||||
]
|
||||
|
||||
docs = [
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ class Location: # noqa:WPS214
|
|||
Convention is {ZONE} {EASTING} {NORTHING}.
|
||||
|
||||
Example:
|
||||
`<Location: 17T 630084 4833438>'`
|
||||
>>> Location(43.6532, -79.3832)
|
||||
<Location: 17T 630378 4834625>
|
||||
"""
|
||||
return f'<Location: {self.zone} {self.easting} {self.northing}>' # noqa:WPS221
|
||||
|
||||
|
|
|
|||
98
uv.lock
generated
98
uv.lock
generated
|
|
@ -3,10 +3,10 @@ revision = 3
|
|||
requires-python = ">=3.13, <4.0"
|
||||
resolution-markers = [
|
||||
"python_full_version >= '3.15' and sys_platform == 'win32'",
|
||||
"python_full_version == '3.14.*' and sys_platform == 'win32'",
|
||||
"python_full_version >= '3.15' and sys_platform == 'emscripten'",
|
||||
"python_full_version == '3.14.*' and sys_platform == 'emscripten'",
|
||||
"python_full_version >= '3.15' and sys_platform != 'emscripten' and sys_platform != 'win32'",
|
||||
"python_full_version == '3.14.*' and sys_platform == 'win32'",
|
||||
"python_full_version == '3.14.*' and sys_platform == 'emscripten'",
|
||||
"python_full_version == '3.14.*' and sys_platform != 'emscripten' and sys_platform != 'win32'",
|
||||
"python_full_version < '3.14' and sys_platform == 'win32'",
|
||||
"python_full_version < '3.14' and sys_platform == 'emscripten'",
|
||||
|
|
@ -1179,15 +1179,6 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/06/1f/e56e6060d8607af0ef806d026914dd8e9ba77c8abd633eef94ce6d9eb529/ipython-9.19.1-py3-none-any.whl", hash = "sha256:06158707d8bb83f0bb0f03cc358de185dcf2fe99187bbce03e9971c22616a7c5", size = 649865, upload-time = "2026-11-23T09:06:28.274Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipython-genutils"
|
||||
version = "0.2.0"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/e8/69/fbeffffc05236398ebfcfb512b6d2511c622871dca1746361006da310399/ipython_genutils-0.2.0.tar.gz", hash = "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8", size = 22208, upload-time = "2017-03-13T22:12:26.393Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/fa/bc/9bd3b5c2b4774d5f33b2d544f1460be9df7df2fe42f352135381c347c69a/ipython_genutils-0.2.0-py2.py3-none-any.whl", hash = "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", size = 26343, upload-time = "2017-03-13T22:12:25.412Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipython-pygments-lexers"
|
||||
version = "1.1.1"
|
||||
|
|
@ -3520,58 +3511,58 @@ test = [
|
|||
{ name = "pytest-cov" },
|
||||
{ name = "pytest-env" },
|
||||
{ name = "pytest-mock" },
|
||||
{ name = "xdoctest", extra = ["optional"] },
|
||||
{ name = "xdoctest", extra = ["colors"] },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
requires-dist = [
|
||||
{ name = "alembic", specifier = ">=1.20.1,<2" },
|
||||
{ name = "click", specifier = ">=8.5.1,<9" },
|
||||
{ name = "folium", specifier = ">=1.0.0,<2" },
|
||||
{ name = "geopy", specifier = ">=2.5.0,<3" },
|
||||
{ name = "googlemaps", specifier = ">=4.10.0,<5" },
|
||||
{ name = "jupyterlab", marker = "extra == 'research'", specifier = ">=4.6.6,<5" },
|
||||
{ name = "matplotlib", specifier = ">=3.11.2,<4" },
|
||||
{ name = "numpy", marker = "extra == 'research'", specifier = ">=2.5.5,<3" },
|
||||
{ name = "ordered-set", specifier = ">=4.1.0,<5" },
|
||||
{ name = "pandas", specifier = ">=3.1.1,<4" },
|
||||
{ name = "psycopg", extras = ["binary"], specifier = ">=3.3.9,<4" },
|
||||
{ name = "alembic", specifier = ">=1.20.1,<2.0.0" },
|
||||
{ name = "click", specifier = ">=8.5.1,<9.0.0" },
|
||||
{ name = "folium", specifier = ">=1.0.0,<2.0.0" },
|
||||
{ name = "geopy", specifier = ">=2.5.0,<3.0.0" },
|
||||
{ name = "googlemaps", specifier = ">=4.10.0,<5.0.0" },
|
||||
{ name = "jupyterlab", marker = "extra == 'research'", specifier = ">=4.6.6,<5.0.0" },
|
||||
{ name = "matplotlib", specifier = ">=3.11.2,<4.0.0" },
|
||||
{ name = "numpy", marker = "extra == 'research'", specifier = ">=2.5.5,<3.0.0" },
|
||||
{ name = "ordered-set", specifier = ">=4.1.0,<5.0.0" },
|
||||
{ name = "pandas", specifier = ">=3.1.1,<4.0.0" },
|
||||
{ name = "psycopg", extras = ["binary"], specifier = ">=3.3.9,<4.0.0" },
|
||||
{ name = "pytz", marker = "extra == 'research'", specifier = ">=2026.6" },
|
||||
{ name = "rpy2", specifier = ">=3.6.9,<4" },
|
||||
{ name = "shapely", specifier = ">=2.2.0,<3" },
|
||||
{ name = "sqlalchemy", specifier = ">=2.1.9,<3" },
|
||||
{ name = "statsmodels", specifier = ">=0.15.0,<0.16" },
|
||||
{ name = "utm", specifier = ">=0.9.0,<0.10" },
|
||||
{ name = "rpy2", specifier = ">=3.6.9,<4.0.0" },
|
||||
{ name = "shapely", specifier = ">=2.2.0,<3.0.0" },
|
||||
{ name = "sqlalchemy", specifier = ">=2.1.9,<3.0.0" },
|
||||
{ name = "statsmodels", specifier = ">=0.15.0,<0.16.0" },
|
||||
{ name = "utm", specifier = ">=0.9.0,<0.10.0" },
|
||||
]
|
||||
provides-extras = ["research"]
|
||||
|
||||
[package.metadata.requires-dev]
|
||||
dev = [
|
||||
{ name = "autoflake", specifier = ">=2.4.0,<3" },
|
||||
{ name = "black", specifier = ">=25.12.0,<26" },
|
||||
{ name = "flake8", specifier = ">=7.5.0,<8" },
|
||||
{ name = "flake8-annotations", specifier = ">=3.3.1,<4" },
|
||||
{ name = "flake8-black", specifier = ">=0.5.0,<0.6" },
|
||||
{ name = "flake8-pyproject", specifier = ">=1.2.4,<2" },
|
||||
{ name = "flake8-pytest-style", specifier = ">=2.2.0,<3" },
|
||||
{ name = "isort", specifier = ">=9.0.2,<10" },
|
||||
{ name = "mypy", specifier = ">=2.4.1,<3" },
|
||||
{ name = "autoflake", specifier = ">=2.4.0,<3.0.0" },
|
||||
{ name = "black", specifier = ">=25.12.0,<26.0.0" },
|
||||
{ name = "flake8", specifier = ">=7.5.0,<8.0.0" },
|
||||
{ name = "flake8-annotations", specifier = ">=3.3.1,<4.0.0" },
|
||||
{ name = "flake8-black", specifier = ">=0.5.0,<0.6.0" },
|
||||
{ name = "flake8-pyproject", specifier = ">=1.2.4,<2.0.0" },
|
||||
{ name = "flake8-pytest-style", specifier = ">=2.2.0,<3.0.0" },
|
||||
{ name = "isort", specifier = ">=9.0.2,<10.0.0" },
|
||||
{ name = "mypy", specifier = ">=2.4.1,<3.0.0" },
|
||||
{ name = "nox", specifier = ">=2026.10.20" },
|
||||
{ name = "pre-commit", specifier = ">=4.7.0,<5" },
|
||||
{ name = "pre-commit", specifier = ">=4.7.0,<5.0.0" },
|
||||
]
|
||||
docs = [
|
||||
{ name = "sphinx", specifier = ">=9.2.0,<10" },
|
||||
{ name = "sphinx-autodoc-typehints", specifier = ">=3.17.7,<4" },
|
||||
{ name = "sphinx", specifier = ">=9.2.0,<10.0.0" },
|
||||
{ name = "sphinx-autodoc-typehints", specifier = ">=3.17.7,<4.0.0" },
|
||||
]
|
||||
test = [
|
||||
{ name = "factory-boy", specifier = ">=3.3.3,<4" },
|
||||
{ name = "faker", specifier = ">=40.63.0,<41" },
|
||||
{ name = "factory-boy", specifier = ">=3.3.3,<4.0.0" },
|
||||
{ name = "faker", specifier = ">=40.63.0,<41.0.0" },
|
||||
{ name = "packaging", specifier = ">=26.4" },
|
||||
{ name = "pytest", specifier = ">=9.2.0,<10" },
|
||||
{ name = "pytest-cov", specifier = ">=7.1.0,<8" },
|
||||
{ name = "pytest-env", specifier = ">=1.8.8,<2" },
|
||||
{ name = "pytest-mock", specifier = ">=3.17.0,<4" },
|
||||
{ name = "xdoctest", extras = ["optional"], specifier = ">=1.3.2,<2" },
|
||||
{ name = "pytest", specifier = ">=9.2.0,<10.0.0" },
|
||||
{ name = "pytest-cov", specifier = ">=7.1.0,<8.0.0" },
|
||||
{ name = "pytest-env", specifier = ">=1.8.8,<2.0.0" },
|
||||
{ name = "pytest-mock", specifier = ">=3.17.0,<4.0.0" },
|
||||
{ name = "xdoctest", extras = ["colors"], specifier = ">=1.3.2,<2.0.0" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3727,19 +3718,8 @@ wheels = [
|
|||
]
|
||||
|
||||
[package.optional-dependencies]
|
||||
optional = [
|
||||
{ name = "attrs" },
|
||||
colors = [
|
||||
{ name = "colorama", marker = "sys_platform == 'win32'" },
|
||||
{ name = "debugpy" },
|
||||
{ name = "ipykernel", marker = "platform_python_implementation != 'PyPy' or sys_platform != 'win32'" },
|
||||
{ name = "ipython" },
|
||||
{ name = "ipython-genutils", marker = "platform_python_implementation != 'PyPy'" },
|
||||
{ name = "jedi" },
|
||||
{ name = "jinja2", marker = "platform_python_implementation != 'PyPy'" },
|
||||
{ name = "jupyter-client" },
|
||||
{ name = "jupyter-core" },
|
||||
{ name = "nbconvert", marker = "platform_python_implementation != 'PyPy'" },
|
||||
{ name = "pyflakes" },
|
||||
{ name = "pygments" },
|
||||
]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue