Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop black in favor of ruff and generate stubs to expand docstrings in Pylance and IDEs #137

Merged
merged 9 commits into from
Jan 3, 2024
Merged
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
49 changes: 0 additions & 49 deletions .github/workflows/code-style.yaml

This file was deleted.

6 changes: 5 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off .[build]
python -m pip install --progress-bar off -e .[build,stubs]
- name: Display system information
run: pycrostates-sys_info --developer
- name: Generate stub files
run: python tools/stubgen.py
- name: Build and publish
env:
TWINE_USERNAME: __token__
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/stubs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: stubs
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}-${{ github.event.ref }}
cancel-in-progress: true
on: # yamllint disable-line rule:truthy
schedule:
- cron: '0 3 * * *'
workflow_dispatch:

jobs:
generate:
timeout-minutes: 10
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
architecture: 'x64'
- name: Install package
run: |
python -m pip install --progress-bar off --upgrade pip setuptools
python -m pip install --progress-bar off -e .[stubs]
- name: Display system information
run: pycrostates-sys_info --developer
- name: Generate stub files
run: python tools/stubgen.py
- name: Push stub files
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "deploy stub files [ci skip]"
git push
fi
19 changes: 7 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
ci:
skip: [codespell, pydocstyle, yamllint]

repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
files: pycrostates

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
hooks:
- id: black
args: [--quiet]
files: pycrostates

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
name: ruff linter
args: [--fix]
files: pycrostates
- id: ruff-format
name: ruff formatter
files: pycrostates

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--check-filenames, --ignore-words=.codespellignore, --skip=*.bib]
args: [--write-changes]
additional_dependencies: [tomli]

- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
Expand Down
2 changes: 1 addition & 1 deletion pycrostates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .utils._logs import set_log_level
from .utils.sys_info import sys_info # noqa: F401

__all__ = (
__all__: tuple[str, ...] = (
"cluster",
"datasets",
"metrics",
Expand Down
2 changes: 1 addition & 1 deletion pycrostates/cluster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .aahc import AAHCluster # noqa: F401
from .kmeans import ModKMeans # noqa: F401

__all__ = (
__all__: tuple[str, ...] = (
"ModKMeans",
"AAHCluster",
)
2 changes: 1 addition & 1 deletion pycrostates/cluster/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from .utils import optimize_order # noqa: F401

__all__ = ("optimize_order",)
__all__: tuple[str, ...] = ("optimize_order",)
2 changes: 1 addition & 1 deletion pycrostates/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@

from . import lemon

__all__ = ("lemon",)
__all__: tuple[str, ...] = ("lemon",)
2 changes: 1 addition & 1 deletion pycrostates/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .meas_info import ChInfo
from .reader import read_cluster

__all__ = ("ChData", "ChInfo", "read_cluster")
__all__: tuple[str, ...] = ("ChData", "ChInfo", "read_cluster")
2 changes: 1 addition & 1 deletion pycrostates/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .dunn import dunn_score
from .silhouette import silhouette_score

__all__ = (
__all__: tuple[str, ...] = (
"calinski_harabasz_score",
"davies_bouldin_score",
"dunn_score",
Expand Down
2 changes: 1 addition & 1 deletion pycrostates/preprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
from .resample import resample
from .spatial_filter import apply_spatial_filter

__all__ = ("apply_spatial_filter", "extract_gfp_peaks", "resample")
__all__: tuple[str, ...] = ("apply_spatial_filter", "extract_gfp_peaks", "resample")
2 changes: 1 addition & 1 deletion pycrostates/segmentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
compute_transition_matrix,
)

__all__ = (
__all__: tuple[str, ...] = (
"compute_expected_transition_matrix",
"compute_transition_matrix",
"EpochsSegmentation",
Expand Down
2 changes: 1 addition & 1 deletion pycrostates/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from ._config import get_config
from .utils import _compare_infos, _corr_vectors, _distance_matrix # noqa: F401

__all__ = ("get_config",)
__all__: tuple[str, ...] = ("get_config",)
Loading