Skip to content

Commit

Permalink
chore: Update pre-commit hooks and add py3.11 and py3.12 for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
paveldedik committed Mar 13, 2024
1 parent 76b5df6 commit 311aa87
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}
strategy:
matrix:
toxenv: [py37, py38, py39, py310]
toxenv: [py37, py38, py39, py310, py311, py312]
26 changes: 9 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
repos:
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
hooks:
- id: black
language_version: python3
- id: ruff-format

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.2
hooks:
- id: flake8
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
# extra dependencies for config in pyproject.toml
additional_dependencies: [".[pyproject]"]
- id: ruff
args: ["--fix", "--exit-non-zero-on-fix", "--config", "pyproject.toml"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.0
rev: v1.9.0
hooks:
- id: mypy
13 changes: 9 additions & 4 deletions structlog_sentry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging
import sys
from fnmatch import fnmatch
from typing import Any, Iterable, Optional
from typing import Any, Optional
from collections.abc import MutableMapping, Iterable

from sentry_sdk import Hub
from sentry_sdk.integrations.logging import _IGNORED_LOGGERS
Expand Down Expand Up @@ -83,7 +84,9 @@ def __init__(
self._ignored_loggers.update(set(ignore_loggers))

@staticmethod
def _get_logger_name(logger: WrappedLogger, event_dict: dict) -> Optional[str]:
def _get_logger_name(
logger: WrappedLogger, event_dict: MutableMapping[str, Any]
) -> Optional[str]:
"""Get logger name from event_dict with a fallbacks to logger.name and
record.name
Expand Down Expand Up @@ -116,9 +119,11 @@ def _get_event_and_hint(self, event_dict: EventDict) -> tuple[dict, dict]:
has_exc_info = exc_info and exc_info != (None, None, None)

if has_exc_info:
client = self._get_hub().client
options: dict[str, Any] = client.options if client else {}
event, hint = event_from_exception(
exc_info,
client_options=self._get_hub().client.options,
client_options=options,
)
else:
event, hint = {}, {}
Expand Down Expand Up @@ -197,7 +202,7 @@ def __call__(
self, logger: WrappedLogger, name: str, event_dict: EventDict
) -> EventDict:
"""A middleware to process structlog `event_dict` and send it to Sentry."""
self._original_event_dict = event_dict.copy()
self._original_event_dict = dict(event_dict)
sentry_skip = event_dict.pop("sentry_skip", False)

if self.active and not sentry_skip and self._can_record(logger, event_dict):
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tox]
envlist =
lint
py{37,38,39,310}
py{37,38,39,310,311,312}
isolated_build = true

[testenv]
Expand Down

0 comments on commit 311aa87

Please sign in to comment.