Skip to content

Commit 7973b79

Browse files
committed
Apply the new pypackage cookiecutter template
1 parent 51aacfd commit 7973b79

38 files changed

+734
-702
lines changed

.cookiecutter.json

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

.cookiecutter/cookiecutter.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"template": "https://github.com/hypothesis/cookiecutters",
3+
"checkout": null,
4+
"directory": "pypackage",
5+
"ignore": ["src/h_pyramid_sentry/core.py", "tests/unit/h_pyramid_sentry/core_test.py"],
6+
"extra_context": {
7+
"name": "Hypothesis Pyramid Sentry Extension",
8+
"package_name": "h_pyramid_sentry",
9+
"slug": "h-pyramid-sentry",
10+
"short_description": "A library which integrates Sentry logging into Pyramid with the ability to filter out unwanted messages.",
11+
"python_versions": "3.9.4,3.8.9",
12+
"github_owner": "hypothesis",
13+
"copyright_holder": "Hypothesis",
14+
"visibility": "public",
15+
"console_script": "no",
16+
"devdata": "no",
17+
"services": "no",
18+
"dependabot_pip_interval": "monthly",
19+
"__entry_point": "h-pyramid-sentry",
20+
"__github_url": "https://github.com/hypothesis/h-pyramid-sentry",
21+
"__pypi_url": "https://pypi.org/project/h-pyramid-sentry"
22+
}
23+
}

.cookiecutter/includes/README/head.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
This is a Pyramid extension that wraps
3+
[sentry-sdk's Pyramid integration](https://docs.sentry.io/platforms/python/pyramid/)
4+
and adds some additional customization and features.
5+
6+
Features
7+
--------
8+
9+
* Initializes sentry-sdk with its Pyramid integration for you.
10+
Your app just has to set any `"h_pyramid_sentry.*"` settings that you want
11+
and then do `config.include("h_pyramid_sentry")` (see instructions below for details).
12+
13+
* Prevents retryable exceptions from being reported to Sentry if your app is using
14+
[pyramid_retry](http://docs.pylonsproject.org/projects/pyramid-retry/en/latest/)
15+
and the request is going to be retried
16+
(requires the `"h_pyramid_sentry.retry_support": True` setting, see below).
17+
18+
Retryable exceptions will still be reported to Sentry if the request is not
19+
going to be retried again because it has run out of retry attempts or because
20+
one of the retries fails with a non-retryable exception. When this happens
21+
only the exception from the request's final attempt is reported to Sentry, so
22+
you get a single Sentry event per request not multiple, but information about
23+
the previous failed attempts' exceptions is added to the single Sentry event.
24+
25+
* Ignores errors logged by `exc_logger` if your app is using
26+
[pyramid_exclog](https://docs.pylonsproject.org/projects/pyramid_exclog/en/latest/).
27+
28+
pyramid_exclog logs all exceptions with log-level ERROR, and these all
29+
get picked up by sentry_sdk's [enabled-by-default logging integration](https://docs.sentry.io/platforms/python/logging/).
30+
This would mean that all exceptions in Sentry appear to come from
31+
exc_logger, and that some handled exceptions that wouldn't normally be
32+
reported to Sentry now _would_ get reported. This extension prevents the
33+
interference by telling sentry_sdk to ignore exc_logger.
34+
35+
* Provides a convenient method for apps to register their own filters for
36+
exceptions and logged errors that they don't want to be reported to Sentry.
37+
See the `"h_pyramid_sentry.filters"` setting below.
38+
39+
Usage
40+
-----
41+
42+
```python
43+
config.add_settings({...}) # See below for available settings.
44+
config.include("h_pyramid_sentry")
45+
```
46+
47+
Filters
48+
-------
49+
50+
In your Pyramid configuration you can provide a list of filter functions in the
51+
setting `h_pyramid_sentry.filters`.
52+
53+
These functions are passed [Event](h_pyramid_sentry/event.py) objects which
54+
they can inspect. If the function returns `True`, then the event is not sent to
55+
Sentry.
56+
57+
For example to prevent reporting of `ValueError`s:
58+
59+
```python
60+
config.add_settings({
61+
"h_pyramid_sentry.filters": [
62+
lambda event: instanceof(event.exception, ValueError)
63+
],
64+
})
65+
```
66+
67+
Settings
68+
--------
69+
70+
The extension will listen to the following Pyramid deployment settings:
71+
72+
| Pyramid setting | Effect |
73+
|------------------------|---------------|
74+
| `h_pyramid_sentry.init` | A dict of any [options understood by `sentry_sdk.init()`](https://docs.sentry.io/error-reporting/configuration/?platform=javascript#common-options) |
75+
| `h_pyramid_sentry.filters` | A list of functions to apply as filters |
76+
| `h_pyramid_sentry.retry_support` *| Enable retry detection and filtering|
77+
| `h_pyramid_sentry.celery_support` *| Enable [Celery support for Sentry](https://docs.sentry.io/platforms/python/celery/) |
78+
| `h_pyramid_sentry.sqlalchemy_support` *| Enable [SQLAlchemy support for Sentry](https://docs.sentry.io/platforms/python/sqlalchemy/) |
79+
80+
_* Enabling retry or celery support requires your application to list the relevant dependency (`pyramid_retry` or `celery`) as a dependency._
81+
82+
As per the [Sentry docs](https://docs.sentry.io/error-reporting/configuration/?platform=python#dsn), the
83+
environment variable `SENTRY_DSN` will be automatically read if set, although this can
84+
also be passed along with any other Sentry SDK options via `h_pyramid_sentry.init`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sentry-sdk
2+
pyramid

.cookiecutter/includes/tox/deps

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
lint,tests: celery
2+
lint,tests: pyramid-retry
3+
lint,tests: sqlalchemy

.coveragerc

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

.github/dependabot.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
version: 2
22
updates:
3-
- package-ecosystem: pip
3+
- package-ecosystem: "pip"
44
directory: "/"
55
schedule:
6-
interval: daily
7-
time: "10:00"
8-
open-pull-requests-limit: 10
6+
interval: "monthly"
7+
day: "sunday"
8+
time: "00:00"
9+
timezone: "Europe/London"

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
on:
3+
push:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 1 * * *'
7+
jobs:
8+
Format:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Install Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.9'
16+
- run: python -m pip install tox
17+
- run: tox -e checkformatting
18+
Lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Install Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.9'
26+
- run: python -m pip install tox
27+
- run: tox -e lint
28+
Tests:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ['3.9', '3.8']
33+
name: Unit tests with Python ${{ matrix.python-version }}
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: Install Python
37+
uses: actions/setup-python@v4
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- run: python -m pip install tox
41+
- run: tox -e tests
42+
- name: Upload coverage file
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: coverage
46+
path: .coverage.*
47+
Coverage:
48+
needs: tests
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v3
52+
- name: Install Python
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: '3.9'
56+
- name: Download coverage files
57+
uses: actions/download-artifact@v3
58+
with:
59+
name: coverage
60+
- run: python -m pip install tox
61+
- run: tox -e coverage
62+
Functests:
63+
runs-on: ubuntu-latest
64+
strategy:
65+
matrix:
66+
python-version: ['3.9', '3.8']
67+
name: Functional tests with Python ${{ matrix.python-version }}
68+
steps:
69+
- uses: actions/checkout@v3
70+
- name: Install Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: ${{ matrix.python-version }}
74+
- run: python -m pip install tox
75+
- run: tox -e functests

.github/workflows/pypi.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: PyPI
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
PyPI:
7+
uses: hypothesis/workflows/.github/workflows/pypi.yml@main
8+
secrets: inherit

0 commit comments

Comments
 (0)