Skip to content

Commit d0621cb

Browse files
committed
Update CONTRIBUTING.md
1 parent 61c10ea commit d0621cb

1 file changed

Lines changed: 50 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,62 @@ On macOS, we recommend using `brew` to install Python. For Windows, we recommend
7474

7575
Before you can contribute, you will need to [fork the `sentry-python` repository](https://github.com/getsentry/sentry-python/fork). Then, clone the forked repository to your local development environment.
7676

77-
### Create a Virtual Environment
77+
78+
### Development Tooling
7879

7980
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:
8081

8182
```bash
8283
cd sentry-python
83-
8484
uv sync
8585
```
8686

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`.
88-
8987
Invoke commands via `uv run <cmd>` (e.g. `uv run tox -e py3.14-common`).
9088

91-
### Install `sentry-python` in Editable Mode
89+
#### Linting / Formatting
9290

93-
Install `sentry-python` in [editable mode](https://pip.pypa.io/en/latest/topics/local-project-installs/#editable-installs). This will make any changes you make to the SDK code locally immediately effective without you having to reinstall or copy anything.
91+
We use `ruff` to lint and format our code. Use the following commands:
9492

95-
```bash
96-
pip install -e .
93+
```
94+
uv run ruff check --fix tests sentry_sdk
95+
uv run ruff format tests sentry_sdk
9796
```
9897

99-
**Hint:** Sometimes you need a sample project to run your new changes to `sentry-python`. In this case install the sample project in the same virtualenv and you should be good to go.
98+
#### Typing
10099

101-
### Install Coding Style Pre-commit Hooks
100+
We use `mypy` for typing our codebase. Use the following command to typecheck the source:
101+
102+
```
103+
uv run --group typing mypy sentry_sdk
104+
```
105+
106+
##### Install Coding Style Pre-commit Hooks
102107

103108
`pre-commit` is included in the project's dev dependencies (installed by `uv sync`). Register the git hooks with:
104109

105110
```bash
106111
uv run pre-commit install
107112
```
108113

114+
Now, pre-commit will automatically lint your changes with `ruff`.
115+
116+
117+
### Install `sentry-python` in Editable Mode
118+
119+
Install `sentry-python` in [editable mode](https://pip.pypa.io/en/latest/topics/local-project-installs/#editable-installs). This will make any changes you make to the SDK code locally immediately effective without you having to reinstall or copy anything.
120+
121+
```bash
122+
pip install -e .
123+
```
124+
125+
or
126+
127+
```bash
128+
uv add --editable .
129+
```
130+
131+
**Hint:** Sometimes you need a sample project to run your new changes to `sentry-python`. In this case install the sample project in the same virtualenv and you should be good to go.
132+
109133
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).
110134

111135
## Running Tests
@@ -116,28 +140,40 @@ We test against a number of Python language and library versions, which are auto
116140

117141
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.
118142

143+
To list all tox environments:
144+
145+
```bash
146+
uv run tox -l
147+
```
148+
119149
To run Celery tests for version v5.5.3 of its Python library using a 3.12 interpreter, use
120150

121151
```bash
122-
uv run tox -p auto -o -e py3.12-celery-v5.5.3
152+
uv run tox -e py3.12-celery-v5.5.3
123153
```
124154

125155
or to use the `common` environment, run
126156

127157
```bash
128-
uv run tox -p auto -o -e py3.12-common
158+
uv run tox -e py3.12-common
159+
```
160+
161+
To run a specific file:
162+
163+
```bash
164+
TESTPATH=tests/integrations/logging/test_logging.py uv run tox -e py3.12-common
129165
```
130166

131167
To select specific tests, you can forward arguments to `pytest` like so
132168

133169
```bash
134-
uv run tox -p auto -o -e py3.12-celery-v5.5.3 -- -k test_transaction_events
170+
uv run tox -e py3.12-celery-v5.5.3 -- -k test_transaction_events
135171
```
136172

137173
In general, you use
138174

139175
```bash
140-
uv run tox -p auto -o -e <tox_env> -- <pytest_args>
176+
TESTPATH=<file_path> uv run tox -e <tox_env> -- <pytest_args>
141177
```
142178

143179
## Debugging

0 commit comments

Comments
 (0)