Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .coveragerc36
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

[run]
branch = true
omit =
omit =
/tmp/*
*/tests/*
*/.venv/*


[report]
exclude_lines =
exclude_lines =
if TYPE_CHECKING:
4 changes: 2 additions & 2 deletions .cursor/rules/core-architecture.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description:
globs:
description:
globs:
alwaysApply: false
---
# Core Architecture
Expand Down
8 changes: 4 additions & 4 deletions .cursor/rules/integrations-guide.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description:
globs:
description:
globs:
alwaysApply: false
---
# Integrations Guide
Expand Down Expand Up @@ -133,10 +133,10 @@ from sentry_sdk.integrations import Integration

class MyIntegration(Integration):
identifier = "my_integration"

def __init__(self, param=None):
self.param = param

@staticmethod
def setup_once():
# Install hooks, monkey patches, etc.
Expand Down
4 changes: 2 additions & 2 deletions .cursor/rules/project-overview.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description:
globs:
description:
globs:
alwaysApply: false
---
# Sentry Python SDK - Project Overview
Expand Down
6 changes: 3 additions & 3 deletions .cursor/rules/quick-reference.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description:
globs:
description:
globs:
alwaysApply: false
---
# Quick Reference
Expand Down Expand Up @@ -44,7 +44,7 @@ tox -e py3.12-django-v5.2.3

### Code Quality

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

```bash
tox -e linters
Expand Down
8 changes: 4 additions & 4 deletions .cursor/rules/testing-guide.mdc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
description:
globs:
description:
globs:
alwaysApply: false
---
# Testing Guide
Expand Down Expand Up @@ -65,10 +65,10 @@ def test_flask_integration(sentry_init, capture_events):
# Test setup
sentry_init(integrations=[FlaskIntegration()])
events = capture_events()

# Test execution
# ... test code ...

# Assertions
assert len(events) == 1
assert events[0]["exception"]["values"][0]["type"] == "ValueError"
Expand Down
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Formatting commits to ignore in git blame
afea4a017bf13f78e82f725ea9d6a56a8e02cb34
23a340a9dca60eea36de456def70c00952a33556
32 changes: 5 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,9 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.13.2
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer

- repo: https://github.com/psf/black
rev: 24.1.0
hooks:
- id: black
exclude: ^(.*_pb2.py|.*_pb2_grpc.py)

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies:
[
flake8-pyproject,
flake8-bugbear,
pep8-naming,
]

# Disabled for now, because it lists a lot of problems.
#- repo: https://github.com/pre-commit/mirrors-mypy
# rev: 'v0.931'
# hooks:
# - id: mypy
- id: ruff-check
args: [--fix]
- id: ruff-format
4 changes: 2 additions & 2 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ comment:
# Comments will only post when coverage changes. Furthermore, if a comment
# already exists, and a newer commit results in no coverage change for the
# entire pull, the comment will be deleted.
require_changes: true
require_changes: true
require_base: true # must have a base report to post
require_head: true # must have a head report to post

github_checks:
annotations: false
annotations: false
79 changes: 41 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
#
# Tool: Black
#

[tool.black]
# 'extend-exclude' excludes files or directories in addition to the defaults
extend-exclude = '''
# A regex preceded with ^/ will apply only to files and directories
# in the root of the project.
(
.*_pb2.py # exclude autogenerated Protocol Buffer files anywhere in the project
| .*_pb2_grpc.py # exclude autogenerated Protocol Buffer files anywhere in the project
)
'''


#
# Tool: Coverage
#
Expand Down Expand Up @@ -196,29 +180,48 @@ module = "agents.*"
ignore_missing_imports = true

#
# Tool: Flake8
# Tool: Ruff (linting and formatting)
#

[tool.flake8]
extend-ignore = [
# Handled by black (Whitespace before ':' -- handled by black)
"E203",
# Handled by black (Line too long)
"E501",
# Sometimes not possible due to execution order (Module level import is not at top of file)
"E402",
# I don't care (Do not assign a lambda expression, use a def)
"E731",
# does not apply to Python 2 (redundant exception types by flake8-bugbear)
"B014",
# I don't care (Lowercase imported as non-lowercase by pep8-naming)
"N812",
# is a worse version of and conflicts with B902 (first argument of a classmethod should be named cls)
"N804",
[tool.ruff]
# Target Python 3.7+ (minimum version supported by ruff)
target-version = "py37"

# Exclude files and directories
extend-exclude = [
"*_pb2.py", # Protocol Buffer files (covers all pb2 files including grpc_test_service_pb2.py)
"*_pb2_grpc.py", # Protocol Buffer files (covers all pb2_grpc files including grpc_test_service_pb2_grpc.py)
"checkouts", # From flake8
"lol*", # From flake8
]
extend-exclude = ["checkouts", "lol*"]
exclude = [
# gRCP generated files
"grpc_test_service_pb2.py",
"grpc_test_service_pb2_grpc.py",

[tool.ruff.lint]
# Match flake8's default rule selection exactly
# Flake8 by default only enables E and W (pycodestyle) + F (pyflakes)
select = [
"E", # pycodestyle errors (same as flake8 default)
"W", # pycodestyle warnings (same as flake8 default)
"F", # Pyflakes (same as flake8 default)
# Note: B and N rules are NOT enabled by default in flake8
# They were only active through the plugins, which may not have been fully enabled
]

# Use ONLY the same ignores as the original flake8 config + compatibility for this codebase
ignore = [
"E203", # Whitespace before ':'
"E501", # Line too long
"E402", # Module level import not at top of file
"E731", # Do not assign a lambda expression, use a def
"B014", # Redundant exception types
"N812", # Lowercase imported as non-lowercase
"N804", # First argument of classmethod should be named cls

# Additional ignores for codebase compatibility
"F401", # Unused imports - many in TYPE_CHECKING blocks used for type comments
"E721", # Use isinstance instead of type() == - existing pattern in this codebase
]

[tool.ruff.format]
# ruff format already excludes the same files as specified in extend-exclude
# Ensure Python 3.7 compatibility - avoid using Python 3.9+ syntax features
skip-magic-trailing-comma = false
6 changes: 1 addition & 5 deletions requirements-linting.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
mypy
black
flake8==5.0.4
flake8-pyproject # Flake8 plugin to support configuration in pyproject.toml
flake8-bugbear # Flake8 plugin
pep8-naming # Flake8 plugin
ruff
types-certifi
types-protobuf
types-gevent
Expand Down
3 changes: 1 addition & 2 deletions scripts/build_aws_lambda_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ def create_init_serverless_sdk_package(self):
sentry-python-serverless zip
"""
serverless_sdk_path = (
f"{self.python_site_packages}/sentry_sdk/"
f"integrations/init_serverless_sdk"
f"{self.python_site_packages}/sentry_sdk/integrations/init_serverless_sdk"
)
if not os.path.exists(serverless_sdk_path):
os.makedirs(serverless_sdk_path)
Expand Down
8 changes: 4 additions & 4 deletions scripts/populate_tox/populate_tox.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def _add_python_versions_to_release(


def _transform_target_python_versions(
python_versions: Union[str, dict[str, str], None]
python_versions: Union[str, dict[str, str], None],
) -> Union[SpecifierSet, dict[SpecifierSet, SpecifierSet], None]:
"""Wrap the contents of the `python` key in SpecifierSets."""
if not python_versions:
Expand Down Expand Up @@ -711,9 +711,9 @@ def main(fail_on_changes: bool = False) -> None:
name = _normalize_name(release["info"]["name"])
version = release["info"]["version"]
CACHE[name][version] = release
CACHE[name][version][
"_accessed"
] = False # for cleaning up unused cache entries
CACHE[name][version]["_accessed"] = (
False # for cleaning up unused cache entries
)

# Process packages
packages = defaultdict(list)
Expand Down
4 changes: 2 additions & 2 deletions scripts/populate_tox/releases.jsonl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7"], "name": "boto3", "requires_python": "", "version": "1.12.49", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">= 3.6", "version": "1.20.54", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">= 3.7", "version": "1.28.85", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">=3.9", "version": "1.40.38", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.9"], "name": "boto3", "requires_python": ">=3.9", "version": "1.40.39", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: Internet :: WWW/HTTP :: WSGI :: Server", "Topic :: Software Development :: Libraries :: Application Frameworks"], "name": "bottle", "requires_python": "", "version": "0.12.25", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP :: Dynamic Content :: CGI Tools/Libraries", "Topic :: Internet :: WWW/HTTP :: HTTP Servers", "Topic :: Internet :: WWW/HTTP :: WSGI", "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", "Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware", "Topic :: Internet :: WWW/HTTP :: WSGI :: Server", "Topic :: Software Development :: Libraries :: Application Frameworks"], "name": "bottle", "requires_python": null, "version": "0.13.4", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Object Brokering", "Topic :: System :: Distributed Computing"], "name": "celery", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", "version": "4.4.7", "yanked": false}}
Expand Down Expand Up @@ -77,7 +77,7 @@
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8"], "name": "grpcio", "requires_python": "", "version": "1.32.0", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "grpcio", "requires_python": ">=3.6", "version": "1.47.5", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9"], "name": "grpcio", "requires_python": ">=3.7", "version": "1.62.3", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.9"], "name": "grpcio", "requires_python": ">=3.9", "version": "1.75.0", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3.9"], "name": "grpcio", "requires_python": ">=3.9", "version": "1.75.1", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: AsyncIO", "Framework :: Trio", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP"], "name": "httpx", "requires_python": ">=3.6", "version": "0.16.1", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: AsyncIO", "Framework :: Trio", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP"], "name": "httpx", "requires_python": ">=3.6", "version": "0.20.0", "yanked": false}}
{"info": {"classifiers": ["Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: AsyncIO", "Framework :: Trio", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Topic :: Internet :: WWW/HTTP"], "name": "httpx", "requires_python": ">=3.6", "version": "0.22.0", "yanked": false}}
Expand Down
12 changes: 5 additions & 7 deletions scripts/populate_tox/tox.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,9 @@ basepython =
py3.12: python3.12
py3.13: python3.13

# Python version is pinned here because flake8 actually behaves differently
# depending on which version is used. You can patch this out to point to
# some random Python 3 binary, but then you get guaranteed mismatches with
# CI. Other tools such as mypy and black have options that pin the Python
# version.
# Python version is pinned here for consistency across environments.
# Tools like ruff and mypy have options that pin the target Python
# version (configured in pyproject.toml), ensuring consistent behavior.
linters: python3.12

commands =
Expand All @@ -196,6 +194,6 @@ commands =

[testenv:linters]
commands =
flake8 tests sentry_sdk
black --check tests sentry_sdk
ruff check tests sentry_sdk
ruff format --check tests sentry_sdk
mypy sentry_sdk
2 changes: 1 addition & 1 deletion scripts/ready_yet/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def main():
Check if libraries in our tox.ini are ready for Python version defined in `PYTHON_VERSION`.
"""
print(f"Checking libs from tox.ini for Python {PYTHON_VERSION} compatibility:")

ready = set()
not_ready = set()
not_found = set()
Expand Down
4 changes: 2 additions & 2 deletions scripts/ready_yet/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# exit on first error
set -xe

reset
reset

# create and activate virtual environment
python -m venv .venv
Expand All @@ -13,4 +13,4 @@ source .venv/bin/activate
python -m pip install -r requirements.txt

# Run the script
python main.py
python main.py
Loading