diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2f910d0..d7688bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,35 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files -- repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - exclude: ^(fileformats/CHANGEME/_version\.py)$ - args: - - -l 88 -- repo: https://github.com/codespell-project/codespell - rev: v2.1.0 - hooks: - - id: codespell - exclude: ^(fileformats/CHANGEME/_version\.py)$ - args: - - --ignore-words=.codespell-ignorewords -- repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 - hooks: - - id: flake8 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - repo: https://github.com/psf/black + rev: 22.3.0 + hooks: + - id: black + exclude: ^(fileformats/CHANGEME/_version\.py)$ + args: + - -l 88 + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + exclude: ^(fileformats/CHANGEME/_version\.py)$ + args: + - --ignore-words=.codespell-ignorewords + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.11.2 + hooks: + - id: mypy + args: [--strict, --install-types, --non-interactive] + exclude: tests + additional_dependencies: [pytest, fileformats] diff --git a/conftest.py b/conftest.py index 2a703c0..83aff9c 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,7 @@ import os import logging from pathlib import Path +import typing as ty import tempfile import pytest @@ -23,15 +24,16 @@ if os.getenv("_PYTEST_RAISE", "0") != "0": @pytest.hookimpl(tryfirst=True) - def pytest_exception_interact(call): - raise call.excinfo.value + def pytest_exception_interact(call: pytest.CallInfo[ty.Any]) -> None: + if call.excinfo is not None: + raise call.excinfo.value @pytest.hookimpl(tryfirst=True) - def pytest_internalerror(excinfo): + def pytest_internalerror(excinfo: pytest.ExceptionInfo[BaseException]) -> None: raise excinfo.value @pytest.fixture -def work_dir(): +def work_dir() -> Path: work_dir = tempfile.mkdtemp() return Path(work_dir)