You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+50-14Lines changed: 50 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,38 +74,62 @@ On macOS, we recommend using `brew` to install Python. For Windows, we recommend
74
74
75
75
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.
76
76
77
-
### Create a Virtual Environment
77
+
78
+
### Development Tooling
78
79
79
80
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:
80
81
81
82
```bash
82
83
cd sentry-python
83
-
84
84
uv sync
85
85
```
86
86
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
-
89
87
Invoke commands via `uv run <cmd>` (e.g. `uv run tox -e py3.14-common`).
90
88
91
-
###Install `sentry-python` in Editable Mode
89
+
#### Linting / Formatting
92
90
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:
94
92
95
-
```bash
96
-
pip install -e .
93
+
```
94
+
uv run ruff check --fix tests sentry_sdk
95
+
uv run ruff format tests sentry_sdk
97
96
```
98
97
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
100
99
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
102
107
103
108
`pre-commit` is included in the project's dev dependencies (installed by `uv sync`). Register the git hooks with:
104
109
105
110
```bash
106
111
uv run pre-commit install
107
112
```
108
113
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
+
109
133
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).
110
134
111
135
## Running Tests
@@ -116,28 +140,40 @@ We test against a number of Python language and library versions, which are auto
116
140
117
141
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.
118
142
143
+
To list all tox environments:
144
+
145
+
```bash
146
+
uv run tox -l
147
+
```
148
+
119
149
To run Celery tests for version v5.5.3 of its Python library using a 3.12 interpreter, use
120
150
121
151
```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
123
153
```
124
154
125
155
or to use the `common` environment, run
126
156
127
157
```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
129
165
```
130
166
131
167
To select specific tests, you can forward arguments to `pytest` like so
132
168
133
169
```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
135
171
```
136
172
137
173
In general, you use
138
174
139
175
```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>
0 commit comments