diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4100a96..35f8d82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ permissions: contents: read jobs: - pre-commit: + lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -34,10 +34,14 @@ jobs: pre-commit run --all-files shell: micromamba-shell {0} + - name: Run mypy + run: mypy . + shell: micromamba-shell {0} + test: runs-on: ubuntu-latest needs: - - pre-commit + - lint strategy: fail-fast: false matrix: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dbec3fb..024ea69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,8 +10,3 @@ repos: # Run the formatter. - id: ruff-format args: [--config, pyproject.toml] - # - repo: https://github.com/pre-commit/mirrors-mypy - # rev: v1.20.0 - # hooks: - # - id: mypy - # args: [--config-file, pyproject.toml] diff --git a/pyproject.toml b/pyproject.toml index 7a37e64..b319dd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ dependencies = [ optional-dependencies.dev = [ "pre-commit", + "mypy", "pytest", "pytest-cov", "pytest-randomly", diff --git a/src/skala/ase/calculator.py b/src/skala/ase/calculator.py index 7095b7d..e2eb06c 100644 --- a/src/skala/ase/calculator.py +++ b/src/skala/ase/calculator.py @@ -75,9 +75,9 @@ def set(self, **kwargs: Any) -> dict[str, Any]: self._ks.verbose = verbose self._ks.base.verbose = verbose - if "ks_config" in changed_parameters and self.parameters.ks_config is not None: + if "ks_config" in changed_parameters and self.parameters.ks_config is not None: # type: ignore if self._ks is not None: - self._ks.base(**self.parameters.ks_config) + self._ks.base(**self.parameters.ks_config) # type: ignore if ( "charge" in changed_parameters @@ -178,7 +178,7 @@ def calculate( else: self._ks.reset(self._mol) - if self.parameters.with_retry: + if self.parameters.with_retry: # type: ignore self._ks.base, _ = retry_scf(self._ks.base) energy = self._ks.base.e_tot else: diff --git a/tests/test_ase.py b/tests/test_ase.py index 09de96f..53a568f 100644 --- a/tests/test_ase.py +++ b/tests/test_ase.py @@ -1,10 +1,7 @@ import numpy as np import pytest -try: - import ase -except ModuleNotFoundError: - ase = None +pytest.importorskip("ase") from ase.build import molecule from ase.calculators import calculator @@ -12,7 +9,6 @@ from skala.ase import Skala -@pytest.mark.skipif(ase is None, reason="ASE is not installed") @pytest.mark.parametrize("xc", ["pbe", "tpss", "skala-1.0", "skala-1.1"]) def test_calc(xc: str) -> None: atoms = molecule("H2O") # type: ignore[no-untyped-call] @@ -49,7 +45,6 @@ def test_calc(xc: str) -> None: ) -@pytest.mark.skipif(ase is None, reason="ASE is not installed") def test_missing_basis() -> None: atoms = molecule("H2O") # type: ignore[no-untyped-call] atoms.calc = Skala(xc="pbe", with_density_fit=True, auxbasis="def2-svp-jkfit") @@ -60,9 +55,8 @@ def test_missing_basis() -> None: atoms.get_potential_energy() -@pytest.mark.skipif(ase is None, reason="ASE is not installed") def test_ks_config() -> None: - atoms = molecule("H2O") + atoms = molecule("H2O") # type: ignore[no-untyped-call] atoms.calc = Skala( xc="pbe", basis="def2-svp",