Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 28 additions & 42 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,34 @@
max-line-length = 79
# extend-ignore (not ignore) so pycodestyle's default-ignored,
# Black-compatible codes (E121, E123, E126, E226, E704, W503, W504, E24)
# remain ignored — they flag layout Black itself produces.
extend-ignore = D200, D100, E203, W503
# remain ignored. E501 is delegated to Black's 79-character formatter.
extend-ignore = D200, D100, E203, E501, W503
max-complexity = 10
show-source = True
# TODO (legacy lint debt): the files below predate the Black/flake8
# standards in CLAUDE.md and were never reformatted. Each is excluded so
# that edits to it don't fail CI on pre-existing violations unrelated to
# the change. Reformat each file (Black + manual fixes for the residual
# E501/F401/C901) and DELETE its entry, retroactively, until this list is
# empty. pylint is already clean across the codebase (no pylint debt).
exclude =
docs/*,
proteopy/__init__.py,
proteopy/ann/__init__.py,
proteopy/ann/base_anndata.py,
proteopy/datasets/__init__.py,
proteopy/download/__init__.py,
proteopy/get/__init__.py,
proteopy/get/stat_tests.py,
proteopy/pl/__init__.py,
proteopy/pl/clustering.py,
proteopy/pl/copf.py,
proteopy/pl/intensities.py,
proteopy/pl/stats.py,
proteopy/pp/__init__.py,
proteopy/pp/filtering.py,
proteopy/pp/normalization.py,
proteopy/pp/stats.py,
proteopy/read/__init__.py,
proteopy/read/diann.py,
proteopy/tl/__init__.py,
proteopy/tl/clustering.py,
proteopy/tl/copf.py,
proteopy/tl/stat_tests.py,
proteopy/utils/__init__.py,
proteopy/utils/copf.py,
proteopy/utils/data_structures.py,
proteopy/utils/functools.py,
proteopy/utils/matplotlib.py,
proteopy/utils/pandas.py,
proteopy/utils/parsers.py,
tests/pp/test_filtering.py,
tests/tl/test_copro.py,
tests/utils/helpers.py,
tests/utils/test_data_structures.py
.git,
.venv,
__pycache__,
build,
dist
per-file-ignores =
proteopy/__init__.py:F401
proteopy/**/__init__.py:F401
docs/sphinx/source/conf.py:E402
proteopy/ann/base_anndata.py:C901
proteopy/get/stat_tests.py:C901
proteopy/pl/clustering.py:C901
proteopy/pl/copf.py:C901
proteopy/pl/intensities.py:C901
proteopy/pl/stats.py:C901
proteopy/pp/filtering.py:C901
proteopy/pp/normalization.py:C901
proteopy/pp/stats.py:C901
proteopy/read/diann.py:C901
proteopy/tl/clustering.py:C901
proteopy/tl/copf.py:C901
proteopy/tl/stat_tests.py:C901
proteopy/utils/copf.py:C901
proteopy/utils/functools.py:C901
proteopy/utils/matplotlib.py:C901
proteopy/utils/parsers.py:C901
94 changes: 22 additions & 72 deletions .github/workflows/format-code_perform-tests_on_push-pr.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
# python linting - pylint and flake8
# pytest

name: Python application using pip
name: Python quality

on:

push:
branches: [ "main", "dev*", "dev/**" ]

pull_request:
branches: [ "main", "dev*", "dev/**" ]

branches: ["main", "dev*", "dev/**"]
workflow_dispatch:

permissions:
contents: read

jobs:

build:

quality:
runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -28,7 +19,6 @@ jobs:
python-version: ["3.10", "3.11"]

steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0
Expand All @@ -38,72 +28,30 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
- name: Install package and quality tools
shell: bash
run: |
python -m pip install --upgrade pip
pip install pre-commit pytest
if [ -f "requirements/requirements_ci-cd.txt" ]; then
pip install -r requirements/requirements_ci-cd.txt
fi
python -m pip install -r requirements/requirements_ci-cd.txt
python -m pip install -e .

- name: Install package
- name: Check formatting with Black
shell: bash
run: |
pip install -e .
run: black --check --diff .

- name: Compute diff range
id: range
- name: Lint with flake8
shell: bash
run: |
# Pick initial from/to refs per event type.
if [ -n "${{ github.event.pull_request.base.sha }}" ]; then
FROM="${{ github.event.pull_request.base.sha }}"
TO="${{ github.event.pull_request.head.sha }}"
elif [ -n "${{ github.event.before }}" ] \
&& [ "${{ github.event.before }}" != "0000000000000000000000000000000000000000" ]; then
FROM="${{ github.event.before }}"
TO="${{ github.sha }}"
else
FROM="HEAD~1"
TO="HEAD"
fi

# Guard: after a force-push, `event.before` may point at an
# orphaned commit no longer reachable in CI's fetched history.
# Fall back to the merge-base with origin/main so lint covers
# the branch's divergence (mirrors what a PR would lint).
# For pushes to main itself, no divergence exists; use HEAD~1.
if ! git cat-file -e "${FROM}^{commit}" 2>/dev/null; then
if [ "${{ github.ref_name }}" = "main" ]; then
echo "::warning::from-ref ${FROM} unreachable on main; falling back to HEAD~1..HEAD"
FROM="HEAD~1"
elif MB=$(git merge-base origin/main HEAD 2>/dev/null); then
echo "::warning::from-ref ${FROM} unreachable (likely force-push); falling back to merge-base with origin/main ($MB)"
FROM="$MB"
else
echo "::warning::from-ref ${FROM} unreachable and no merge-base with origin/main; falling back to HEAD~1..HEAD"
FROM="HEAD~1"
fi
TO="HEAD"
fi

echo "from=$FROM" >> "$GITHUB_OUTPUT"
echo "to=$TO" >> "$GITHUB_OUTPUT"

- name: Cache pre-commit envs
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
run: flake8 .

- name: Lint via pre-commit (changed files only)
- name: Lint with pylint
shell: bash
run: |
pre-commit run \
--from-ref "${{ steps.range.outputs.from }}" \
--to-ref "${{ steps.range.outputs.to }}" \
--show-diff-on-failure
pylint \
$(git ls-files \
"proteopy/*.py" "proteopy/**/*.py" \
"tests/*.py" "tests/**/*.py") \
--disable=all \
--enable=E,F

- name: Get month
id: date
Expand All @@ -114,7 +62,10 @@ jobs:
id: cache-dir
shell: python
run: |
import pooch, os
import os

import pooch

cache = str(pooch.os_cache("proteopy"))
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"path={cache}\n")
Expand All @@ -126,5 +77,4 @@ jobs:
key: proteopy-datasets-${{ runner.os }}-${{ steps.date.outputs.month }}

- name: Test with pytest
run: |
pytest -v -s tests/
run: pytest -v -s tests/
18 changes: 7 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
# - pre-commit (fast): formatting + cheap linters, run on every commit
# - pre-push (slow): full linters + tests, run before pushing
#
# Install both hook types once per clone:
# Install pinned tools, then install both hook types once per clone:
# python -m pip install -r requirements/requirements_ci-cd.txt
# pre-commit install
# pre-commit install --hook-type pre-push
#
# Manual runs:
# pre-commit run --all-files # everything (commit stage)
# pre-commit run --all-files --hook-stage pre-push # everything (push stage)

minimum_pre_commit_version: "3.5.0"
minimum_pre_commit_version: "4.5.1"

# Hook env Python version is whatever runs pre-commit itself.
# Tool versions are pinned via each hook's `rev:`, which is what
Expand Down Expand Up @@ -87,7 +88,7 @@ repos:
rev: 24.10.0
hooks:
- id: black
args: ["--line-length=79"] # matches CLAUDE.md code style
args: ["--line-length=79"] # matches AGENTS.md code style
exclude: ^(docs/|tests/data/)
stages: [pre-commit, pre-push]
- id: black-jupyter
Expand All @@ -110,14 +111,9 @@ repos:
hooks:
- id: pylint
name: pylint (errors only)
entry: pylint --disable=all --enable=E,F --disable=E0401
language: python
additional_dependencies: ["pylint==3.3.4"]
entry: pylint --disable=all --enable=E,F
language: system
types: [python]
# TODO: re-include proteopy/pl/intensities.py once its
# pre-existing E1133 false positives (hue_order inference in the
# isolated hook env) are resolved. Excluded to keep the
# proteoform-color fix commit scoped to the feature.
exclude: ^(docs/|proteopy/pl/intensities\.py)
exclude: ^docs/
require_serial: true
stages: [pre-commit, pre-push]
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ python:
- method: pip
path: .
- requirements: docs/sphinx/requirements.txt

6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ AnnData.X matrix is also sparse.


General argument guidelines:
- essential arguments which should be found in all functions unless it does not make sense:
- essential arguments which should be found in all functions unless it does not make sense:
adata : AnnData
Input AnnData with .X (obs x vars) and .var annotations.
Default=None (do not include this line in docstrings)
Expand Down Expand Up @@ -355,7 +355,7 @@ To ensure consistent plotting behavior across `pl.*` modules, adhere to the foll
Call plt.show() at the end of the function (default=True).

- `save: str | Path | None`
Save the figure: str/Path for a specific path, None to skip saving (default=None).
Save the figure: str/Path for a specific path, None to skip saving (default=None).

- `ax: matplotlib.axes.Axes | None`
Matplotlib Axes object to plot onto. If `None`, a new figure and axes are created. The function always returns the Axes object used for plotting (default=None).
Expand Down Expand Up @@ -712,7 +712,7 @@ To ensure consistent plotting behavior across `pl.*` modules, adhere to the foll
Call plt.show() at the end of the function (default=True).

- `save: str | Path | None`
Save the figure: str/Path for a specific path, None to skip saving (default=None).
Save the figure: str/Path for a specific path, None to skip saving (default=None).

- `ax: matplotlib.axes.Axes | None`
Matplotlib Axes object to plot onto. If `None`, a new figure and axes are created. The function always returns the Axes object used for plotting (default=None).
Expand Down
12 changes: 6 additions & 6 deletions docs/sphinx/source/_static/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
// Makes expand/collapse only trigger on arrow click, not link click

document.addEventListener("DOMContentLoaded", function() {

// Process all toctree links that have expandable children
document.querySelectorAll('.wy-menu-vertical .toctree-l1, .wy-menu-vertical .toctree-l2, .wy-menu-vertical .toctree-l3').forEach(function(li) {
const link = li.querySelector(':scope > a');
const ul = li.querySelector(':scope > ul');

// Only process items that have children (expandable)
if (!link || !ul) return;

// Create a toggle button for expand/collapse
const toggle = document.createElement('span');
toggle.className = 'nav-toggle';
toggle.setAttribute('role', 'button');
toggle.setAttribute('aria-label', 'Toggle submenu');

// Insert toggle after the link text
link.appendChild(toggle);

// Toggle expand/collapse on arrow click
toggle.addEventListener('click', function(e) {
e.preventDefault();
e.stopPropagation();
li.classList.toggle('current');
});

// Link click should only navigate, not toggle
link.addEventListener('click', function(e) {
// If clicking on the toggle, don't navigate
Expand Down
1 change: 0 additions & 1 deletion docs/sphinx/source/api/tl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ detection of functional proteoform groups from peptide-level quantitative data
proteopy.tl.peptide_dendograms_by_correlation
proteopy.tl.peptide_clusters_from_dendograms
proteopy.tl.proteoform_scores

Loading