diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 257501ae..2fe03c24 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -25,29 +25,43 @@ jobs: test: runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} # enables conda/mamba env activation by reading bash profile strategy: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11", "3.12"] split: [1, 2, 3, 4, 5, 6] + steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: Check out repo + uses: actions/checkout@v4 + + - name: Set up micromamba + uses: mamba-org/setup-micromamba@main + + - name: Create mamba environment + run: | + micromamba create -n lobpy python=${{ matrix.python-version }} --yes + + - name: Install uv + run: micromamba run -n lobpy pip install uv + + - name: Install LobsterPy and dependencies run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pytest-mock pytest-split pytest-cov - python -m pip install types-setuptools - pip install .[featurizer] + micromamba activate lobpy + uv pip install --upgrade pip + uv pip install --editable '.[tests,featurizer]' + - name: Test with pytest and coverage # run this locally to update tests durations # pytest --cov=lobsterpy --cov-append --splits 1 --group 1 --durations-path ./tests/test_data/.pytest-split-durations --store-durations run: | + micromamba activate lobpy pytest --cov=lobsterpy --cov-report term-missing --cov-append --splits 6 --group ${{ matrix.split }} -vv --durations-path ./tests/test_data/.pytest-split-durations + - name: Upload coverage uses: actions/upload-artifact@v3 with: @@ -58,22 +72,26 @@ jobs: needs: test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.10 uses: actions/setup-python@v4 with: python-version: '3.10' + - name: Install Coverage run: | python -m pip install coverage[toml] + - name: Download coverage artifacts continue-on-error: true uses: actions/download-artifact@v3 + - name: Run coverage continue-on-error: true run: | coverage combine coverage*/.coverage* coverage report --show-missing + - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v4.0.1 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c3c2333..48eb5dd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ exclude: ^(docs|examples|tests/test_data) ci: autoupdate_schedule: monthly - skip: [mypy] + skip: [mypy,pyright] autofix_commit_msg: pre-commit auto-fixes autoupdate_commit_msg: pre-commit autoupdate @@ -65,3 +65,7 @@ repos: stages: [commit, commit-msg] args: [--ignore-words-list, 'titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo'] types_or: [python, rst, markdown] +- repo: https://github.com/RobertCraigie/pyright-python + rev: v1.1.372 + hooks: + - id: pyright diff --git a/lobsterpy/featurize/utils.py b/lobsterpy/featurize/utils.py index 26bc9044..4b20e82d 100644 --- a/lobsterpy/featurize/utils.py +++ b/lobsterpy/featurize/utils.py @@ -60,7 +60,7 @@ def get_file_paths( if file_path.exists(): file_paths[file] = file_path else: - gz_file_path = Path(zpath(file_path)) + gz_file_path = Path(zpath(str(file_path.as_posix()))) if gz_file_path.exists(): file_paths[file] = gz_file_path else: @@ -86,7 +86,7 @@ def get_structure_path(lobster_path: Path) -> Path: poscar_path = lobster_path / filename if poscar_path.exists(): return poscar_path - gz_file_path = Path(zpath(poscar_path)) + gz_file_path = Path(zpath(str(poscar_path.as_posix()))) if gz_file_path.exists(): return gz_file_path diff --git a/pyproject.toml b/pyproject.toml index 3d1ef676..b62bc95b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,3 +181,12 @@ no_implicit_optional = false [tool.codespell] ignore-words-list = "titel,alls,ans,nd,mater,nwo,te,hart,ontop,ist,ot,fo" check-filenames = true + +[tool.pyright] +typeCheckingMode = "off" +reportPossiblyUnboundVariable = false +reportUnboundVariable = true +reportMissingImports = false +reportMissingModuleSource = false +reportInvalidTypeForm = false +exclude = ["**/tests"] diff --git a/tests/cohp/test_describe.py b/tests/cohp/test_describe.py index cf3b1784..82b208b4 100644 --- a/tests/cohp/test_describe.py +++ b/tests/cohp/test_describe.py @@ -407,7 +407,7 @@ def test_warnings(self): potcar_symbols=["C"], bva_comp=True, ) - assert "Oxidation states from BVA analyzer cannot" in str(w2[0].message) + assert "Oxidation states from BVA analyzer cannot" in str(w2[-1].message) calc_des2 = Description.get_calc_quality_description(calc_quality_warnings2)