diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bea1eee..c46501d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,39 +5,42 @@ on: branches: - main pull_request: + workflow_dispatch: jobs: - test-with-codecov: + linting-and-coverage: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python 3.8 - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.8" - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flit flake8 + pip install ruff - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Check with Ruff + run: ruff check --output-format=github . - - name: Install with Flit - run: flit install --deps all + - name: Install package and its dependencies + run: pip install --editable .[dev] - name: Test with pytest and codecov run: | - pytest --cov=psm_utils tests + pytest --cov=psm_utils --cov-report=xml tests/ - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} + file: ./coverage.xml + flags: unittests + name: codecov-umbrella + fail_ci_if_error: false test-platforms: runs-on: ubuntu-latest @@ -48,24 +51,17 @@ jobs: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install package and its dependencies run: | python -m pip install --upgrade pip - pip install flit flake8 - - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + pip install .[dev] - - name: Install with Flit - run: flit install --deps all + - name: Test imports + run: python -c "import psm_utils" - name: Test with pytest run: | diff --git a/.vscode/settings.json b/.vscode/settings.json index c4e25f4..0164d5c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,9 +2,11 @@ "esbonio.sphinx.confDir": "${workspaceFolder}/docs/source", "[python]": { "editor.formatOnSave": true, + "editor.formatOnType": true, "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, + "editor.defaultFormatter": "charliermarsh.ruff", "editor.rulers": [99] }, "python.testing.pytestArgs": ["tests"], diff --git a/docs/source/conf.py b/docs/source/conf.py index ccaca8b..af3a6c4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -52,7 +52,7 @@ def setup(app): - config = { + config = { # noqa: F841 # "auto_toc_tree_section": "Contents", "enable_eval_rst": True, } diff --git a/online/Home.py b/online/Home.py index 5603ae9..1c1f8fc 100644 --- a/online/Home.py +++ b/online/Home.py @@ -1,6 +1,5 @@ """psm_utils Streamlit-based web server.""" -import streamlit as st from _base import StreamlitPage diff --git a/online/pages/2_PSM_file_conversion.py b/online/pages/2_PSM_file_conversion.py index 2dddcef..37afe4d 100644 --- a/online/pages/2_PSM_file_conversion.py +++ b/online/pages/2_PSM_file_conversion.py @@ -75,7 +75,7 @@ def _convert(self): # Open converted file in memory for download button with open("output_filename", "rb") as file: - is_downloaded = st.download_button( + _ = st.download_button( "Download", data=file, file_name=output_filename, diff --git a/pyproject.toml b/pyproject.toml index b883a60..b6923bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["black", "isort>5", "pytest", "pytest-cov"] +dev = ["ruff", "isort>5", "pytest", "pytest-cov"] docs = [ "sphinx", "numpydoc>=1,<2", @@ -56,11 +56,15 @@ CompOmics = "https://www.compomics.com" psm_utils = "psm_utils.__main__:main" [build-system] -requires = ["flit_core >=3.2,<4"] -build-backend = "flit_core.buildapi" +requires = ["setuptools"] +build-backend = "setuptools.build_meta" -[tool.flit.module] -name = "psm_utils" +[tool.setuptools.packages.find] +include = ["psm_utils*"] + + +[tool.setuptools.dynamic] +version = { attr = "psm_utils.__version__" } [tool.isort] profile = "black" diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_io/test__base_classes.py b/tests/test_io/test__base_classes.py index 43c4be6..af63d26 100644 --- a/tests/test_io/test__base_classes.py +++ b/tests/test_io/test__base_classes.py @@ -1,14 +1,8 @@ """Tests for psm_utils.io._base_classes.""" -import pytest - -from psm_utils.io._base_classes import ReaderBase -from psm_utils.io.exceptions import ( - InvalidModificationDefinitionError, - InvalidModificationError, - UnresolvableModificationError, -) +from psm_utils.io._base_classes import ReaderBase # noqa: F401 class TestBaseReader: + # TODO pass diff --git a/tests/test_io/test_maxquant.py b/tests/test_io/test_maxquant.py index 5384127..fcabc7e 100644 --- a/tests/test_io/test_maxquant.py +++ b/tests/test_io/test_maxquant.py @@ -1,7 +1,6 @@ import pytest import psm_utils.io.maxquant as maxquant -from psm_utils import peptidoform, psm, psm_list TEST_COL = [ "Raw file", diff --git a/tests/test_io/test_mzid.py b/tests/test_io/test_mzid.py index 3c60c99..233dd0d 100644 --- a/tests/test_io/test_mzid.py +++ b/tests/test_io/test_mzid.py @@ -1,7 +1,6 @@ import xml.etree.ElementTree as ET import psm_utils.io.mzid as mzid -from psm_utils import peptidoform, psm, psm_list PEAKS_TEST_FILE = "./tests/test_data/test_peaks.mzid" MSGF_TEST_FILE = "./tests/test_data/test_msgf.mzid" diff --git a/tests/test_io/test_tsv.py b/tests/test_io/test_tsv.py index 22eadd8..e4a4ef6 100644 --- a/tests/test_io/test_tsv.py +++ b/tests/test_io/test_tsv.py @@ -1,6 +1,6 @@ """Tests for psm_utils.io.tsv.""" -from psm_utils.io.tsv import TSVReader, TSVWriter +from psm_utils.io.tsv import TSVReader, TSVWriter # noqa: F401 test_cases = [ ( diff --git a/tests/test_psm_list.py b/tests/test_psm_list.py index 2be2c8f..21fa709 100644 --- a/tests/test_psm_list.py +++ b/tests/test_psm_list.py @@ -12,7 +12,7 @@ class TestPSMList: def test___init__(self): - psm_list = PSMList(psm_list=sample_psm_list) + _ = PSMList(psm_list=sample_psm_list) def test___iter__(self): for psm in PSMList(psm_list=sample_psm_list):