Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
302 lines (280 loc) · 12.1 KB
/
Copy pathpyproject.toml
File metadata and controls
302 lines (280 loc) · 12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
[build-system]
# Minimum requirements for the build system to execute.
build-backend = "setuptools.build_meta"
requires = ["setuptools>=61.0"]
# This is configuration specific to the `setuptools` build backend.
# If you are using a different build backend, you will need to change this.
[tool.setuptools.packages.find]
exclude = ["causalpy.test*", "docs*"]
[tool.setuptools.dynamic]
version = {attr = "causalpy.version.__version__"}
[tool.setuptools.package-data]
"causalpy.data" = ["*.csv"]
"causalpy.templates" = ["*.html"]
[project]
name = "CausalPy"
dynamic = ["version"]
description = "Causal inference for quasi-experiments in Python"
readme = "README.md"
license = { file = "LICENSE" }
authors = [{ name = "Ben Vincent", email = "ben.vincent@pymc-labs.com" }]
requires-python = ">=3.12"
keywords = ["causal inference", "statistics", "econometrics", "pymc", "bayesian"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Scientific/Engineering :: Mathematics",
]
# This field lists other packages that your project depends on to run.
# Any package you put here will be installed by pip when your project is
# installed, so they must be valid existing projects.
#
# For an analysis of this field vs pip's requirements files see:
# https://packaging.python.org/discussions/install-requires-vs-requirements/
dependencies = [
"arviz>=1.1,<2",
"graphviz",
"ipython!=8.7.0",
"jinja2",
"matplotlib>=3.5.3",
"narwhals>=1.13.1",
"numpy",
"packaging",
"pandas<4,>=2.3",
"patsy",
"plotnine>=0.15.9",
"polars",
# Keep these public major-version ranges broad. PyMC metadata supplies compatible PyTensor patch-level ranges, so base installs may select newer PyMC/PyTensor minors.
# The docs-only PyMC-Marketing pin in docs/requirements.txt has its own narrower resolver constraints; it does not restrict normal runtime installs.
# pymc-extras 0.11 is the first release that declares PyMC 6 support and provides the structural state-space API CausalPy imports.
"pymc>=6.0.1,<7",
"pytensor>=3,<4",
"scikit-learn>=1",
"scipy",
"seaborn>=0.11.2",
"statsmodels",
"xarray>=v2022.11.0",
"pymc-extras>=0.11",
]
# List additional groups of dependencies here (e.g. development dependencies). Users
# will be able to install these using the "extras" syntax, for example:
#
# $ pip install causalpy[dev]
#
# Similar to `dependencies` above, these must be valid existing projects.
[project.optional-dependencies]
# pymc-forecast is young (0.x); pin the minor so API movement across 0.x
# minors is opted into deliberately (see docs on the ITS forecast backend).
# The [extras] marker pulls pymc-extras>=0.10, which upstream declares for
# the Pathfinder integration the adapter advertises.
forecast = [
"pymc-forecast[extras]>=0.4,<0.5",
]
dev = [
"prek",
# Pinned: a type checker that floats turns an untouched branch red whenever upstream ships new checks. Bump deliberately, with the allowlist in [tool.mypy] re-measured (issue #1127). TOML cannot share the value, so the same pin appears in the ``lint`` extra below and the two must be bumped together.
"mypy==2.4.1",
"twine",
"codespell",
"nbformat",
"nbconvert",
"PyYAML",
# Editor/agent tooling used during development; not a runtime or test dependency.
"marimo[mcp]",
]
docs = [
"ipykernel",
"maketables",
"daft-pgm",
"pymc-bart",
"linkify-it-py",
"myst-nb<=1.4.0",
"pylint>=4.1.1",
"sphinx",
"sphinx-autodoc-typehints",
"sphinx_autodoc_defaultargs",
"labs-sphinx-theme",
"sphinx-copybutton",
"sphinx-sitemap",
"statsmodels",
"sphinxcontrib-bibtex>=2.7.0",
"sphinx-notfound-page",
"ipywidgets",
"sphinx-design",
"sphinx-togglebutton",
"nbformat",
"nbconvert",
"Pillow",
"PyYAML",
"sphinxext-opengraph",
"sphinxext-rediraffe",
]
# The mypy pin here must match the one in the ``dev`` extra above; TOML cannot share the value, so bump both together.
lint = ["prek", "ruff", "mypy==2.4.1"]
test = [
"pytest",
"pytest-cov",
"pytest-xdist",
"diff-cover",
"codespell",
"nbformat",
"nbconvert",
"papermill",
"polars",
"pyarrow",
"pymc-forecast[extras]>=0.4,<0.5",
]
[tool.pyproject2conda]
channels = ["conda-forge"]
# pymc-forecast and marimo are PyPI-only (not on conda-forge, or not
# resolvable with the ``[mcp]`` extra via conda): route them to the pip
# section of the generated environment.yml.
[tool.pyproject2conda.dependencies]
pymc-forecast = { pip = true }
marimo = { pip = true }
# uv is the canonical resolver for local dev + CI (uv.lock). environment.yml
# (generated via pyproject2conda) remains a supported alternative for
# contributors who prefer conda/micromamba; see CONTRIBUTING.md.
#
# Two conflicting dependency groups pin the pandas major version tested in
# CI so a single uv.lock can hold both pandas 2.3 and pandas 3.x resolutions
# (the base `dependencies` pandas constraint stays broad: >=2.3,<4).
[dependency-groups]
pandas2 = ["pandas>=2.3,<3"]
pandas3 = ["pandas<4,>=3"]
[tool.uv]
conflicts = [
[
{ group = "pandas2" },
{ group = "pandas3" },
],
]
[project.urls]
Homepage = "https://github.com/pymc-labs/CausalPy"
"Bug Reports" = "https://github.com/pymc-labs/CausalPy/issues"
Source = "https://github.com/pymc-labs/CausalPy"
Documentation = "https://causalpy.readthedocs.io"
Changelog = "https://github.com/pymc-labs/CausalPy/releases"
Discussions = "https://github.com/pymc-labs/CausalPy/discussions"
[tool.pytest.ini_options]
addopts = [
"-vv",
"-m",
"not correctness and not nightly",
"--strict-markers",
"--strict-config",
"--cov=causalpy",
"--cov-report=term-missing",
]
testpaths = "causalpy/tests"
markers = [
"integration: mark as an integration test.",
"slow: mark test as slow.",
"nightly: heavy test deselected on PRs by the default addopts; runs in .github/workflows/nightly.yml. Run locally with `make test-nightly`.",
"correctness: mark statistical correctness and reproducibility tests.",
]
[tool.ruff.format]
docstring-code-format = true
[tool.ruff.lint]
# Pin explicit rule set (not extend-select) so ruff default expansions do not
# silently add new rule families on version bumps.
select = [
"E4", # pycodestyle errors (import)
"E7", # pycodestyle errors (statement)
"E9", # pycodestyle errors (runtime)
"F", # pyflakes - detect unused imports, undefined names
"I", # isort
"B", # flake8-bugbear - find likely bugs and design problems
"UP", # pyupgrade - modern Python syntax upgrades
"C4", # flake8-comprehensions - better list/dict comprehensions
"SIM", # flake8-simplify - suggest simpler code
]
[tool.ruff.lint.per-file-ignores]
# Notebooks display dataframes via bare expressions on the last line of a cell.
"*.ipynb" = ["B018"]
[tool.codespell]
ignore-words = "./docs/source/.codespell/codespell-whitelist.txt"
# uv.lock is autogenerated (`uv lock`) and full of third-party package names
# (e.g. "astroid") that trip codespell false positives; never hand-edit it anyway.
skip = "*.ipynb,*.csv,*.svg,pyproject.toml,docs/source/.codespell/codespell-whitelist.txt,uv.lock"
# Numpydoc validation. Originally introduced under #886 as a narrow check on public ``.plot`` overrides, expanded under #898 to enforce a curated set of numpydoc rules across the whole ``causalpy`` package. The ``exclude`` regex matches any dotted node whose path contains a private (underscore-prefixed) component — private helpers, dunders, and members of private modules are considered implementation detail and not subject to docstring validation.
[tool.numpydoc_validation]
checks = [
"PR01", # Parameters not documented
"PR02", # Unknown parameters
"PR04", # Parameter has no type
"PR07", # Parameter has no description
"PR10", # Parameter requires a space before the colon
"RT03", # Return value has no description
"SS03", # Summary does not end with a period
"GL07", # Sections are in the wrong order
"GL08", # Object does not have a docstring
]
exclude = ['\._']
[tool.coverage.run]
source = ["causalpy"]
omit = ["*/conftest.py", "*/tests/conftest.py"]
branch = true # Also measure branch coverage, not just line coverage
[tool.coverage.report]
fail_under = 80
show_missing = true
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if self.debug:",
"if settings.DEBUG",
"raise AssertionError",
"raise NotImplementedError",
"if 0:",
"if __name__ == .__main__.:",
"class .*\\bProtocol\\):",
"@(abc\\.)?abstractmethod",
]
# Type checking (issue #1127). ``files = "causalpy"`` recurses, so the subpackages are covered; the old ``causalpy/*.py`` glob did not and only reached the 18 top-level modules. ``make typecheck`` runs this from the project environment, where the real dependencies are importable, and CI runs the same target. ``ignore_missing_imports`` drops the untyped-third-party noise (pymc, patsy, arviz and friends ship no stubs).
[tool.mypy]
files = "causalpy"
exclude = "build|dist|docs|notebooks|tests|setup.py"
ignore_missing_imports = true
# Report a per-module override that stops matching a real module, so a rename or a deletion does not leave a stale entry behind unnoticed. This warns rather than fails: mypy prints ``note: unused section(s)`` and still exits 0. There are no overrides left, and this keeps it that way if one is ever added and then outlives its module.
warn_unused_configs = true
# The allowlist is empty: the package type-checks clean. What could not be expressed in the type system is a handful of line-level ``type: ignore`` comments, each with the reasoning next to it.
#
# ``warn_unused_ignores`` keeps those comments self-cleaning: a fix that removes the underlying error now fails the check unless the now-unneeded ignore is deleted with it.
warn_unused_ignores = true
[tool.marimo.runtime]
watcher_on_save = "autorun"
# PyMarkdown linter (pre-commit hook) configuration. Primary motivator (issue #899) is enforcing MD032 — lists must be surrounded by blank lines — to mirror the docstring rule already enforced by ``validate-docstring-lists`` (issue #892). The rules below are deliberately disabled because they conflict with project conventions or are noisy on the existing Markdown corpus (see PR #900 for the audit).
[tool.pymarkdown]
# Enable GitHub-flavoured / front-matter extensions so the linter understands YAML front-matter (skill files), GFM task lists, tables, strikethrough, and extended autolinks.
extensions.front-matter.enabled = true
extensions.markdown-task-list-items.enabled = true
extensions.markdown-tables.enabled = true
extensions.markdown-strikethrough.enabled = true
extensions.markdown-extended-autolinks.enabled = true
# Project convention: do not hard-wrap Markdown lines (see AGENTS.md).
plugins.md013.enabled = false
# Many top-level docs (skills, command snippets) start with YAML front-matter or a short paragraph rather than an H1.
plugins.md041.enabled = false
# Allow a mix of setext and atx headings across files.
plugins.md003.enabled = false
# Allow ``1. item`` style list-marker spacing produced by some editors.
plugins.md030.enabled = false
# Allow varying unordered-list indentation.
plugins.md007.enabled = false
# Skill / agent description lines naturally end in punctuation when promoted to headings by the renderer.
plugins.md026.enabled = false
# Bold text used as pseudo-headings is an established pattern in skill files.
plugins.md036.enabled = false
# Templates and reference docs intentionally repeat heading text.
plugins.md024.enabled = false
# Inline HTML (e.g. ``<details>`` blocks) is occasionally used in long-form docs.
plugins.md033.enabled = false
# Shell-prompt prefixes (``$ cmd``) are useful in setup instructions.
plugins.md014.enabled = false
# Image alt text is enforced in notebooks separately; .md image usage is rare.
plugins.md045.enabled = false