From 08b4d6c2b8a6a3fb640688d42d8e92a68446d797 Mon Sep 17 00:00:00 2001 From: SvenKlaassen Date: Tue, 30 Jun 2026 09:03:19 +0200 Subject: [PATCH 1/3] update development setup with uv and adjust dependencies in pyproject.toml --- .github/workflows/pytest.yml | 2 +- .gitignore | 4 ++++ .python-version | 1 + CONTRIBUTING.md | 27 ++++++++++++++++++--------- README.md | 9 +++++++++ pyproject.toml | 6 ++++-- 6 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 .python-version diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 6548ef261..8fcf80220 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -46,7 +46,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -e .[dev,rdd] + pip install -e ".[rdd]" --group dev - name: Run pre-commit checks run: | diff --git a/.gitignore b/.gitignore index 5934c80cf..15e43279e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ MANIFEST # Setuptools SCM doubleml/_version.py + +# uv +.venv/ +uv.lock diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..e4fba2183 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a614dd73b..dc0031deb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,10 +79,19 @@ $ git merge upstream/main ``` 5. **Install DoubleML in editable mode** (more details can be found -[here](https://docs.doubleml.org/stable/intro/install.html#python-building-the-package-from-source)) -via +[here](https://docs.doubleml.org/stable/intro/install.html#python-building-the-package-from-source)). + +We recommend [uv](https://docs.astral.sh/uv/) for development. The following command creates a virtual +environment, provisions Python 3.12 (as pinned in `.python-version`), and installs DoubleML in editable +mode together with the `dev` dependency group and the `rdd` extra: +```bash +$ uv sync --extra rdd +``` +Prefix tooling commands with `uv run` to execute them inside this environment (e.g. `uv run pytest .`). + +Alternatively, you can use `pip` (requires pip >= 25.1 for the `--group` flag): ```bash -$ pip install --editable .[dev, rdd] +$ pip install --editable ".[rdd]" --group dev ``` 6. **Develop** your code changes. The changes can be added and pushed via @@ -109,7 +118,7 @@ When opening the PR you will be guided with a checklist. for details). To check, please run ```bash -$ pytest . +$ uv run pytest . # or, without uv: pytest . ``` - [x] If you add an **enhancements** or **new feature**, **unit tests** @@ -118,13 +127,13 @@ $ pytest . - [x] Check whether your changes adhere to the **PEP8 standards**. For the check you can use the following code ```bash -$ git diff upstream/main -u -- "*.py" | ruff check --diff +$ git diff upstream/main -u -- "*.py" | uv run ruff check --diff # or: ... | ruff check --diff ``` - [x] Check wether the code formatting adheres to the **Black code style** by running ```bash -$ black . --check --diff +$ uv run black . --check --diff # or, without uv: black . --check --diff ``` If your PR is still **work in progress**, please consider marking it a **draft PR** @@ -137,13 +146,13 @@ To ensure code quality and consistency before committing your changes, we recomm 1. **Install hooks**: If you haven't already, install the required hooks by running: ```bash - $ pre-commit install + $ uv run pre-commit install # or, without uv: pre-commit install ``` 2. **Run pre-commit manually**: To run the pre-commit checks manually, use: ```bash - $ pre-commit run --all-files + $ uv run pre-commit run --all-files # or, without uv: pre-commit run --all-files ``` ### Unit Tests and Test Coverage @@ -156,7 +165,7 @@ Coverage reports for the package, PRs, branches etc. are available from It is mandatory to equip new features with an appropriate level of unit test coverage. To **run all unit tests** (for further option see the [pytest docu](https://docs.pytest.org)) call ```bash -$ pytest --cov . +$ uv run pytest --cov . # or, without uv: pytest --cov . ``` If `pytest` is called with the `--cov` flag, a unit test coverage report is being generated. diff --git a/README.md b/README.md index 54e2e445a..64c5a13fa 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,15 @@ cd doubleml-for-py pip install --editable . ``` +For development we recommend [uv](https://docs.astral.sh/uv/), which sets up the +environment (including the `dev` dependency group) in one step: + +``` +git clone git@github.com:DoubleML/doubleml-for-py.git +cd doubleml-for-py +uv sync --extra rdd +``` + Detailed [installation instructions](https://docs.doubleml.org/stable/intro/install.html) can be found in the documentation. ## Contributing diff --git a/pyproject.toml b/pyproject.toml index 3e69a23f1..1ab4871bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,8 +25,7 @@ dependencies = [ "optuna>=4.6.0", "matplotlib>=3.9.0", "seaborn>=0.13", - "plotly>=5.0.0", - "mypy>=1.18.0" + "plotly>=5.0.0" ] classifiers = [ "Programming Language :: Python :: 3", @@ -42,6 +41,8 @@ classifiers = [ rdd = [ "rdrobust>=1.3.0" ] + +[dependency-groups] dev = [ "pytest>=8.3.0", "pytest-cov>=6.0.0", @@ -50,6 +51,7 @@ dev = [ "black>=25.1.0", "ruff>=0.11.1", "pre-commit>=4.2.0", + "mypy>=1.18.0", ] [project.urls] From 96737ee374396545d410be65e908f54e45c8d6e8 Mon Sep 17 00:00:00 2001 From: SvenKlaassen Date: Tue, 30 Jun 2026 10:45:44 +0200 Subject: [PATCH 2/3] fix: correct typos in CONTRIBUTING.md and .gitignore --- .gitignore | 1 - CONTRIBUTING.md | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 15e43279e..bda36077c 100644 --- a/.gitignore +++ b/.gitignore @@ -28,7 +28,6 @@ share/python-wheels/ *.vscode MANIFEST *.idea -*.vscode .flake8 .coverage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc0031deb..cb2dd3dc5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ DoubleML is a community effort. Everyone is welcome to contribute. -All contributors should adhere to this contributing guidelines +All contributors should adhere to these contributing guidelines and our [code of conduct](https://github.com/DoubleML/doubleml-for-py/blob/main/CODE_OF_CONDUCT.md). The contributing guidelines are particularly helpful to get started for your first contribution. @@ -34,7 +34,7 @@ In case of an exception the full traceback is appreciated. ```python import platform; print(platform.platform()) import sys; print("Python", sys.version) -import doubleml; print("DoubleML", sklearn.__version__) +import doubleml; print("DoubleML", doubleml.__version__) import sklearn; print("Scikit-Learn", sklearn.__version__) ``` @@ -130,7 +130,7 @@ For the check you can use the following code $ git diff upstream/main -u -- "*.py" | uv run ruff check --diff # or: ... | ruff check --diff ``` -- [x] Check wether the code formatting adheres to the **Black code style** +- [x] Check whether the code formatting adheres to the **Black code style** by running ```bash $ uv run black . --check --diff # or, without uv: black . --check --diff From 687fd029ff42dfaeb0156d4ca046415538489dfc Mon Sep 17 00:00:00 2001 From: SvenKlaassen Date: Tue, 30 Jun 2026 10:53:52 +0200 Subject: [PATCH 3/3] fix: update package name from 'sklearn' to 'scikit-learn' in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64c5a13fa..80e527930 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ It further can be readily extended with regards to **DoubleML** requires - Python -- sklearn +- scikit-learn - numpy - scipy - pandas