Skip to content

Commit 501c848

Browse files
committed
Merge branch 'master' into constantinius/feat/integration/litellm
2 parents 29b2e35 + f3e8a5c commit 501c848

File tree

89 files changed

+1018
-466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1018
-466
lines changed

.coveragerc36

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
[run]
55
branch = true
6-
omit =
6+
omit =
77
/tmp/*
88
*/tests/*
99
*/.venv/*
1010

1111

1212
[report]
13-
exclude_lines =
13+
exclude_lines =
1414
if TYPE_CHECKING:

.cursor/rules/core-architecture.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: false
55
---
66
# Core Architecture

.cursor/rules/integrations-guide.mdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: false
55
---
66
# Integrations Guide
@@ -133,10 +133,10 @@ from sentry_sdk.integrations import Integration
133133

134134
class MyIntegration(Integration):
135135
identifier = "my_integration"
136-
136+
137137
def __init__(self, param=None):
138138
self.param = param
139-
139+
140140
@staticmethod
141141
def setup_once():
142142
# Install hooks, monkey patches, etc.

.cursor/rules/project-overview.mdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: false
55
---
66
# Sentry Python SDK - Project Overview

.cursor/rules/quick-reference.mdc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: false
55
---
66
# Quick Reference
@@ -44,7 +44,7 @@ tox -e py3.12-django-v5.2.3
4444

4545
### Code Quality
4646

47-
Our `linters` tox environment runs `black` for formatting, `flake8` for linting and `mypy` for type checking.
47+
Our `linters` tox environment runs `ruff-format` for formatting, `ruff-check` for linting and `mypy` for type checking.
4848

4949
```bash
5050
tox -e linters

.cursor/rules/testing-guide.mdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
description:
3-
globs:
2+
description:
3+
globs:
44
alwaysApply: false
55
---
66
# Testing Guide
@@ -65,10 +65,10 @@ def test_flask_integration(sentry_init, capture_events):
6565
# Test setup
6666
sentry_init(integrations=[FlaskIntegration()])
6767
events = capture_events()
68-
68+
6969
# Test execution
7070
# ... test code ...
71-
71+
7272
# Assertions
7373
assert len(events) == 1
7474
assert events[0]["exception"]["values"][0]["type"] == "ValueError"

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Formatting commits to ignore in git blame
2+
afea4a017bf13f78e82f725ea9d6a56a8e02cb34
3+
23a340a9dca60eea36de456def70c00952a33556

.pre-commit-config.yaml

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,9 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
4-
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.3.0
4+
- repo: https://github.com/astral-sh/ruff-pre-commit
5+
rev: v0.13.2
66
hooks:
7-
- id: trailing-whitespace
8-
- id: end-of-file-fixer
9-
10-
- repo: https://github.com/psf/black
11-
rev: 24.1.0
12-
hooks:
13-
- id: black
14-
exclude: ^(.*_pb2.py|.*_pb2_grpc.py)
15-
16-
- repo: https://github.com/pycqa/flake8
17-
rev: 5.0.4
18-
hooks:
19-
- id: flake8
20-
additional_dependencies:
21-
[
22-
flake8-pyproject,
23-
flake8-bugbear,
24-
pep8-naming,
25-
]
26-
27-
# Disabled for now, because it lists a lot of problems.
28-
#- repo: https://github.com/pre-commit/mirrors-mypy
29-
# rev: 'v0.931'
30-
# hooks:
31-
# - id: mypy
7+
- id: ruff-check
8+
args: [--fix]
9+
- id: ruff-format

CONTRIBUTING.md

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ We test against a number of Python language and library versions, which are auto
7878

7979
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.
8080

81-
[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.
81+
[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.
8282

8383
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.
8484

@@ -109,29 +109,20 @@ tox -p auto -o -e <tox_env> -- <pytest_args>
109109
## Adding a New Integration
110110

111111
1. Write the integration.
112-
113-
- Instrument all application instances by default. Prefer global signals/patches instead of configuring a specific instance. Don't make the user pass anything to your integration for anything to work. Aim for zero configuration.
114-
115-
- Everybody monkeypatches. That means:
116-
117-
- Make sure to think about conflicts with other monkeypatches when monkeypatching.
118-
119-
- You don't need to feel bad about it.
120-
112+
- Instrument all application instances by default. Prefer global signals/patches.
113+
- Don't make the user pass anything to your integration for anything to work. Aim for zero configuration.
114+
- Everybody monkeypatches. That means you don't need to feel bad about it.
121115
- Make sure your changes don't break end user contracts. The SDK should never alter the expected behavior of the underlying library or framework from the user's perspective and it shouldn't have any side effects.
122-
123-
- Avoid modifying the hub, registering a new client or the like. The user drives the client, and the client owns integrations.
124-
125-
- Allow the user to turn off the integration by changing the client. Check `Hub.current.get_integration(MyIntegration)` from within your signal handlers to see if your integration is still active before you do anything impactful (such as sending an event).
116+
- Be defensive. Don't assume the code you're patching will stay the same forever, especially if it's an internal function. Allow for future variability whenever it makes sense.
117+
- Avoid registering a new client or the like. The user drives the client, and the client owns integrations.
118+
- Allow the user to turn off the integration by changing the client. Check `sentry_sdk.get_client().get_integration(MyIntegration)` from within your signal handlers to see if your integration is still active before you do anything impactful (such as sending an event).
126119

127120
2. Write tests.
128-
129-
- Consider the minimum versions supported, and test each version in a separate env in `tox.ini`.
130-
121+
- Consider the minimum versions supported, and document in `_MIN_VERSIONS` in `integrations/__init__.py`.
131122
- Create a new folder in `tests/integrations/`, with an `__init__` file that skips the entire suite if the package is not installed.
123+
- Add the test suite to the script generating our test matrix. See [`scripts/populate_tox/README.md`](https://github.com/getsentry/sentry-python/blob/master/scripts/populate_tox/README.md#add-a-new-test-suite).
132124

133125
3. Update package metadata.
134-
135126
- We use `extras_require` in `setup.py` to communicate minimum version requirements for integrations. People can use this in combination with tools like Poetry or Pipenv to detect conflicts between our supported versions and their used versions programmatically.
136127

137128
Do not set upper bounds on version requirements as people are often faster in adopting new versions of a web framework than we are in adding them to the test matrix or our package metadata.
@@ -140,8 +131,6 @@ tox -p auto -o -e <tox_env> -- <pytest_args>
140131

141132
5. Merge docs after new version has been released. The docs are built and deployed after each merge, so your changes should go live in a few minutes.
142133

143-
6. (optional, if possible) Update data in [`sdk_updates.py`](https://github.com/getsentry/sentry/blob/master/src/sentry/sdk_updates.py) to give users in-app suggestions to use your integration. This step will only apply to some integrations.
144-
145134
## Releasing a New Version
146135

147136
_(only relevant for Python SDK core team)_

codecov.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ comment:
1919
# Comments will only post when coverage changes. Furthermore, if a comment
2020
# already exists, and a newer commit results in no coverage change for the
2121
# entire pull, the comment will be deleted.
22-
require_changes: true
22+
require_changes: true
2323
require_base: true # must have a base report to post
2424
require_head: true # must have a head report to post
2525

2626
github_checks:
27-
annotations: false
27+
annotations: false

0 commit comments

Comments
 (0)