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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ dmypy.json
.mutmut-cache
html/

# vim
Session.vim

# Misc
TODO.md
junit.xml
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.8.6
rev: v0.14.0
hooks:
# Run the linter.
- id: ruff
# Run the formatter.
- id: ruff-format
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.390
rev: v1.1.406
hooks:
- id: pyright
# I don't love having to specify these here, but pre-commit only seems to work
Expand Down
14 changes: 7 additions & 7 deletions annotated_logger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import logging.config
import time
import uuid
from collections.abc import Iterator
from collections.abc import Callable, Iterator
from copy import copy, deepcopy
from typing import (
TYPE_CHECKING,
Any,
Callable,
Concatenate,
Literal,
ParamSpec,
Expand All @@ -34,7 +33,7 @@
# https://test.pypi.org/project/annotated-logger/
# The dev versions in testpypi can then be pulled in to whatever project needed
# the new feature.
VERSION = "1.2.3" # pragma: no mutate
VERSION = "1.2.4" # pragma: no mutate

T = TypeVar("T")
P = ParamSpec("P")
Expand Down Expand Up @@ -732,7 +731,7 @@ def wrap_class(
cls=wrapped, logger_base_name=logger_name
)
logger.debug("init")
new = cast(AnnotatedClass[C_co], wrapped(*args, **kwargs))
new = cast("AnnotatedClass[C_co]", wrapped(*args, **kwargs))
new.annotated_logger = logger
return new

Expand Down Expand Up @@ -766,7 +765,7 @@ def wrap_function(*args: P.args, **kwargs: P.kwargs) -> R:
post_call_attempted = True
_attempt_post_call(post_call, logger, *new_args, **new_kwargs) # pyright: ignore[reportCallIssue]
end_time = time.perf_counter()
logger.annotate(run_time=f"{end_time - start_time :.1f}")
logger.annotate(run_time=f"{end_time - start_time:.1f}")
with contextlib.suppress(TypeError):
logger.annotate(count=len(result)) # pyright: ignore[reportArgumentType]

Expand Down Expand Up @@ -880,7 +879,7 @@ def _inject_by_kwarg(
else:
instance = False # pragma: no mutate
logger, annotations = self._pick_correct_logger(
function, instance, logger_base_name=logger_base_name
function, instance=instance, logger_base_name=logger_base_name
)
if not provided:
kwargs["annotated_logger"] = logger
Expand All @@ -904,7 +903,7 @@ def _inject_by_index( # noqa: PLR0913
else:
instance = False # pragma: no mutate
logger, annotations = self._pick_correct_logger(
function, instance, logger_base_name=logger_base_name
function, instance=instance, logger_base_name=logger_base_name
)
if not provided:
args.insert(index, logger)
Expand All @@ -927,6 +926,7 @@ def _check_parameters_for_self_and_cls(
def _pick_correct_logger(
self,
function: Function[S, P, R],
*,
instance: object | bool,
logger_base_name: str | None = None,
) -> tuple[AnnotatedAdapter, Annotations | None]:
Expand Down
4 changes: 3 additions & 1 deletion annotated_logger/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import contextlib
import logging
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any

from requests.exceptions import HTTPError

from annotated_logger.filter import AnnotatedFilter

if TYPE_CHECKING: # pragma: no cover
from collections.abc import Callable

from annotated_logger import AnnotatedAdapter


Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
# - requests
#

certifi==2024.12.14
certifi==2025.10.5
# via requests
charset-normalizer==3.4.1
charset-normalizer==3.4.3
# via requests
idna==3.10
# via requests
makefun==1.15.6
makefun==1.16.0
# via hatch.envs.default
pychoir==0.0.27
pychoir==0.0.29
# via hatch.envs.default
python-json-logger==3.2.1
python-json-logger==4.0.0
# via hatch.envs.default
requests==2.32.4
requests==2.32.5
# via hatch.envs.default
urllib3==2.5.0
# via requests
101 changes: 48 additions & 53 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# This file is autogenerated by hatch-pip-compile with Python 3.10
# This file is autogenerated by hatch-pip-compile with Python 3.12
#
# - coverage
# - mutmut
Expand All @@ -20,128 +20,123 @@
# - requests
#

certifi==2024.12.14
certifi==2025.10.5
# via requests
cfgv==3.4.0
# via pre-commit
charset-normalizer==3.4.1
charset-normalizer==3.4.3
# via requests
click==8.1.8
click==8.3.0
# via mutmut
coverage==7.6.10
coverage==7.10.7
# via
# hatch.envs.dev
# pytest-cov
distlib==0.3.9
distlib==0.4.0
# via virtualenv
exceptiongroup==1.2.2
# via pytest
filelock==3.16.1
filelock==3.20.0
# via virtualenv
freezegun==1.5.1
freezegun==1.5.5
# via pytest-freezer
identify==2.6.5
identify==2.6.15
# via pre-commit
idna==3.10
# via requests
iniconfig==2.0.0
iniconfig==2.1.0
# via pytest
junit-xml==1.8
libcst==1.7.0
# via mutmut
linkify-it-py==2.0.3
# via markdown-it-py
makefun==1.15.6
makefun==1.16.0
# via hatch.envs.dev
markdown-it-py==3.0.0
markdown-it-py==4.0.0
# via
# mdit-py-plugins
# rich
# textual
mdit-py-plugins==0.4.2
mdit-py-plugins==0.5.0
# via markdown-it-py
mdurl==0.1.2
# via markdown-it-py
mutmut==3.2.2
mutmut==3.3.1
# via hatch.envs.dev
nodeenv==1.9.1
# via
# pre-commit
# pyright
packaging==24.2
packaging==25.0
# via pytest
parso==0.8.4
# via mutmut
platformdirs==4.3.6
platformdirs==4.5.0
# via
# textual
# virtualenv
pluggy==1.5.0
# via pytest
pre-commit==4.0.1
pluggy==1.6.0
# via
# pytest
# pytest-cov
pre-commit==4.3.0
# via hatch.envs.dev
pychoir==0.0.27
pychoir==0.0.29
# via hatch.envs.dev
pygments==2.19.1
# via rich
pyright==1.1.391
pygments==2.19.2
# via
# pytest
# rich
# textual
pyright==1.1.406
# via hatch.envs.dev
pytest==8.3.4
pytest==8.4.2
# via
# hatch.envs.dev
# mutmut
# pytest-cov
# pytest-freezer
# pytest-github-actions-annotate-failures
# pytest-mock
# pytest-randomly
pytest-cov==6.0.0
pytest-cov==7.0.0
# via hatch.envs.dev
pytest-freezer==0.4.9
# via hatch.envs.dev
pytest-github-actions-annotate-failures==0.2.0
pytest-github-actions-annotate-failures==0.3.0
# via hatch.envs.dev
pytest-mock==3.14.0
pytest-mock==3.15.1
# via hatch.envs.dev
pytest-randomly==3.16.0
pytest-randomly==4.0.1
# via hatch.envs.dev
python-dateutil==2.9.0.post0
# via freezegun
python-json-logger==3.2.1
python-json-logger==4.0.0
# via hatch.envs.dev
pyyaml==6.0.2
# via pre-commit
requests==2.32.4
pyyaml==6.0.3
# via
# libcst
# pre-commit
requests==2.32.5
# via
# hatch.envs.dev
# requests-mock
requests-mock==1.12.1
# via hatch.envs.dev
rich==13.9.4
rich==14.2.0
# via textual
ruff==0.8.6
ruff==0.14.0
# via hatch.envs.dev
setproctitle==1.3.4
setproctitle==1.3.7
# via mutmut
six==1.17.0
# via
# junit-xml
# python-dateutil
textual==1.0.0
# via python-dateutil
textual==6.2.1
# via mutmut
toml==0.10.2
# via mutmut
tomli==2.2.1
# via
# coverage
# pytest
typing-extensions==4.12.2
typing-extensions==4.15.0
# via
# hatch.envs.dev
# pyright
# rich
# textual
uc-micro-py==1.0.3
# via linkify-it-py
urllib3==2.5.0
# via requests
virtualenv==20.28.1
virtualenv==20.34.0
# via pre-commit
4 changes: 2 additions & 2 deletions test/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,6 @@ def test_args_kwargs_splat_provided_not_instance(
class TestNonClassBased:
def test_annotated_logger_must_be_first(self):
with pytest.raises(
TypeError, match="^annotated_logger must be the first argument$"
TypeError, match=r"^annotated_logger must be the first argument$"
):
import example.invalid_order # noqa: F401
import example.invalid_order # noqa: F401 PLC0415
2 changes: 1 addition & 1 deletion test/test_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def wrong_present_for_add_success(expected, missing=None, incorrect=None):
else:
incorrect_string = ", ".join(
[
f"\"Extra `{d['key']}` value is incorrect. Desired `{d['expected']}` ({type(d['expected'])}) , actual `{d['actual']}` ({type(d['actual'])})\""
f'"Extra `{d["key"]}` value is incorrect. Desired `{d["expected"]}` ({type(d["expected"])}) , actual `{d["actual"]}` ({type(d["actual"])})"'
for d in incorrect
]
)
Expand Down
Loading