Skip to content

Commit

Permalink
Merge pull request #2 from ArcanaFramework/mypy-ci
Browse files Browse the repository at this point in the history
Adds mypy to CI and pre-commit
  • Loading branch information
tclose authored Sep 17, 2024
2 parents 23fc891 + 55b0fe3 commit 93fe038
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 29 deletions.
57 changes: 32 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
10 changes: 6 additions & 4 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import logging
from pathlib import Path
import typing as ty
import tempfile
import pytest

Expand All @@ -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)

0 comments on commit 93fe038

Please sign in to comment.