Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install dependencies
run: pip install build
- name: Create packages
run: python -m build
- name: Archive packages
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
Expand All @@ -36,7 +36,7 @@ jobs:
id-token: write
steps:
- name: Retrieve packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
- name: Upload packages
uses: pypa/gh-action-pypi-publish@release/v1

Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.7", "3.10", "3.11", "3.12", "pypy-3.9"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy-3.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Install dependencies
run: pip install -e .[test] coverage
run: pip install -e .[test]
- name: Test with pytest
run: |
coverage run -m pytest
coverage xml
run: coverage run -m pytest -v
- name: Generate coverage report
run: coverage xml
- name: Upload Coverage
uses: coverallsapp/github-action@v2
with:
Expand Down
11 changes: 7 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * Run "pre-commit install".
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -16,14 +16,17 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
rev: v0.8.3
hooks:
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies: ["pytest"]
additional_dependencies:
- asphalt@git+https://github.com/asphalt-framework/asphalt
- pytest
- sentry-sdk
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.8"
python: "3.9"

sphinx:
configuration: docs/conf.py
Expand Down
18 changes: 8 additions & 10 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
API reference
=============

.. py:currentmodule:: asphalt.exceptions

Component
---------

.. autoclass:: asphalt.exceptions.component.ExceptionReporterComponent
:members:
.. autoclass:: ExceptionReporterComponent

Functions
---------

.. autofunction:: asphalt.exceptions.report_exception
.. autofunction:: report_exception

Abstract classes
----------------
Interfaces
----------

.. automodule:: asphalt.exceptions.api
:members:
.. autoclass:: ExceptionReporter
.. autoclass:: ExtrasProvider

Exception reporters
-------------------

.. autoclass:: asphalt.exceptions.reporters.sentry.SentryExceptionReporter
:members:

.. autoclass:: asphalt.exceptions.reporters.raygun.RaygunExceptionReporter
:members:
8 changes: 5 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
from importlib.metadata import version
import importlib.metadata

from packaging.version import parse

Expand All @@ -8,6 +8,7 @@
"sphinx.ext.intersphinx",
"sphinx.ext.extlinks",
"sphinx_autodoc_typehints",
"sphinx_rtd_theme",
]

templates_path = ["_templates"]
Expand All @@ -17,19 +18,20 @@
author = "Alex Grönholm"
copyright = "2017, " + author

v = parse(version(project))
v = parse(importlib.metadata.version(project))
version = v.base_version
release = v.public

language = "en"

exclude_patterns = ["_build"]
pygments_style = "sphinx"
autodoc_default_options = {"members": True, "show-inheritance": True}
autodoc_inherit_docstrings = False
highlight_language = "python3"
todo_include_todos = False

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
htmlhelp_basename = project.replace("-", "") + "doc"

extlinks = {
Expand Down
6 changes: 3 additions & 3 deletions docs/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Writing new reporter backends
-----------------------------

To support new exception reporting services, you can subclass the
:class:`~asphalt.exceptions.api.ExceptionReporter` class. You just need to implement the
:meth:`~asphalt.exceptions.api.ExceptionReporter.report_exception` method.
:class:`~asphalt.exceptions.ExceptionReporter` class. You just need to implement the
:meth:`~asphalt.exceptions.ExceptionReporter.report_exception` method.

If you want your exception reporter to be available as a backend for
:class:`~asphalt.exceptions.component.ExceptionReporterComponent`, you need to add the
Expand Down Expand Up @@ -39,7 +39,7 @@ Writing extras providers
------------------------

If you want to provide backend specific extra data for exception reporting, you can do so by
subclassing :class:`~asphalt.exceptions.api.ExtrasProvider` and adding one or more instances of it
subclassing :class:`~asphalt.exceptions.ExtrasProvider` and adding one or more instances of it
as resources to the context.

For example, if you wanted to provide extra data for Sentry about your custom context
Expand Down
11 changes: 6 additions & 5 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ When an exception is caught, the typical course of action is to log it::
except Exception:
logger.exception('Tried to do something but it failed :(')

To take advantage of the exception reporters configured with this component, all you have to do is
call :func:`~asphalt.exceptions.report_exception` instead::
To take advantage of the exception reporters configured with this component, all you
have to do is call :func:`~asphalt.exceptions.report_exception` instead::

from asphalt.exceptions import report_exception

Expand All @@ -26,6 +26,7 @@ call :func:`~asphalt.exceptions.report_exception` instead::
This will not only log the exception as usual, but also send it to any external services
represented by the configured exception reporter backends.

The ``ctx`` argument is required in order for the function to find the configured exception
reporter resources. Additionally, it looks up plugins matching the fully qualified class name of
the context object to provide additional information to each exception reporter backend.
The ``ctx`` argument is required in order for the function to find the configured
exception reporter resources. Additionally, it looks up plugins matching the fully
qualified class name of the context object to provide additional information to each
exception reporter backend.
60 changes: 28 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ classifiers = [
"Typing :: Typed",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
requires-python = ">=3.7"
requires-python = ">=3.9"
dependencies = [
"asphalt ~= 4.6",
"asphalt @ git+https://github.com/asphalt-framework/asphalt",
"typing_extensions >= 4.6.0; python_version < '3.10'"
]
dynamic = ["version"]
Expand All @@ -38,10 +37,10 @@ Homepage = "https://github.com/asphalt-framework/asphalt-exceptions"

[project.optional-dependencies]
test = [
"anyio[trio] ~= 4.1",
"asphalt-exceptions[sentry,raygun]",
"coverage >= 7",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-mock",
]
doc = [
Expand All @@ -64,33 +63,31 @@ raygun = "asphalt.exceptions.reporters.raygun:RaygunExceptionReporter"
version_scheme = "post-release"
local_scheme = "dirty-tag"

[tool.ruff]
line-length = 99
target-version = "py37"

[tool.ruff.lint]
select = [
"ASYNC", # flake8-async
"E", "F", "W", # default Flake8
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"RUF", # Ruff-specific rules
"UP", # pyupgrade
"W", # pycodestyle warnings
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["asphalt.exceptions"]
known-third-party = ["asphalt.core"]

[tool.pytest.ini_options]
addopts = "-rsx --tb=short"
asyncio_mode = "strict"
addopts = ["-rsfE", "--tb=short"]
testpaths = ["tests"]

[tool.mypy]
python_version = "3.7"
ignore_missing_imports = true
python_version = "3.9"
strict = true
explicit_package_bases = true
mypy_path = ["src", "tests"]

[tool.coverage.run]
source = ["asphalt.exceptions"]
Expand All @@ -101,19 +98,18 @@ branch = true
show_missing = true

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, py310, py311, py312, pypy3
env_list = ["py39", "py310", "py311", "py312", "py313", "pypy3"]
skip_missing_interpreters = true
minversion = 4.4.3

[testenv]
extras = test
commands = python -m pytest {posargs}
package = editable

[testenv:docs]
extras = doc
commands = sphinx-build docs build/sphinx
package = editable
"""

[tool.tox.env_run_base]
commands = [["python", "-m", "pytest", { replace = "posargs", extend = true }]]
package = "editable"
extras = ["test"]

[tool.tox.env.pyright]
deps = ["pyright"]
commands = [["pyright", "--verifytypes", "asphalt.exceptions"]]

[tool.tox.env.docs]
commands = [["sphinx-build", "-W", "-n", "docs", "build/sphinx", { replace = "posargs", extend = true }]]
extras = ["doc"]
Loading
Loading