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

Upgrade and use ruff==0.4.8 and support numpy>=2.0.0 #176

Merged
merged 9 commits into from
Jun 19, 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
7 changes: 4 additions & 3 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ jobs:
python-version: "3.10"
- name: Install deps
run: |
pip install -r requirements/fitting-requirements.txt
pip install pytest pytest-benchmark pytest-coverage
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system -r requirements/fitting-requirements.txt
uv pip install --system pytest pytest-benchmark pytest-coverage
- name: Install module
run: |
pip install .
uv pip install --system .
- name: Run benchmark
run: |
pytest tests/benchmark*.py --benchmark-json output.json
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@ on:
branches: [master]

jobs:
black-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
sphinx-lint:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -21,7 +16,13 @@ jobs:
python-version: "3.10"
- name: Install deps
run: |
pip install sphinx-lint
pip install sphinx-lint ruff==0.4.8
- name: ruff
run: |
ruff check src/elli tests
- name: ruff formatting
run: |
ruff format --check src/elli tests
- name: Run Sphinx Linting
run: |
sphinx-lint .
8 changes: 3 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -25,12 +25,10 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Install module
run: |
pip install .[fitting,testing]
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system ".[fitting,dev]"
- name: Test with pytest
run: |
pytest --nbmake
8 changes: 3 additions & 5 deletions .github/workflows/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install package (no deps)
run: |
pip install --no-deps .[fitting,testing]
curl -LsSf https://astral.sh/uv/install.sh | sh
uv pip install --system --no-deps .[fitting,dev]
- name: Install dev requirements
run: |
python -m pip install -r requirements/dev-requirements.txt
uv pip install --system -r requirements/dev-requirements.txt
- name: Test with pytest
run: |
pytest --nbmake
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ __pycache__/*
.pydevproject
.settings
.idea
.vscode
tags

# Package files
Expand Down
19 changes: 7 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.8
hooks:
- id: black
language_version: python3.10
# - repo: local
# hooks:
# - id: pylint
# name: pylint
# entry: pylint
# language: system
# types: [python]
# args: ["-rn", "--rcfile", ".pylintrc"]
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: local
hooks:
- id: sphinx-lint
Expand Down
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.rulers": [90],
"editor.renderWhitespace": "all",
"editor.tabSize": 4,
"files.trimTrailingWhitespace": true,
"[python]": {
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "charliermarsh.ruff"
},
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ or **Miniconda**

4. You should run

pip install -U pip setuptools -e .[fitting,testing]
pip install -U pip setuptools -e .[fitting,dev]

which installs the package in development mode and all extra requirements in your current virtualenv.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

--------

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyElli) [![PyPI](https://img.shields.io/pypi/v/pyElli)](https://pypi.org/project/pyElli/) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5702469.svg)](https://doi.org/10.5281/zenodo.5702469) [![Pytest](https://github.com/PyEllips/pyElli/actions/workflows/pytest.yml/badge.svg)](https://github.com/PyEllips/pyElli/actions/workflows/pytest.yml) [![Documentation Status](https://readthedocs.org/projects/pyelli/badge/?version=latest)](https://pyelli.readthedocs.io/en/latest/?badge=latest) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pyElli) [![PyPI](https://img.shields.io/pypi/v/pyElli)](https://pypi.org/project/pyElli/) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5702469.svg)](https://doi.org/10.5281/zenodo.5702469) [![Pytest](https://github.com/PyEllips/pyElli/actions/workflows/pytest.yml/badge.svg)](https://github.com/PyEllips/pyElli/actions/workflows/pytest.yml) [![Documentation Status](https://readthedocs.org/projects/pyelli/badge/?version=latest)](https://pyelli.readthedocs.io/en/latest/?badge=latest) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

[![](https://dcbadge.vercel.app/api/server/zCBNMtBFAQ?compact=true)](https://discord.gg/zCBNMtBFAQ)

Expand Down
46 changes: 42 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ authors = [
{ name = "Marius Müller", email = "[email protected]" },
{ name = "Florian Dobener", email = "[email protected]" }
]
requires-python = ">=3.7"
requires-python = ">=3.8"
license = { file = "LICENSE.txt" }
readme = "README.md"
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -25,6 +24,7 @@ classifiers = [
dependencies = [
"scipy",
"numpy>=1.20",
"numpy<2.0.0;python_version<'3.10'",
"pandas>=1.0.0",
"h5py",
"pyyaml",
Expand All @@ -42,10 +42,13 @@ fitting = [
"matplotlib",
"lmfit"
]
testing = [
dev = [
"pytest",
"pytest-cov",
"nbmake"
"nbmake",
"ruff==0.4.8",
"uv",
"pre-commit",
]

[project.urls]
Expand All @@ -63,3 +66,38 @@ local_scheme = "node-and-date"
[tool.setuptools.packages.find]
where = ["src"]
exclude = ["tests*"]

[tool.ruff]
include = ["src/*.py", "tests/*.py"]
line-length = 88
indent-width = 4

[tool.ruff.lint]
select = [
"E", # pycodestyle
"W", # pycodestyle
"PL", # pylint
"NPY201", # numpy
]
ignore = [
"E501", # Line too long ({width} > {limit} characters)
"E701", # Multiple statements on one line (colon)
"E731", # Do not assign a lambda expression, use a def
"E402", # Module level import not at top of file
"PLR0911", # Too many return statements
"PLR0912", # Too many branches
"PLR0913", # Too many arguments in function definition
"PLR0915", # Too many statements
"PLR2004", # Magic value used instead of constant
"PLW0603", # Using the global statement
"PLW2901", # redefined-loop-name
"PLR1714", # consider-using-in
"PLR5501", # else-if-used
]
fixable = ["ALL"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"
Loading
Loading