Skip to content

Commit d6dd40c

Browse files
authored
Merge pull request #113 from elbersb/ruff
Switch to ruff for linting/formatting
2 parents f6419be + b0d5b2c commit d6dd40c

47 files changed

Lines changed: 352 additions & 473 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/confidence.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ jobs:
1313
runs-on: ubuntu-latest
1414
strategy:
1515
matrix:
16-
python-version: ['3.9', '3.10', '3.11', '3.12']
16+
include:
17+
- python-version: '3.9'
18+
tox-env: py39-min
19+
- python-version: '3.10'
20+
tox-env: py310
21+
- python-version: '3.11'
22+
tox-env: py311
23+
- python-version: '3.12'
24+
tox-env: py312
1725

1826
steps:
1927
- uses: actions/checkout@v4
@@ -26,9 +34,7 @@ jobs:
2634
with:
2735
enable-cache: true
2836
cache-dependency-glob: "**/pyproject.toml"
29-
- name: Install dependencies
30-
run: |
31-
uv pip install --system -e ".[dev]"
32-
uv pip install --system tox tox-gh-actions
37+
- name: Install tox
38+
run: uv pip install --system tox tox-uv
3339
- name: Test with tox
34-
run: tox
40+
run: tox -e ${{ matrix.tox-env }}

.github/workflows/python-publish.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ jobs:
2323
uses: actions/setup-python@v5
2424
with:
2525
python-version: '3.11'
26-
- name: Install dependencies
27-
run: |
28-
python -m pip install --upgrade pip
29-
pip install build
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
- name: Install build tools
29+
run: uv pip install --system build
3030
- name: Build package
31-
run: python -m build
31+
run: uv build
3232
- name: Publish a Python distribution to PyPI
3333
uses: pypa/gh-action-pypi-publish@release/v1
3434
with:

.gitignore

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ coverage.xml
4949
*.mo
5050
*.pot
5151

52-
# Django stuff:
53-
*.log
54-
local_settings.py
55-
56-
# Flask stuff:
57-
instance/
58-
.webassets-cache
59-
60-
# Scrapy stuff:
61-
.scrapy
62-
6352
# Sphinx documentation
6453
docs/_build/
6554

@@ -72,26 +61,20 @@ target/
7261
# pyenv
7362
.python-version
7463

75-
# celery beat schedule file
76-
celerybeat-schedule
77-
7864
# dotenv
7965
.env
8066

8167
# virtualenv
8268
venv/
8369
ENV/
8470

85-
# Spyder project settings
86-
.spyderproject
87-
88-
# Rope project settings
89-
.ropeproject
90-
9171
.DS_store
92-
9372
.idea/
9473

9574
# uv
9675
uv.lock
97-
.venv/
76+
.venv/
77+
78+
.mypy_cache/
79+
.pytest_cache/
80+
.ruff_cache/

CLAUDE.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Spotify Confidence is a Python library for A/B test analysis. It provides conven
1111
### Setup
1212
```bash
1313
# Install with development dependencies (including tox-uv)
14-
uv pip install -e ".[dev]"
14+
uv pip install -e . --group dev
1515
```
1616

1717
### Testing
@@ -34,17 +34,14 @@ uv run tox
3434

3535
### Code Quality
3636
```bash
37-
# Format code with black (line length: 119)
38-
uv run black spotify_confidence tests
37+
# Run linting
38+
uv run ruff check
3939

40-
# Check formatting without making changes
41-
uv run black --check --diff spotify_confidence tests
42-
43-
# Lint with flake8 (max line length: 120)
44-
uv run flake8 spotify_confidence tests
40+
# Run formatting
41+
uv run ruff format
4542

4643
# Run all quality checks (as done in CI)
47-
uv run black --check --diff spotify_confidence tests && uv run flake8 spotify_confidence tests && uv run pytest
44+
uv run ruff check && uv run ruff format && uv run pytest
4845
```
4946

5047
### Build
@@ -151,7 +148,4 @@ The project uses `tox-uv` to leverage uv's fast package installation and environ
151148

152149
## Code Style
153150

154-
- Black formatting with 119 character line length
155-
- Flake8 linting with max line length 120
156-
- Ignored flake8 rules: E203, E231, W503
157-
- Excluded from linting: `.venv`, `.tox`, `dist`, `build`, `scratch.py`, `confidence_dev`
151+
Uses ruff linting and formatting.

CONTRIBUTING.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Ready to contribute? Here's how to set up `confidence` for local development.
7171
3. Set up your development environment using uv::
7272

7373
$ uv venv
74-
$ uv pip install -e ".[dev]"
74+
$ uv pip install -e . --group dev
7575

7676
This creates a virtual environment and installs the package in editable mode with all development dependencies.
7777

@@ -89,9 +89,9 @@ Ready to contribute? Here's how to set up `confidence` for local development.
8989

9090
6. When you're done making changes, check that your changes pass all quality checks::
9191

92-
$ uv run black spotify_confidence tests --line-length 119 # Format code
93-
$ uv run flake8 spotify_confidence tests # Lint code
94-
$ uv run pytest # Run tests
92+
$ uv run ruff format # Format code
93+
$ uv run ruff check # Lint code
94+
$ uv run pytest # Run tests
9595

9696
To test across all supported Python versions (3.9, 3.10, 3.11, 3.12)::
9797

HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
History
33
=======
44

5+
in development
6+
--------------
7+
* Modernize infrastructure (pyproject.toml, uv, ruff, update dependencies)
8+
59
4.0.0 (2024-11-24)
610
------------------
711
* Update mininum requirement for Chartify to avoid cropping bug in `chrome-webdriver`

Makefile

Lines changed: 0 additions & 96 deletions
This file was deleted.

pyproject.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@ dependencies = [
2424
"ipywidgets>=8.0.0",
2525
]
2626

27-
[project.optional-dependencies]
27+
[dependency-groups]
2828
dev = [
2929
"build",
3030
"twine",
31-
"black>=23.7.0",
32-
"flake8>=6.0.0",
31+
"ruff>=0.14.11",
3332
"tox>=4.0.0",
3433
"tox-uv>=1.0.0",
3534
"pytest>=7.0.0",
@@ -47,9 +46,12 @@ where = ["."]
4746
include = ["spotify_confidence*"]
4847
namespaces = false
4948

50-
[tool.black]
49+
[tool.ruff]
5150
line-length = 119
52-
target-version = ["py39", "py310", "py311", "py312"]
51+
extend-exclude = ["examples/"]
52+
53+
[tool.ruff.format]
54+
quote-style = "double"
5355

5456
[tool.pytest.ini_options]
5557
addopts = "-v -n auto --cov=spotify_confidence --cov-report=html --cov-report=xml --cov-report=term-missing"

spotify_confidence/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
# limitations under the License.
1414

1515
from importlib.metadata import version as _version
16-
from .analysis.bayesian.bayesian_models import BetaBinomial
16+
1717
from spotify_confidence.analysis.frequentist.chi_squared import ChiSquared
18+
from spotify_confidence.analysis.frequentist.experiment import Experiment
19+
from spotify_confidence.analysis.frequentist.sample_size_calculator import SampleSizeCalculator
1820
from spotify_confidence.analysis.frequentist.t_test import StudentsTTest
1921
from spotify_confidence.analysis.frequentist.z_test import ZTest
2022
from spotify_confidence.analysis.frequentist.z_test_linreg import ZTestLinreg
21-
from spotify_confidence.analysis.frequentist.experiment import Experiment
22-
from spotify_confidence.analysis.frequentist.sample_size_calculator import SampleSizeCalculator
23-
from .samplesize.sample_size_calculator import SampleSize
2423

2524
from . import examples
25+
from .analysis.bayesian.bayesian_models import BetaBinomial
2626
from .options import options
27+
from .samplesize.sample_size_calculator import SampleSize
2728

2829
__version__ = _version("spotify_confidence")
2930

spotify_confidence/analysis/abstract_base_classes/confidence_abc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
# limitations under the License.
1414

1515
from abc import ABC, abstractmethod
16-
from typing import Union, Iterable, Tuple, List
16+
from typing import Iterable, List, Tuple, Union
1717

1818
from pandas import DataFrame
1919

2020
from spotify_confidence.chartgrid import ChartGrid
21+
22+
from ..constants import NIM_TYPE
2123
from .confidence_computer_abc import ConfidenceComputerABC
2224
from .confidence_grapher_abc import ConfidenceGrapherABC
23-
from ..constants import NIM_TYPE
2425

2526

2627
class ConfidenceABC(ABC):

0 commit comments

Comments
 (0)