Skip to content

Commit 7ebab10

Browse files
juanitorduzdrbenvincenttwiecki
authored
Adopt Ruff linter and formatter (#268)
* adopt ruff * add ruff badge * Update README.md Co-authored-by: Thomas Wiecki <[email protected]> --------- Co-authored-by: Benjamin T. Vincent <[email protected]> Co-authored-by: Thomas Wiecki <[email protected]>
1 parent 0ef986a commit 7ebab10

File tree

7 files changed

+45
-66
lines changed

7 files changed

+45
-66
lines changed

.pre-commit-config.yaml

+25-39
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.4.0
6-
hooks:
7-
- id: trailing-whitespace
8-
exclude_types: [svg]
9-
- id: end-of-file-fixer
10-
exclude_types: [svg]
11-
- id: check-yaml
12-
- id: check-added-large-files
13-
- repo: https://github.com/pycqa/isort
14-
rev: 5.12.0
15-
hooks:
16-
- id: isort
17-
args: [--profile, black]
18-
types: [python]
19-
- repo: https://github.com/ambv/black
20-
rev: 23.3.0
21-
hooks:
22-
- id: black
23-
- repo: https://github.com/pycqa/flake8
24-
rev: 6.0.0
25-
hooks:
26-
- id: flake8
27-
- repo: https://github.com/nbQA-dev/nbQA
28-
rev: 1.7.0
29-
hooks:
30-
- id: nbqa-black
31-
# additional_dependencies: [jupytext] # optional, only if you're using Jupytext
32-
- id: nbqa-pyupgrade
33-
args: ["--py37-plus"]
34-
- id: nbqa-isort
35-
args: ["--float-to-top"]
36-
- repo: https://github.com/econchick/interrogate
37-
rev: 1.5.0
38-
hooks:
39-
- id: interrogate
40-
# needed to make excludes in pyproject.toml work
41-
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
42-
pass_filenames: false
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
exclude_types: [svg]
9+
- id: end-of-file-fixer
10+
exclude_types: [svg]
11+
- id: check-yaml
12+
- id: check-added-large-files
13+
- repo: https://github.com/charliermarsh/ruff-pre-commit
14+
rev: v0.1.4
15+
hooks:
16+
- id: ruff
17+
- id: ruff-format
18+
- repo: https://github.com/nbQA-dev/nbQA
19+
rev: 1.7.0
20+
hooks:
21+
- id: nbqa-ruff
22+
- repo: https://github.com/econchick/interrogate
23+
rev: 1.5.0
24+
hooks:
25+
- id: interrogate
26+
# needed to make excludes in pyproject.toml work
27+
# see here https://github.com/econchick/interrogate/issues/60#issuecomment-735436566
28+
pass_filenames: false

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
----
66

77
![Build](https://github.com/pymc-labs/CausalPy/workflows/ci/badge.svg)
8-
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
8+
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)]([https://codecov.io/gh/pymc-labs/CausalPy](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json))
99
[![PyPI version](https://badge.fury.io/py/CausalPy.svg)](https://badge.fury.io/py/CausalPy)
1010
![GitHub Repo stars](https://img.shields.io/github/stars/pymc-labs/causalpy?style=social)
1111
![Read the Docs](https://img.shields.io/readthedocs/causalpy)

causalpy/__init__.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import arviz as az
22

3-
import causalpy.pymc_experiments
4-
import causalpy.pymc_models
5-
import causalpy.skl_experiments
6-
import causalpy.skl_models
3+
from causalpy import pymc_experiments
4+
from causalpy import pymc_models
5+
from causalpy import skl_experiments
6+
from causalpy import skl_models
77
from causalpy.version import __version__
88

99
from .data import load_data
1010

1111
az.style.use("arviz-darkgrid")
12+
13+
__all__ = [
14+
"pymc_experiments",
15+
"pymc_models",
16+
"skl_experiments",
17+
"skl_models",
18+
"load_data",
19+
"__version__",
20+
]

docs/source/notebooks/did_skl.ipynb

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"metadata": {},
1414
"outputs": [],
1515
"source": [
16-
"import xarray as xr\n",
1716
"from sklearn.linear_model import LinearRegression\n",
1817
"\n",
1918
"import causalpy as cp"

docs/source/notebooks/geolift1.ipynb

+5-1
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,14 @@
346346
}
347347
],
348348
"source": [
349+
"formula = \"\"\"\n",
350+
" \"Denmark ~ 0 + Austria + Belgium + Bulgaria + Croatia + Cyprus + Czech_Republic\"\n",
351+
"\"\"\"\n",
352+
"\n",
349353
"result = cp.pymc_experiments.SyntheticControl(\n",
350354
" df,\n",
351355
" treatment_time,\n",
352-
" formula=\"Denmark ~ 0 + Austria + Belgium + Bulgaria + Croatia + Cyprus + Czech_Republic\",\n",
356+
" formula=formula,\n",
353357
" model=cp.pymc_models.WeightedSumFitter(\n",
354358
" sample_kwargs={\"target_accept\": 0.95, \"random_seed\": seed}\n",
355359
" ),\n",

pyproject.toml

+1-16
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,7 @@ docs = [
6363
"statsmodels",
6464
"sphinxcontrib-bibtex",
6565
]
66-
lint = [
67-
"black",
68-
"flake8",
69-
"interrogate",
70-
"isort",
71-
"nbqa",
72-
"pre-commit",
73-
"pylint",
74-
]
66+
lint = ["interrogate", "nbqa", "pre-commit", "ruff"]
7567
test = ["pytest", "pytest-cov"]
7668

7769
[metadata]
@@ -83,13 +75,6 @@ Homepage = "https://github.com/pymc-labs/CausalPy"
8375
"Bug Reports" = "https://github.com/pymc-labs/CausalPy/issues"
8476
"Source" = "https://github.com/pymc-labs/CausalPy"
8577

86-
[tool.black]
87-
line_length = 88
88-
89-
[tool.isort]
90-
profile = "black"
91-
skip_gitignore = true
92-
9378
[tool.pytest.ini_options]
9479
addopts = [
9580
"-vv",

setup.cfg

-4
This file was deleted.

0 commit comments

Comments
 (0)