From e94e20f793e9fdf11a6a1036d68d3e08d1148495 Mon Sep 17 00:00:00 2001 From: callumforrester Date: Fri, 9 Aug 2024 14:29:41 +0000 Subject: [PATCH] deploy: DiamondLightSource/python-copier-template@262db8e2c4079fd7b862f540ab21f53cda0c1e87 --- .copier-answers.yml | 2 +- .github/CONTRIBUTING.md | 2 +- src/python_copier_template_example/__main__.py | 12 +++++++++--- tests/conftest.py | 12 +++++++++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 3e893a0..c831d9b 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: 2.1.0-42-gcbc04ca +_commit: 2.2.0-4-g262db8e _src_path: gh:DiamondLightSource/python-copier-template author_email: tom.cobb@diamond.ac.uk author_name: Tom Cobb diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 0ad0fbb..cd8ec61 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -24,4 +24,4 @@ It is recommended that developers use a [vscode devcontainer](https://code.visua This project was created using the [Diamond Light Source Copier Template](https://github.com/DiamondLightSource/python-copier-template) for Python projects. -For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.1.0/how-to.html). +For more information on common tasks like setting up a developer environment, running the tests, and setting a pre-commit hook, see the template's [How-to guides](https://diamondlightsource.github.io/python-copier-template/2.2.0/how-to.html). diff --git a/src/python_copier_template_example/__main__.py b/src/python_copier_template_example/__main__.py index fb2afb0..fb75d83 100644 --- a/src/python_copier_template_example/__main__.py +++ b/src/python_copier_template_example/__main__.py @@ -1,14 +1,20 @@ from argparse import ArgumentParser +from collections.abc import Sequence from . import __version__ __all__ = ["main"] -def main(args=None): +def main(args: Sequence[str] | None = None) -> None: parser = ArgumentParser() - parser.add_argument("-v", "--version", action="version", version=__version__) - args = parser.parse_args(args) + parser.add_argument( + "-v", + "--version", + action="version", + version=__version__, + ) + parser.parse_args(args) # test with: python -m python_copier_template_example diff --git a/tests/conftest.py b/tests/conftest.py index d5cdd5f..ebe9c10 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,5 @@ import os +from typing import Any import pytest @@ -7,9 +8,14 @@ if os.getenv("PYTEST_RAISE", "0") == "1": @pytest.hookimpl(tryfirst=True) - def pytest_exception_interact(call): - raise call.excinfo.value + def pytest_exception_interact(call: pytest.CallInfo[Any]): + if call.excinfo is not None: + raise call.excinfo.value + else: + raise RuntimeError( + f"{call} has no exception data, an unknown error has occurred" + ) @pytest.hookimpl(tryfirst=True) - def pytest_internalerror(excinfo): + def pytest_internalerror(excinfo: pytest.ExceptionInfo[Any]): raise excinfo.value