Skip to content

Commit 2210818

Browse files
committed
pre-commit and instructions
1 parent 92ffa80 commit 2210818

6 files changed

Lines changed: 96 additions & 42 deletions

File tree

‎AGENTS.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22

33
## Tox
44

5-
- Run tox via uv: `uv run -- tox -e <env>`
5+
- Run tox via uv: `uv run tox -e <env>`
66
- `tox` + `tox-uv` are declared as the project's default dev dependencies in `pyproject.toml`, so uv installs them automatically into `.venv`.
77

88
## Package Manager
99

1010
Use **tox** for testing (not pytest directly):
1111
- Test matrix configuration is in `tox.ini`
12-
- Integration tests: `tox -e py3.14-{integration}-v{version}`
13-
- Common tests: `tox -e py3.14-common`
14-
- Run specific test file: `TESTPATH=tests/integrations/logging/test_logging.py tox -e py3.14-common`
15-
- Run single test: `TESTPATH=tests/path/to/test_file.py tox -e py3.14-common -- -k "test_name"`
12+
- Integration tests: `uv run tox -e py3.14-{integration}-v{version}`
13+
- Common tests: `uv run tox -e py3.14-common`
14+
- Run specific test file: `TESTPATH=tests/integrations/logging/test_logging.py uv run tox -e py3.14-common`
15+
- Run single test: `TESTPATH=tests/path/to/test_file.py uv run tox -e py3.14-common -- -k "test_name"`
1616

1717
## Type Checking
1818

1919
Use **tox** for type checking (not mypy directly):
20-
- Run `tox -e mypy` before committing (must pass with zero errors)
20+
- Run `uv run tox -e mypy` before committing (must pass with zero errors)
2121
- Strict mode enabled (`check_untyped_defs`, `disallow_untyped_defs`)
2222

2323
## Linting & Formatting
2424

2525
Use **tox** for linting (not ruff directly):
26-
- `tox -e ruff`
27-
- Full lint suite: `tox -e linters`
26+
- `uv run tox -e ruff`
27+
- Full lint suite: `uv run tox -e linters`
2828
- Full lint suite must pass before committing
2929

3030
## Commit Attribution

‎CONTRIBUTING.md‎

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,17 @@ Before you can contribute, you will need to [fork the `sentry-python` repository
7676

7777
### Create a Virtual Environment
7878

79-
To keep your Python development environment and packages separate from the ones
80-
used by your operation system, create a [virtual environment](https://docs.python.org/3/tutorial/venv.html):
79+
We use [uv](https://docs.astral.sh/uv/) to manage the project's virtual environment and dev dependencies. Install uv following the [official instructions](https://docs.astral.sh/uv/getting-started/installation/), then run:
8180

8281
```bash
8382
cd sentry-python
8483

85-
python -m venv .venv
84+
uv sync
8685
```
8786

88-
Then, activate your virtual environment with the following command. You will need to repeat this step every time you wish to work on your changes for `sentry-python`.
87+
This creates a `uv` managed `.venv` (using the Python version pinned in `.python-version`) and installs the project's dev dependencies (tox, tox-uv, etc.) into it. It is recommended not to deal with this `.venv` manually but only through `uv`.
8988

90-
```bash
91-
source .venv/bin/activate
92-
```
89+
Invoke commands via `uv run <cmd>` (e.g. `uv run tox -e py3.14-common`).
9390

9491
### Install `sentry-python` in Editable Mode
9592

@@ -103,16 +100,10 @@ pip install -e .
103100

104101
### Install Coding Style Pre-commit Hooks
105102

106-
This will make sure that your commits will have the correct coding style.
103+
`pre-commit` is included in the project's dev dependencies (installed by `uv sync`). Register the git hooks with:
107104

108105
```bash
109-
cd sentry-python
110-
111-
pip install -r requirements-devenv.txt
112-
113-
pip install pre-commit
114-
115-
pre-commit install
106+
uv run pre-commit install
116107
```
117108

118109
That's it. You should be ready to make changes, run tests, and make commits! If you experience any problems, please don't hesitate to ping us in our [Discord Community](https://discord.com/invite/Ww9hbqr).
@@ -121,34 +112,32 @@ That's it. You should be ready to make changes, run tests, and make commits! If
121112

122113
We test against a number of Python language and library versions, which are automatically generated and stored in the [tox.ini](tox.ini) file. The `envlist` defines the environments you can choose from when running tests, and correspond to package versions and environment variables. The `TESTPATH` environment variable, in turn, determines which tests are run.
123114

124-
The tox CLI tool is required to run the tests locally. Follow [the installation instructions](https://tox.wiki/en/latest/installation.html) for tox. Dependencies are installed for you when you run the command below, but _you_ need to bring an appropriate Python interpreter.
125-
126-
[Pyenv](https://github.com/pyenv/pyenv) is a cross-platform utility for managing Python versions. You can also use a conventional package manager, but not all versions may be distributed in the package manager of your choice. For macOS, versions 3.8 and up can be installed with Homebrew.
115+
`uv` manages both `tox` (installed as a dev dependency via `uv sync`) and the Python interpreters used by each tox environment — you don't need to install them yourself. Invoke tox via `uv run tox ...`.
127116

128117
An environment consists of the Python major and minor version and the library name and version. The exception to the rule is that you can provide `common` instead of the library information. The environments tied to a specific library usually run the corresponding test suite, while `common` targets all tests but skips those that require uninstalled dependencies.
129118

130119
To run Celery tests for version v5.5.3 of its Python library using a 3.12 interpreter, use
131120

132121
```bash
133-
tox -p auto -o -e py3.12-celery-v5.5.3
122+
uv run tox -p auto -o -e py3.12-celery-v5.5.3
134123
```
135124

136125
or to use the `common` environment, run
137126

138127
```bash
139-
tox -p auto -o -e py3.12-common
128+
uv run tox -p auto -o -e py3.12-common
140129
```
141130

142131
To select specific tests, you can forward arguments to `pytest` like so
143132

144133
```bash
145-
tox -p auto -o -e py3.12-celery-v5.5.3 -- -k test_transaction_events
134+
uv run tox -p auto -o -e py3.12-celery-v5.5.3 -- -k test_transaction_events
146135
```
147136

148137
In general, you use
149138

150139
```bash
151-
tox -p auto -o -e <tox_env> -- <pytest_args>
140+
uv run tox -p auto -o -e <tox_env> -- <pytest_args>
152141
```
153142

154143
## Debugging

‎Makefile‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL = /bin/bash
22

3-
VENV_PATH = tox.venv
3+
VENV_PATH = .venv
44

55
help:
66
@echo "Thanks for your interest in the Sentry Python SDK!"
@@ -12,17 +12,17 @@ help:
1212
@echo
1313
@false
1414

15-
$(VENV_PATH):
15+
.venv:
1616
python -m venv $(VENV_PATH)
17-
$(VENV_PATH)/bin/pip install tox tox-uv
17+
$(VENV_PATH)/bin/pip install tox
1818

19-
dist: $(VENV_PATH)
19+
dist: .venv
2020
rm -rf dist dist-serverless build
2121
$(VENV_PATH)/bin/pip install wheel setuptools
2222
$(VENV_PATH)/bin/python setup.py sdist bdist_wheel
2323
.PHONY: dist
2424

25-
apidocs: $(VENV_PATH)
25+
apidocs: .venv
2626
@$(VENV_PATH)/bin/pip install --editable .
2727
@$(VENV_PATH)/bin/pip install -U -r ./requirements-docs.txt
2828
rm -rf docs/_build

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#
22
# Project dev dependencies (PEP 735 `dev` group, installed by default).
3-
# Run tox with: `uv run -- tox -e <env>`
3+
# Run tox with: `uv run tox -e <env>`
44
#
55

66
[dependency-groups]
77
dev = [
88
"tox",
99
"tox-uv",
1010
"coverage[toml]",
11+
"pre-commit",
1112
]
1213

1314
#

‎requirements-devenv.txt‎

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

‎uv.lock‎

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)